|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.universAAL.middleware.rdf.Resource
org.universAAL.middleware.rdf.UnmodifiableResource
public final class UnmodifiableResource
A Resource that can not be modified.
Field Summary |
---|
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 | |
---|---|
UnmodifiableResource(Resource r)
|
Method Summary | |
---|---|
boolean |
addType(String typeURI,
boolean blockFurtherTypes)
Set or add the type of this Resource. |
List |
asList()
If this Resource represents an RDF List, retrieve the elements as List . |
void |
asList(List l)
If this Resource represents an RDF List, retrieve the elements as List . |
boolean |
changeProperty(String propURI,
Object value)
Change the value (RDF object) of the specified property (RDF predicate) to the given object. |
Resource |
copy(boolean isXMLLitera)
Create a copy of this resource. |
Resource |
deepCopy()
Create a deep copy of this Resource, i.e. create a new Resource for this object and for the resources of all properties. |
boolean |
equals(Object other)
Determines if this Resource equals the specified Resource. |
Class |
getClassOfUnmodifiable()
|
String |
getLocalName()
Get the local name which is the part of the URI after the delimiter ('#'). |
String |
getNamespace()
Get the namespace of the URI which is the start of the URI including the delimiter ('#'). |
String |
getOrConstructLabel(String type)
If this resource has no original label, constructs one for it without changing the resource itself. |
Object |
getProperty(String propURI)
Get the RDF object for a specified property. |
Enumeration |
getPropertyURIs()
Get all properties, i.e. all RDF predicates for this Resource. |
int |
getPropSerializationType(String propURI)
Answers if the given property has to be considered when serializing this individual in a minimized way, and if not ignore-able, whether its value should be presented in its full form or can be reduced. |
String |
getResourceComment()
Get the Resource comment. |
String |
getResourceLabel()
Get the Resource label. |
Object |
getStaticFieldValue(String fieldName,
Object defaultValue)
Helper method to get the static field of the java class with the given field name. |
String |
getType()
Returns the URI of the first type added to the list of types of this resource. |
String[] |
getTypes()
Returns the URIs of all known types of this resource. |
static Object |
getUnmodifiable(Object o)
Get an unmodifiable version of the given object. |
String |
getURI()
Get the URI. |
int |
hashCode()
Get the hash code for this Resource, calculated from the URI. |
boolean |
hasProperty(String propURI)
Determines if this Resource has the specified property. |
boolean |
hasQualifiedName()
Determines if this Resource has a qualified, i.e. the URI has a delimiter ('#'). |
boolean |
instanceOf(Class c)
|
boolean |
isAnon()
Determines if this Resource has an anonymous URI. |
boolean |
isClosedCollection(String propURI)
Returns true if the value of the given property should be treated as an rdf:List. |
boolean |
isWellFormed()
Returns true, if the state of the resource is valid, otherwise false. |
int |
numberOfProperties()
Returns the number of properties, i.e. the number of RDF predicates for this Resource. |
boolean |
representsQualifiedURI()
|
boolean |
serializesAsXMLLiteral()
Resources to be serialized and parsed as rdf:XMLLiteral must overwrite this method and return true. |
boolean |
setProperty(String propURI,
Object value)
Adds a statement with this resource as the subject, the given propURI as the predicate and the given value as the object. |
boolean |
setPropertyPath(String[] propPath,
Object value)
Set the given value at the end of the given property path, but does not force the setting. |
boolean |
setPropertyPath(String[] propPath,
Object value,
boolean force)
Set the given value at the end of the given property path. |
boolean |
setPropertyPathFromOffset(String[] propPath,
int fromIndex,
Object value,
boolean force)
Change or add the Resource at the end of the given property path to the given value. |
void |
setResourceComment(String comment)
Set the Resource comment. |
void |
setResourceLabel(String label)
Set the Resource label. |
String |
toString()
Get a String representation of this Resource; returns the URI. |
String |
toStringRecursive()
Debug method: get a string of this RDF graph. |
String |
toStringRecursive(String prefix,
boolean prefixAtStart,
Hashtable visitedElements)
Debug method: get a string of this RDF graph. |
Methods inherited from class org.universAAL.middleware.rdf.Resource |
---|
addMultiLangProp, asRDFList, generateAnonURI, getDefaultLang, getFilename, getMultiLangProp, getResource, isAnon, isBlockingAddingTypes, isQualifiedName, literal, unliteral |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UnmodifiableResource(Resource r)
Method Detail |
---|
public static Object getUnmodifiable(Object o)
Resource
, an UnmodifiableResource
is returned. If the
parameter is a List
, an
UnmodifiableResourceList
is returned.
o
- The object for which an unmodifiable version should be
returned.
public boolean changeProperty(String propURI, Object value)
Resource
changeProperty
in class Resource
propURI
- The value has to be changed for this property.value
- The new value.
Resource.changeProperty(String, Object)
public final Object getProperty(String propURI)
Resource
getProperty
in class Resource
propURI
- URI of the property.
Resource.getProperty(String)
public boolean setProperty(String propURI, Object value)
Resource
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.
setProperty
in class Resource
Resource.setProperty(String, Object)
public boolean setPropertyPath(String[] propPath, Object value, boolean force)
Resource
setPropertyPath
in class Resource
Resource.setPropertyPath(String[],
Object, boolean)
public boolean setPropertyPath(String[] propPath, Object value)
Resource
setPropertyPath
in class Resource
Resource.setPropertyPath(String[],
Object)
public boolean setPropertyPathFromOffset(String[] propPath, int fromIndex, Object value, boolean force)
Resource
setPropertyPathFromOffset
in class Resource
propPath
- The set of properties defining the path through the RDF graph.fromIndex
- The property path is evaluated from this index on; if
'fromIndex' is greater than zero, then some entries at the
beginning are just ignored.value
- The value to set at the end of the property pathforce
- Determines if setting the value has to be forced. If true,
Resource.changeProperty(String, Object)
is called, otherwise
Resource.setProperty(String, Object)
is called.
Resource.setPropertyPathFromOffset(String[],
int, Object, boolean)
public List asList()
Resource
List
.
asList
in class Resource
public void asList(List l)
Resource
List
.
asList
in class Resource
l
- The list to store the elements of this RDF list.public Resource copy(boolean isXMLLitera)
Resource
Resource.deepCopy()
.
copy
in class Resource
Resource
, not a subclass of it (Note: future versions may
change this and return a specialized copy).#copyAsNonXMLLiteral()
public Resource deepCopy()
Resource
deepCopy
in class Resource
public boolean equals(Object other)
Resource
equals
in class Resource
public String getOrConstructLabel(String type)
Resource
getOrConstructLabel
in class Resource
type
- The optional type to be used instead of the return value of
'getType()' when constructing a label
public int getPropSerializationType(String propURI)
Resource
Resource.PROP_SERIALIZATION_OPTIONAL
,
Resource.PROP_SERIALIZATION_REDUCED
, or Resource.PROP_SERIALIZATION_FULL
.
It can be assumed that the given property is one of those returned by
Resource.getPropertyURIs()
. PROP_SERIALIZATION_OPTIONAL
in
favor of lower communication traffic and higher performance even at risk
of a possible additional query on the receiver side for fetching this
info. With the same rationale, if a property should be included in the
process of serialization, it is preferable to include it in a reduced
form; in this case the return value should be
PROP_SERIALIZATION_REDUCED
, otherwise
PROP_SERIALIZATION_FULL
can be returned.
Subclasses should normally overwrite this method as this default
implementation returns always PROP_SERIALIZATION_FULL
.
getPropSerializationType
in class Resource
public String getResourceComment()
Resource
getResourceComment
in class Resource
public String getResourceLabel()
Resource
getResourceLabel
in class Resource
public Object getStaticFieldValue(String fieldName, Object defaultValue)
Resource
getStaticFieldValue
in class Resource
fieldName
- Name of the static field of the java class to retrieve.defaultValue
- Default value, if the field could not be retrieved.
public int hashCode()
Resource
hashCode
in class Resource
public boolean hasProperty(String propURI)
Resource
hasProperty
in class Resource
public boolean isClosedCollection(String propURI)
Resource
List
is assumed to be a closed collection
(unless it is specifically an instance of OpenCollection
).
Subclasses can change this, if needed.
isClosedCollection
in class Resource
public boolean isWellFormed()
Resource
Subclasses should overwrite this methods as the default implementation returns always true.
isWellFormed
in class Resource
public boolean representsQualifiedURI()
representsQualifiedURI
in class Resource
public boolean serializesAsXMLLiteral()
Resource
serializesAsXMLLiteral
in class Resource
public void setResourceComment(String comment)
Resource
setResourceComment
in class Resource
public void setResourceLabel(String label)
Resource
setResourceLabel
in class Resource
public String toString()
Resource
toString
in class Resource
public String toStringRecursive()
Resource
toStringRecursive
in class Resource
public String toStringRecursive(String prefix, boolean prefixAtStart, Hashtable visitedElements)
Resource
toStringRecursive
in class Resource
prefix
- Indention string that every line starts with.prefixAtStart
- True iff the first line should start with the prefix string.
public int numberOfProperties()
Resource
numberOfProperties
in class Resource
public boolean isAnon()
Resource
isAnon
in class Resource
Resource.isAnon()
public final boolean hasQualifiedName()
Resource
hasQualifiedName
in class Resource
Resource.hasQualifiedName()
public final String getURI()
Resource
getURI
in class Resource
Resource.getURI()
public final Enumeration getPropertyURIs()
Resource
getPropertyURIs
in class Resource
Resource.getPropertyURIs()
public final boolean addType(String typeURI, boolean blockFurtherTypes)
Resource
addType
in class Resource
typeURI
- URI of the type.blockFurtherTypes
- If true, no further types can be added.Resource.addType(String, boolean)
public final String getLocalName()
Resource
getLocalName
in class Resource
Resource.getLocalName()
public final String getNamespace()
Resource
getNamespace
in class Resource
Resource.getNamespace()
public final String getType()
Resource
getType
in class Resource
Resource.getType()
public final String[] getTypes()
Resource
getTypes
in class Resource
Resource.getTypes()
public final Class getClassOfUnmodifiable()
public final boolean instanceOf(Class c)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |