Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Language.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Language.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Language.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Language.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + +/** + * Represents a language as expressed by the RDF 4646 language tag + * + * @author reto + */ +public class Language { + + private String id; + + /** + * Constructs the language tag defined by RDF 4646, normalized to lowercase. + * + * @param the id as defined by RDF 4646, normalized to lowercase. + */ + public Language(String id) { + if ((id == null) || (id.equals(""))) { + throw new IllegalArgumentException("A language id may not be null or empty"); + } + this.id = id; + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other instanceof Language) { + return id.equals(((Language) other).id); + } else { + return false; + } + } + + @Override + public int hashCode() { + return id.hashCode(); + } + + @Override + public String toString() { + return id; + } +}
Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Literal.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Literal.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Literal.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Literal.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + +import org.apache.commons.rdf.Resource; + +/** + * Represents a literal value that can be a node in an RDF Graph. + * Literals are used to identify values such as numbers and dates by + * means of a lexical representation. There are two types of literals + * represented by the subinterfaces {@link PlainLiteral} + * and {@link TypedLiteral} + * + * @author reto + */ +public interface Literal extends Resource { + + /** + * + * @return the text of this literal + */ + public String getLexicalForm(); +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/MGraph.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/MGraph.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/MGraph.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/MGraph.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + +/** + * A mutable graph + * + * @author reto + * + */ +public interface MGraph extends TripleCollection { + + /** + * Returns true if <code>other</code> represents the same mutable graph as + * this instance, false otherwise. It returns true if this == other or if it + * is otherwise guaranteed that changes to one of the instances are + * immediately reflected in the other. + * + * @param other + * @return true if other == this + */ + @Override + public boolean equals(Object other); + + /** + * Returns the graph + * + * @return graph + */ + public Graph getGraph(); +} \ No newline at end of file Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/NoConvertorException.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/NoConvertorException.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/NoConvertorException.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/NoConvertorException.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + +import java.lang.reflect.Type; + +/** + * This exception is thrown when no convertor is available to do a required + * java-object to literal or literal to java-object conversion. + * + * @since 0.3 + * @author reto + */ +public class NoConvertorException extends RuntimeException { + + /** + * Create an instance of <code>NoConvertorException</code> + * indicating that no convertor is available for the type. + * + * @param type the type for which no convertor is available + */ + public NoConvertorException(Type type) { + super("No convertor available for type "+type); + } +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/NonLiteral.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/NonLiteral.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/NonLiteral.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/NonLiteral.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + +/** + * Represents a <code>Resource</code> that is not a <code>Literal</code>. + * This is a marker interface implemented by <code>UriRef</code> + * and <code>BNode</code>. + * + * @author reto + */ +public interface NonLiteral extends Resource { + +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/PlainLiteral.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/PlainLiteral.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/PlainLiteral.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/PlainLiteral.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + + +/** + * A string combined with an optional language tag + * The lexical form is the string represented by the Literal + * without including the language tag + * + * @author reto + * + */ +public interface PlainLiteral extends Literal { + public Language getLanguage(); + + /** + * Returns true if <code>obj</code> is an instance of + * <code>PlainLiteral</code> for which the lexical form and the language + * are equals to the ones of this instance, false otherwise + * + * @return true if obj == this + */ + public boolean equals(Object obj); + + /** + * Returns the hash code of the lexical form plus the hash code of the language + * + * @return hash code + */ + public int hashCode(); +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Resource.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Resource.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Resource.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Resource.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + +/** + * Some entity. It could be a web resource such as a web page, or it could + * be a concrete physical thing such as a tree or a car. It could be an + * abstract idea such as a football game. + * + * @author reto + */ +public interface Resource { + +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Triple.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Triple.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Triple.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/Triple.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + +/** + * A structure containing a subject, a predicate, and an object. + * Also known as a statement. + * + * @author reto + */ +public interface Triple { + + NonLiteral getSubject(); + + UriRef getPredicate(); + + Resource getObject(); + + /** + * + * @param obj + * @return true iff subject, predicate, and object of both triples are equal + */ + @Override + boolean equals(Object obj); + + /** + * The hash code is computed as follow + * (subject.hashCode() >> 1) ^ predicate.hashCode() ^ object.hashCode() << 1) + * + * Note that the hash returned is computed including the hash of BNodes, so + * it is not blank-node blind as in Graph. + * + * This would have to change if triple should extend Graph + * + * @return hash code + */ + @Override + int hashCode(); + +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/TripleCollection.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/TripleCollection.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/TripleCollection.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/TripleCollection.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + +import java.util.Collection; +import java.util.Iterator; +import org.apache.commons.rdf.event.FilterTriple; +import org.apache.commons.rdf.event.GraphListener; + + +/** + * A set of triples (as it doesn't allow duplicates), it does however + * not extend {@link java.util.Set} as it doesn't inherit its + * specification for <code>hashCode()</code> and <code>equals</code>. + * It is possible to add <code>GraphListener</code> to listen for modifications + * in the triples. + * + * @author reto + */ +public interface TripleCollection extends Collection<Triple> { + + /** + * Filters triples given a pattern. + * filter(null, null, null) returns the same as iterator() + * + * @param subject + * @param predicate + * @param object + * @return <code>Iterator</code> + */ + public Iterator<Triple> filter(NonLiteral subject, UriRef predicate, + Resource object); + + /** + * Adds the specified <code>GraphListener</code> to the graph. This listener + * will be notified, when the graph is modified and the <code>Triple</code> + * that was part of the modifiaction matched the specified + * <code>FilterTriple</code>. The notification will be passed to the + * listener after the specified delay time (in milli-seconds) has passed. + * If more matching events occur during the delay period, then they are + * passed all together at the end of the delay period. If the the listener + * unregisters or the platform is stopped within the period then the already + * occurred events may not be delivered. + * + * All implementations support this method, immutable implementations will + * typically provide an empty implementation, they shall not throw an + * exception. + * + * Implementation of which the triples change over time without add- and + * remove-methods being called (e.g. implementation dynamically generating + * their triples on invocation of the filer-method) may choose not to, or + * only partially propagate their changes to the listener. They should + * describe the behavior in the documentation of the class. + * + * Implementations should keep weak references the listeners, so that the + * listener can be garbage collected if its no longer referenced by another + * object. + * + * If delay is 0 notification will happen synchroneously. + * + * @param listener The listener that will be notified + * @param filter The triple filter with which triples are tested, + * that were part of the modification. + * @param delay The time period afer which the listener will be notified in milliseconds. + */ + public void addGraphListener(GraphListener listener, FilterTriple filter, + long delay); + + /** + * Adds the specified <code>GraphListener</code> to the graph. This listener + * will be notified, when the graph is modified and the <code>Triple</code> + * that was part of the modifiaction matched the specified + * <code>FilterTriple</code>. The notification will be passed without delay. + * + * Same as <code>addGraphListener(listener, filter, 0). + * + * @param listener The listener that will be notified + * @param filter The triple filter with which triples are tested, + * that were part of the modification. + */ + public void addGraphListener(GraphListener listener, FilterTriple filter); + + /** + * Removes the specified <code>GraphListener</code> from the graph. This + * listener will no longer be notified, when the graph is modified. + * + * @param listener The listener to be removed. + */ + public void removeGraphListener(GraphListener listener); +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/TypedLiteral.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/TypedLiteral.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/TypedLiteral.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/TypedLiteral.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + + +/** + * Typed literals have a lexical form and a data type URI being an RDF URI reference. + * + * To convert java objects to typed literals use {@link LiteralFactory} + * + * @author reto + * + */ +public interface TypedLiteral extends Literal { + + /** + * Returns the data type which is a UriRef. + * Note that the return value is not a node in the graph + * + * @return UriRef + */ + public UriRef getDataType(); + + /** + * Two TypedLiteral nodes are equal iff they have the same lexical form and + * the same data type + * + * @param obj + * @return true if <code>obj</code> is an instance of <code>TypedLiteral</code> + * for which the lexical form and the data type URI are equal to the ones + * of this instance, false otherwise + */ + public boolean equals(Object obj); + + /** + * The hash code is equal to the hash code of the lexical form + * plus the hash code of the dataType + * + * @return hash code + */ + public int hashCode(); +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/UriRef.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/UriRef.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/UriRef.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/UriRef.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf; + +import java.io.Serializable; + +/** + * Represents an RDF URI Reference + * + * RDF URI References are defined in section 6.4 RDF URI References of + * http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#section-Graph-URIref + * + * Note that an RDF URI Reference is not the same as defined by RFC3986, + * RDF URI References support most unicode characters + * + * @author reto + */ +public class UriRef implements NonLiteral, Serializable { + + private String unicodeString; + + public UriRef(String unicodeString) { + this.unicodeString = unicodeString; + } + + /** + * @return the unicode string that produces the URI + */ + public String getUnicodeString() { + return unicodeString; + } + + /** + * Returns true iff <code>obj</code> == <code>UriRef</code> + * + * @param obj + * @return true if obj is an instanceof UriRef with + * the same unicode-string, false otherwise + */ + @Override + public boolean equals(Object obj) { + + if (!(obj instanceof UriRef)) { + return false; + } + + return unicodeString.equals(((UriRef) obj).getUnicodeString()); + } + + /** + * @return 5 + the hashcode of the string + */ + @Override + public int hashCode() { + int hash = 5 + unicodeString.hashCode(); + return hash; + } + + @Override + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append('<'); + buffer.append(unicodeString); + buffer.append('>'); + return buffer.toString(); + } +} \ No newline at end of file Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/AddEvent.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/AddEvent.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/AddEvent.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/AddEvent.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf.event; + +import org.apache.commons.rdf.Triple; +import org.apache.commons.rdf.TripleCollection; + +/** + * This class represent a addition event that occured on a + * <code>TripleCollection</code>. + * + * @author rbn + */ +public class AddEvent extends GraphEvent { + + + public AddEvent(TripleCollection graph, Triple triple) { + super(graph, triple); + } + +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/FilterTriple.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/FilterTriple.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/FilterTriple.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/FilterTriple.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf.event; + +import org.apache.commons.rdf.NonLiteral; +import org.apache.commons.rdf.Resource; +import org.apache.commons.rdf.Triple; +import org.apache.commons.rdf.UriRef; + +/** + * The <code>FilterTriple</code> class provides a match()-method that tests + * if a <code>Triple</code> match a certain triple pattern. + * + * @author mir + */ +public class FilterTriple { + + private NonLiteral subject; + private UriRef predicate; + private Resource object; + + /** + * Creates a new <code>FilterTriple</code>. The specified subject, + * predicate and object are used to test a given <code>Triple</code>. Any + * of these values can be null, which acts as wildcard in the test. + * + * @param subject the subject. + * @param predicate the predicate. + * @param object the object. + */ + public FilterTriple (NonLiteral subject, UriRef predicate, Resource object) { + this.subject = subject; + this.predicate = predicate; + this.object = object; + } + + /** + * Returns true if the subject, predicate and object of the specified + * <code>Triple</code> match the subject, predicate and object of this + * <code>FilterTriple</code>. Null values in the <code>FilterTriple</code> + * act as wildcards. + * @param triple + * @return + */ + public boolean match(Triple triple) { + boolean subjectMatch, predicateMatch, objectMatch; + if (this.subject == null) { + subjectMatch = true; + } else { + subjectMatch = this.subject.equals(triple.getSubject()); + } + if (this.predicate == null) { + predicateMatch = true; + } else { + predicateMatch = this.predicate.equals(triple.getPredicate()); + } + if (this.object == null) { + objectMatch = true; + } else { + objectMatch = this.object.equals(triple.getObject()); + } + return subjectMatch && predicateMatch && objectMatch; + } + + @Override + public String toString() { + return "FilterTriples: "+subject+" "+predicate+" "+object; + } + +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/GraphEvent.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/GraphEvent.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/GraphEvent.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/GraphEvent.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf.event; + +import org.apache.commons.rdf.Triple; +import org.apache.commons.rdf.TripleCollection; + +/** + * This class represent a modification event that occured on a + * <code>TripleCollection</code>. A <code>GraphEvent</code> object keeps + * information about this event. These information are: The <code>Triple</code> + * that was part of the modification, the type of modification (addition or + * removal) and the <code>TripleCollection</code> that was modified. + * + * @author mir + */ +public class GraphEvent { + + private TripleCollection graph; + private Triple triple; + + protected GraphEvent(TripleCollection graph, Triple triple) { + this.graph = graph; + this.triple = triple; + } + + /** + * Returns the <code>TripleCollection</code> that was modified in the event. + * @return the graph + */ + public TripleCollection getGraph() { + return graph; + } + + + /** + * Return the <code>Triple</code> that was part of the modification. + * @return the triple + */ + public Triple getTriple() { + return triple; + } +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/GraphListener.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/GraphListener.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/GraphListener.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/GraphListener.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf.event; + +import java.util.List; + +/** + * A class that is interested in graph events implements this interface and + * is then added as listener to a <code>ListenableTripleCollection</code> or + * one of its subclasses. When the <code>ListenableTripleCollection</code> is + * modified, then the <code>GraphListener</code> is notified. + * + * @author mir + */ +public interface GraphListener { + + /** + * This method is called when a <code>ListenableTripleCollection</code> was + * modified, to which this <code>GraphListener</code> was added. A + * <code>List</code> containing <code>GraphEvent</code>s are passed as + * argument. The list contains all events in which a triple was part of + * the modification that matched the <code>FilterTriple</code> which was passed + * as argument when the listener was added. + * @param events + */ + public void graphChanged(List<GraphEvent> events); +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/RemoveEvent.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/RemoveEvent.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/RemoveEvent.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/event/RemoveEvent.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.rdf.event; + +import org.apache.commons.rdf.Triple; +import org.apache.commons.rdf.TripleCollection; + +/** + * This class represent a removal event that occured on a + * <code>TripleCollection</code>. + * + * @author rbn + */ +public class RemoveEvent extends GraphEvent { + + + public RemoveEvent(TripleCollection graph, Triple triple) { + super(graph, triple); + } + +} Added: commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/package-info.java URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/package-info.java?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/package-info.java (added) +++ commons/sandbox/rdf/trunk/src/main/java/org/apache/commons/rdf/package-info.java Wed Dec 17 20:18:21 2014 @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Common RDF API + */ +package org.apache.commons.rdf; \ No newline at end of file Added: commons/sandbox/rdf/trunk/src/site/custom/project-info-report.properties URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/site/custom/project-info-report.properties?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/site/custom/project-info-report.properties (added) +++ commons/sandbox/rdf/trunk/src/site/custom/project-info-report.properties Wed Dec 17 20:18:21 2014 @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Replace SCM report description in index page +report.scm.description=This document lists ways to access the online source repository. + +# Replace SCM report text for viewvc section +report.scm.webaccess.title=Browser (HTTP) Access +report.scm.webaccess.url=The following is a link to a browsable version of the source repository. \ +Please use the "Anonymous Access" or "Developer Access" URL if you want to check out the source using your SCM client. \ No newline at end of file Added: commons/sandbox/rdf/trunk/src/site/resources/download_net.cgi URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/site/resources/download_net.cgi?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/site/resources/download_net.cgi (added) +++ commons/sandbox/rdf/trunk/src/site/resources/download_net.cgi Wed Dec 17 20:18:21 2014 @@ -0,0 +1,4 @@ +#!/bin/sh +# Just call the standard mirrors.cgi script. It will use download.html +# as the input template. +exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $* \ No newline at end of file Added: commons/sandbox/rdf/trunk/src/site/resources/images/net-logo-white.png URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/site/resources/images/net-logo-white.png?rev=1646331&view=auto ============================================================================== Binary file - no diff available. Propchange: commons/sandbox/rdf/trunk/src/site/resources/images/net-logo-white.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: commons/sandbox/rdf/trunk/src/site/site.xml URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/site/site.xml?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/site/site.xml (added) +++ commons/sandbox/rdf/trunk/src/site/site.xml Wed Dec 17 20:18:21 2014 @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project name="Apache Commons Net"> + + <bannerRight> + <name>Apache Commons Net</name> + <src>/images/net-logo-white.png</src> + <href>/index.html</href> + <alt>Commons Net&trade; logo</alt> + </bannerRight> + + <body> + <menu name="Documentation"> + <item name="Overview" href="index.html"/> + </menu> + <menu name="Development"> + <item name="Coding Specifications" href="code-standards.html"/> + <item name="SVN repository" href="source-repository.html"/> + </menu> + + </body> + +</project> Added: commons/sandbox/rdf/trunk/src/site/xdoc/code-standards.xml URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/site/xdoc/code-standards.xml?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/site/xdoc/code-standards.xml (added) +++ commons/sandbox/rdf/trunk/src/site/xdoc/code-standards.xml Wed Dec 17 20:18:21 2014 @@ -0,0 +1,187 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<document> + + <properties> + <title>Coding Standards</title> + <author email="j...@latchkey.com">Jon S. Stevens</author> + <author email="jvan...@apache.org">Jason van Zyl</author> + </properties> + +<body> + +<section name="Coding Standards"> + +<p> +This document describes a list of coding conventions that are required +for code submissions to the project. By default, the coding conventions +for most Open Source Projects should follow the existing coding conventions +in the code that you are working on. For example, if the bracket is on +the same line as the if statement, then you should write all your code +to have that convention. +</p> + +<p> +<strong>If you commit code that does not follow these conventions, you +are responsible for also fixing your own code.</strong> +</p> + +<p> +Below is a list of coding conventions that are specific to Apache Commons Net +everything else not specificially mentioned here should follow the official +<a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">Sun +Java Coding Conventions</a>. +</p> + +<p> +1. Brackets should begin and end on a new line and should exist even +for one line statements. Examples: +</p> + +<source test=""><![CDATA[ +if ( foo ) +{ + // code here +} + +try +{ + // code here +} +catch (Exception bar) +{ + // code here +} +finally +{ + // code here +} + +while ( true ) +{ + // code here +} +]]></source> + +<p> +2. Though it's considered okay to include spaces inside parens, the +preference is to not include them. Both of the following are okay: +</p> + +<source test=""><![CDATA[ +if (foo) + +or + +if ( foo ) +]]></source> + +<p> +3. 4 space indent. <strong>NO tabs</strong>. Period. We understand +that many developers like to use tabs, but the fact of the matter is +that in a distributed development environment where diffs are sent to +the mailing lists by both developers and the version control system +(which sends commit log messages), the use tabs makes it impossible to +preserve legibility. +</p> + +<p> +In Emacs-speak, this translates to the following command: +</p> + +<source><![CDATA[ +(setq-default tab-width 4 indent-tabs-mode nil) +]]></source> + +<p> +4. Native linefeeds (svn:eol-style native) for all .java source code and text files. +Platform specific files should have the platform specific linefeeds. +</p> + +<p> +5. JavaDoc <strong>MUST</strong> exist on all public and protected methods. +JavaDoc on private and default access methods and members is preferred and +encouraged. If your code modifications use an existing class/method/variable +which lacks JavaDoc, it is required that you add it. This will improve the +project as a whole. +</p> + +<p> +6. The Apache License header <strong>MUST</strong> be placed at the top +of each and every file. +</p> + +<p> +9. Import statements must be fully qualified for clarity. +</p> + +<source><![CDATA[ +import java.util.ArrayList; +import java.util.Hashtable; + +import org.apache.foo.Bar; +import org.apache.bar.Foo; +]]></source> + +<p> +And not +</p> + +<source><![CDATA[ +import java.util.*; +import org.apache.foo.*; +import org.apache.bar.*; +]]></source> + +<hr noshade="true" size="1"/> + +<p> +X/Emacs users might appreciate this in their .emacs file. +</p> + +<source><![CDATA[ +(defun apache-jakarta-mode () + "The Java mode specialization for Apache Jakarta projects." + (if (not (assoc "apache-jakarta" c-style-alist)) + ;; Define the Apache Jakarta cc-mode style. + (c-add-style "apache-jakarta" '("java" (indent-tabs-mode . nil)))) + + (c-set-style "apache-jakarta") + (c-set-offset 'substatement-open 0 nil) + (setq mode-name "Apache Jakarta") + + ;; Turn on syntax highlighting when X is running. + (if (boundp 'window-system) + (progn (setq font-lock-support-mode 'lazy-lock-mode) + (font-lock-mode t)))) + +;; Activate Jakarta mode. +(if (fboundp 'jde-mode) + (add-hook 'jde-mode-hook 'apache-jakarta-mode) + (add-hook 'java-mode-hook 'apache-jakarta-mode)) +]]></source> + +<p> +Thanks for your cooperation. +</p> + +</section> + +</body> +</document> Added: commons/sandbox/rdf/trunk/src/site/xdoc/index.xml URL: http://svn.apache.org/viewvc/commons/sandbox/rdf/trunk/src/site/xdoc/index.xml?rev=1646331&view=auto ============================================================================== --- commons/sandbox/rdf/trunk/src/site/xdoc/index.xml (added) +++ commons/sandbox/rdf/trunk/src/site/xdoc/index.xml Wed Dec 17 20:18:21 2014 @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<document> + + <properties> + <title>Overview</title> + <author email="d...@commons.apache.org">Apache Commons Documentation Team</author> + </properties> + + <body> + + <section name="Apache Commons RDF"> + <p> + Apache Commons RDF provides an API modelling the RDF data model as defined by + http://www.w3.org/TR/rdf11-concepts/ + </p> + </section> + <section name="Features"> + <p> + This Library shall + <ul> + <li>Allow to access, modify nad monitor RDF data</li> + <li>Support all concepts defined by the RDF Abstract Syntax</li> + <li>Provide an easy to use API</li> + <li>Support both triple stores as well as the wrapping other sources</li> + <li>Allow to seamlessly use instances coming from different sources</li> + <li>Integrate well with existing Java APIs</li> + </ul> + </p> + </section> + +</document> +