public final class UnmodifiableResource extends Resource
ANON_URI_PREFIX, blockAddingTypes, isXMLLiteral, NAMESPACE_PREFIX, ns_delim_index, PROP_INVOLVED_HUMAN_USER, 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, props, RDF_EMPTY_LIST, RDF_NAMESPACE, RDFS_NAMESPACE, SERVICE_NAMESPACE, TYPE_RDF_LIST, TYPE_RDFS_CLASS, uri, VOCABULARY_NAMESPACE
Constructor and Description |
---|
UnmodifiableResource(Resource r) |
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
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.
|
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.
|
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.
|
addMultiLangProp, asRDFList, generateAnonURI, getDefaultLang, getFilename, getMultiLangProp, getOrConstructLabel, getResource, getResourceLabel, isAnon, isBlockingAddingTypes, isQualifiedName, literal, unliteral
public UnmodifiableResource(Resource r)
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.public Object getProperty(String propURI)
Resource
getProperty
in class Resource
propURI
- URI of the property.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
public boolean setPropertyPath(String[] propPath, Object value, boolean force)
Resource
setPropertyPath
in class Resource
Resource.setPropertyPathFromOffset(String[], int, Object, boolean)
public boolean setPropertyPath(String[] propPath, Object value)
Resource
setPropertyPath
in class Resource
Resource.setPropertyPathFromOffset(String[], int, Object, boolean)
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.public List asList()
Resource
List
.public void asList(List l)
Resource
List
.public Resource copy(boolean isXMLLitera)
Resource
Resource.deepCopy()
.public Resource deepCopy()
Resource
public boolean equals(Object other)
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 labelpublic 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
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
comment
- the comment.public void setResourceLabel(String label)
Resource
setResourceLabel
in class Resource
label
- the label.public String toString()
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
public boolean hasQualifiedName()
Resource
hasQualifiedName
in class Resource
public Enumeration getPropertyURIs()
Resource
getPropertyURIs
in class Resource
public boolean addType(String typeURI, boolean blockFurtherTypes)
Resource
public String getLocalName()
Resource
getLocalName
in class Resource
Resource.getNamespace()
,
Resource.getFilename()
public String getNamespace()
Resource
getNamespace
in class Resource
Resource.getLocalName()
,
Resource.getFilename()
public String getType()
Resource
public String[] getTypes()
Resource
public Class getClassOfUnmodifiable()
public boolean instanceOf(Class c)
Copyright © 2018 universAAL Consortium. All rights reserved.