org.universAAL.middleware.rdf
Class PropertyPath

Package class diagram package PropertyPath
java.lang.Object
  extended by org.universAAL.middleware.rdf.Resource
      extended by org.universAAL.middleware.rdf.FinalizedResource
          extended by org.universAAL.middleware.rdf.PropertyPath

public final class PropertyPath
extends FinalizedResource

A PropertyPath is a closed list of property URIs that relates a resource to a set of other resources or literal values as it could be reached by conventional join operations over an RDF database. The following example should help to understand this concept better: Assuming that an RDF database contains the following triples:

(a p1 b)
(a p1 c)
(b p2 d)
(c p2 e)
(c p2 f)
(d p3 g)
(d p3 h)
(e p3 i)
(f p3 j)
(f p3 k)

Then the following relations can be deduced using the property path {p1, p2, p3}:

(a {p1, p2, p3} g)
(a {p1, p2, p3} h)
(a {p1, p2, p3} i)
(a {p1, p2, p3} j)
(a {p1, p2, p3} k)
.

As the type hierarchy of PropertyPath plays no specific role in ontological reasoning, it is not defined as subclass of ManagedIndividual but just as a Resource.

Author:
mtazari, Carsten Stockloew

Field Summary
static String PROP_PROPERTY_PATH
          The only property of a property path is the one pointing to the list of properties that build up the path.
static String TYPE_PROPERTY_PATH
          URI of this class.
 
Fields inherited from class org.universAAL.middleware.rdf.Resource
ANON_URI_PREFIX, blockAddingTypes, isXMLLiteral, ns_delim_index, PROP_RDF_FIRST, PROP_RDF_REST, PROP_RDF_TYPE, PROP_RDFS_COMMENT, PROP_RDFS_LABEL, PROP_SERIALIZATION_FULL, PROP_SERIALIZATION_OPTIONAL, PROP_SERIALIZATION_REDUCED, PROP_SERIALIZATION_UNDEFINED, PROP_uAAL_INVOLVED_HUMAN_USER, props, RDF_EMPTY_LIST, RDF_NAMESPACE, RDFS_NAMESPACE, TYPE_RDF_LIST, TYPE_RDFS_CLASS, uAAL_NAMESPACE_PREFIX, uAAL_SERVICE_NAMESPACE, uAAL_VOCABULARY_NAMESPACE, uri
 
Constructor Summary
PropertyPath()
          The constructor for (de-)serializers.
PropertyPath(boolean isXMLLiteral)
          The constructor for property paths which may be XML Literals.
PropertyPath(String uri)
          The constructor for property paths with a specified URI.
PropertyPath(String uri, boolean isXMLLiteral)
          The constructor for property paths which may be XML Literals and with a specified URI.
PropertyPath(String uri, boolean isXMLLiteral, String[] thePath)
          The constructor for property paths.
 
Method Summary
 boolean equals(Object other)
          Determines if the property path of this object equals the property path of another object.
 String getFirstPathElement()
          Get the first element of the path.
 String getLastPathElement()
          Get the last element of the path.
static String[] getSubpath(String[] path, int i)
          Get a property path that is a part of the specified property path.
 String[] getThePath()
          Get the path in form of a String array.
 boolean isClosedCollection(String propURI)
          Returns true if the value of the given property should be treated as an rdf:List.
static boolean pathHasPrefix(String[] path, String[] prefix)
          Determines if the specified property path has as prefix a specified set of properties.
 boolean setProperty(String propURI, Object o)
          Adds a statement with this resource as the subject, the given propURI as the predicate and the given value as the object.
 void setThePath(String[] propPath)
          Set the path for this object.
 PropertyPath toLiteral()
          Creates a new PropertyPath and copies the property containing the property path to it.
static PropertyPath toPropertyPath(Resource pr)
          Takes a Resource and creates an instance of PropertyPath.
 void unliteral()
          Make this object not being an XMLLiteral
 
Methods inherited from class org.universAAL.middleware.rdf.FinalizedResource
addType, getLocalName, getNamespace, getProperty, getPropertyURIs, getType, getTypes, getURI, hasQualifiedName, isAnon, numberOfProperties
 
Methods inherited from class org.universAAL.middleware.rdf.Resource
addMultiLangProp, asList, asList, asRDFList, changeProperty, copy, deepCopy, generateAnonURI, getDefaultLang, getFilename, getMultiLangProp, getOrConstructLabel, getPropSerializationType, getResource, getResourceComment, getResourceLabel, getStaticFieldValue, hashCode, hasProperty, isAnon, isBlockingAddingTypes, isQualifiedName, isWellFormed, literal, representsQualifiedURI, serializesAsXMLLiteral, setPropertyPath, setPropertyPath, setPropertyPathFromOffset, setResourceComment, setResourceLabel, toString, toStringRecursive, toStringRecursive
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_PROPERTY_PATH

public static final String PROP_PROPERTY_PATH
The only property of a property path is the one pointing to the list of properties that build up the path.

See Also:
Constant Field Values

TYPE_PROPERTY_PATH

public static final String TYPE_PROPERTY_PATH
URI of this class.

See Also:
Constant Field Values
Constructor Detail

PropertyPath

public PropertyPath()
The constructor for (de-)serializers.


PropertyPath

public PropertyPath(String uri)
The constructor for property paths with a specified URI.


PropertyPath

public PropertyPath(boolean isXMLLiteral)
The constructor for property paths which may be XML Literals. The URI of this object is automatically generated.


PropertyPath

public PropertyPath(String uri,
                    boolean isXMLLiteral)
The constructor for property paths which may be XML Literals and with a specified URI.


PropertyPath

public PropertyPath(String uri,
                    boolean isXMLLiteral,
                    String[] thePath)
The constructor for property paths.

Parameters:
uri - URI of this object.
isXMLLiteral - True, if this object is an XML Literal.
thePath - The initial property path.
Method Detail

getSubpath

public static String[] getSubpath(String[] path,
                                  int i)
Get a property path that is a part of the specified property path.

Parameters:
path - The property path from which to extract the sub path.
i - The resulting sub path contains all elements from the specified path from position 'i' to the end.
Returns:
The sub path.

pathHasPrefix

public static boolean pathHasPrefix(String[] path,
                                    String[] prefix)
Determines if the specified property path has as prefix a specified set of properties.


toPropertyPath

public static PropertyPath toPropertyPath(Resource pr)
Takes a Resource and creates an instance of PropertyPath. The content is copied to the newly created object.


equals

public boolean equals(Object other)
Determines if the property path of this object equals the property path of another object. The set of properties is compared piece-wise.

Overrides:
equals in class Resource

getFirstPathElement

public String getFirstPathElement()
Get the first element of the path.


getLastPathElement

public String getLastPathElement()
Get the last element of the path.


getThePath

public String[] getThePath()
Get the path in form of a String array.


isClosedCollection

public boolean isClosedCollection(String propURI)
Description copied from class: Resource
Returns true if the value of the given property should be treated as an rdf:List. Serializers can use this to determine if a multi-valued property should be serialized using the concept of rdf:List or the property should appear as often as the number of values assigned to the property. The default behavior is that a property associated with an instance of List is assumed to be a closed collection (unless it is specifically an instance of OpenCollection). Subclasses can change this, if needed.

Overrides:
isClosedCollection in class Resource
See Also:
Resource.isClosedCollection(String)

setProperty

public boolean setProperty(String propURI,
                           Object o)
Description copied from class: Resource
Adds a statement with this resource as the subject, the given propURI as the predicate and the given value as the object. Subclasses must override this in order to decide if the statement to be added fits the general class constraints. If not, the call of this method should be ignored. For each property only one single call may be made to this method, unless subsequent calls to this method for setting the value of the same property are treated as an update for an update-able property. Multi-valued properties must be set using an instance of List. The differentiation, if a such list should be treated as an rdf:List, can be made with the help of Resource.isClosedCollection(String). The default implementation here accepts all property-value pairs blindly except for rdf:type which is handled if the value is a type URI, a Resource or a java.util.List of them.

Note: The setting of the property rdf:type is being handled by this class via the final methods Resource.addType(String, boolean), Resource.getType(), and Resource.getTypes(). Although these methods give the view of handling type URIs as strings, but in reality the types are stored as direct instances of this class. So, the subclasses should ignore calls for setting rdf:type; if not, then the subclass must pay attention that the value should be a List of direct instances of this class so that (1) the Resource.toString() method returns just the URI and (2) the serializers get no problems with the value. Also, settings via subclasses may be overwritten by this class if a subsequent call to Resource.addType(String, boolean) is made.

Overrides:
setProperty in class Resource
Returns:
true if the property changed as a result of the call
See Also:
Resource.setProperty(java.lang.String, java.lang.Object)

setThePath

public void setThePath(String[] propPath)
Set the path for this object. Each element of the specified set has to be a URI and has to be a qualified name.

Parameters:
propPath - The set of URIs.
See Also:
Resource.isQualifiedName(java.lang.String)

toLiteral

public PropertyPath toLiteral()
Creates a new PropertyPath and copies the property containing the property path to it. The newly created PropertyPath is marked as XML Literal.

Returns:
A new PropertyPath with the contents of the property PROP_PROPERTY_PATH copied.

unliteral

public void unliteral()
Make this object not being an XMLLiteral

Overrides:
unliteral in class Resource


Copyright © 2014 universAAL Consortium. All Rights Reserved.