public abstract class RdfModelObject extends Object implements IRdfModel, Cloneable
RdfModelObject.createModelObject(ModelContainer container, Node node)
where the node contains the property values for the class. The subclass
implementations should implement the population of the Java properties from the
model. From that point forward, using standard getters and setters will keep
the Jena model updated along with the Java properties.
- If creating a new object use the constructor and pass in the initial property
values or use setters to set the property values. To populate the Jena model,
invoke the method Resource createResource(IModelContainer modelContainer).
This create a new resource in the model and populate the Jena model from the
Java properties. Once this method has been invoked, all subsequent calls to
setters will update both the Java properties and the Jena RDF property values.
To implement a new RdfModelObject subclass, the following methods must be implemented:
- Clone: All concrete classes must implement a clone method which will copy the
Java values but not copy the model data. The clone method can be used to duplicate
an RdfModelObject in a different Jena model.
- getType: Return the RDF Resource that describes RDF class associated with the Java class
- getUri: Returns a URI string for RDF resoures where an absolute URI is required. If null, an anonymous node is created.
- populateModel: Populates the RDF model from the Java properties
- equivalent: Returns true if the parameter has the same property values
- A constructor of the form O(Type1 p1, Type2 p2, ...) where p1, p2, ... are Java properties to initialize the Java object.
- A constructor of the form O(ModelContainer modelContainer, Node node)
This class implements several common and helper methods including
methods to find and set resources to the model. The methods to set a resource
are named setPropertyValue while the methods to find a
resource value is named findTypePropertyValue where where Type
is the type of Java object to be found. If no property value is found, null is returned.| Modifier and Type | Field and Description |
|---|---|
protected org.apache.jena.rdf.model.Model |
model |
protected IModelContainer |
modelContainer |
protected org.apache.jena.graph.Node |
node |
protected boolean |
refreshOnGet
Force a refresh for the model on every property get.
|
protected org.apache.jena.rdf.model.Resource |
resource |
| Constructor and Description |
|---|
RdfModelObject()
Create an Rdf Model Object without any associated nodes.
|
RdfModelObject(IModelContainer modelContainer,
org.apache.jena.graph.Node node)
Create an RDF Model Object based on an existing Node
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addPropertyUriValue(String nameSpace,
String propertyName,
String uri)
Adds a property value as a list of Uris
|
protected void |
addPropertyValue(String nameSpace,
String propertyName,
Annotation annotation) |
void |
addPropertyValue(String nameSpace,
String propertyName,
AnyLicenseInfo license)
Add a property value of type AnyLicenseInfo without removing the existing property values
|
protected void |
addPropertyValue(String nameSpace,
String propertyName,
Checksum checksumValue)
Add a checksum as a property to this resource
|
protected void |
addPropertyValue(String nameSpace,
String propertyName,
ExternalRef externalRef) |
protected void |
addPropertyValue(String nameSpace,
String propertyName,
Relationship relationship)
Add a relationship property value
|
protected void |
addPropertyValue(String nameSpace,
String propertyName,
SpdxElement element)
Adds an SPDX element property value for this resource without removing the old property values
|
protected void |
addPropertyValue(String nameSpace,
String propertyName,
SpdxElement element,
boolean updateModel)
Adds an SPDX element property value for this resource without removing the old property values
|
boolean |
arraysEquivalent(IRdfModel[] array1,
IRdfModel[] array2)
Compares 2 arrays to see if the property values for the element RdfModelObjects are the same independent of
order and considering nulls
|
org.apache.jena.rdf.model.Resource |
createResource(IModelContainer modelContainer)
Create a resource from the Java model object
|
org.apache.jena.rdf.model.Resource |
createResource(IModelContainer modelContainer,
boolean updateModel) |
boolean |
equals(Object o) |
boolean |
equivalentConsideringNull(IRdfModel o1,
IRdfModel o2)
Compares the properties of two RdfModelObjects considering possible null values
|
protected Annotation[] |
findAnnotationPropertyValues(String nameSpace,
String propertyName)
Find all annotations with a subject of this object
|
AnyLicenseInfo |
findAnyLicenseInfoPropertyValue(String namespace,
String propertyName)
Find a property value with a subject of this object
|
AnyLicenseInfo[] |
findAnyLicenseInfoPropertyValues(String namespace,
String propertyName)
Find a property value with a subject of this object
|
protected Checksum |
findChecksumPropertyValue(String nameSpace,
String propertyName) |
protected SPDXCreatorInformation |
findCreationInfoPropertyValue(String nameSpace,
String propertyName) |
org.apache.jena.rdf.model.Resource |
findDuplicateResource(IModelContainer modelContainer,
String uri)
Search the model to see if there is a duplicate resource either based on the
URI or based on other information.
|
protected SpdxElement |
findElementPropertyValue(String namespace,
String propertyName)
Find an SPDX element with a subject of this object
|
ExternalDocumentRef[] |
findExternalDocRefPropertyValues(String nameSpace,
String propertyName) |
static ExternalDocumentRef[] |
findExternalDocRefPropertyValues(String nameSpace,
String propertyName,
IModelContainer extDocModelContainer,
org.apache.jena.graph.Node nodeContainingExternalRefs) |
protected ExternalRef[] |
findExternalRefPropertyValues(String nameSpace,
String propertyName) |
Integer |
findIntPropertyValue(String namespace,
String propertyName)
Find an integer property value with a subject of this object
|
protected Checksum[] |
findMultipleChecksumPropertyValues(String nameSpace,
String propertyName) |
protected DoapProject[] |
findMultipleDoapPropertyValues(String nameSpace,
String propertyName) |
protected SpdxElement[] |
findMultipleElementPropertyValues(String namespace,
String propertyName)
Finds all SPDX elements with a subject of this object
|
String[] |
findMultiplePropertyValues(String namespace,
String propertyName)
Finds multiple property values with a subject of this object
|
protected ReferenceType |
findReferenceTypePropertyValue(String nameSpace,
String propertyName)
Find the reference type within a specific property in the model for this node
|
protected Relationship[] |
findRelationshipPropertyValues(String nameSpace,
String propertyName)
Find all annotations with a subject of this object
|
protected SPDXReview[] |
findReviewPropertyValues(String nameSpace,
String propertyName) |
protected SinglePointer |
findSinglePointerPropertyValue(String nameSpace,
String propertyName) |
String |
findSinglePropertyValue(String namespace,
String propertyName)
Find a property value with a subject of this object
|
protected StartEndPointer[] |
findStartEndPointerPropertyValues(String nameSpace,
String propertyName)
Find all StartEndPointers assocated with a property
|
protected String |
findUriPropertyValue(String namespace,
String propertyName)
Find a single URI as a property value to this node
|
protected String[] |
findUriPropertyValues(String namespace,
String propertyName)
Find a single URI as a property value to this node
|
protected SpdxPackageVerificationCode |
findVerificationCodePropertyValue(String nameSpace,
String propertyName) |
org.apache.jena.graph.Node |
getNode() |
abstract void |
getPropertiesFromModel()
Fetch all of the properties from the model and populate the local Java properties
|
abstract org.apache.jena.rdf.model.Resource |
getType(org.apache.jena.rdf.model.Model model) |
abstract String |
getUri(IModelContainer modelContainer)
Get the URI for this RDF object.
|
int |
hashCode() |
boolean |
isRefreshOnGet() |
abstract void |
populateModel()
Populate the RDF model from the Java properties
|
protected void |
removePropertyValue(String nameSpace,
String propertyName)
Removes all property values for this resource.
|
protected boolean |
resourcesEqual(org.apache.jena.rdf.model.Resource r1,
org.apache.jena.rdf.model.Resource r2)
Returns true if the two resources represent the same node
|
void |
setMultipleObjectsForSameNode()
Called to signal that there are multiple objects representing the same node
|
protected void |
setPropertyUriValue(String nameSpace,
String propertyName,
String uri)
Sets a property value as a Uri
|
protected void |
setPropertyUriValues(String nameSpace,
String propertyName,
String[] uris)
Sets a property value as a list of Uris
|
protected void |
setPropertyValue(String nameSpace,
String propertyName,
AnyLicenseInfo license)
Set a property value for this resource.
|
protected void |
setPropertyValue(String nameSpace,
String propertyName,
boolean value)
Set a property values for this resource.
|
protected void |
setPropertyValue(String nameSpace,
String propertyName,
Checksum checksumValue) |
protected void |
setPropertyValue(String nameSpace,
String propertyName,
DoapProject[] doapProjectValues) |
protected void |
setPropertyValue(String nameSpace,
String propertyName,
ExternalRef[] externalRefs)
Set the external refs as a value for the property
|
protected void |
setPropertyValue(String nameSpace,
String propertyName,
Integer value)
Set a property value for this resource.
|
protected void |
setPropertyValue(String nameSpace,
String propertyName,
ReferenceType referenceType) |
protected void |
setPropertyValue(String nameSpace,
String propertyName,
SinglePointer singlePointer) |
protected void |
setPropertyValue(String nameSpace,
String propertyName,
SPDXCreatorInformation creatorInfo) |
protected void |
setPropertyValue(String nameSpace,
String propertyName,
SpdxElement element) |
protected void |
setPropertyValue(String nameSpace,
String propertyName,
SpdxElement[] element) |
protected void |
setPropertyValue(String nameSpace,
String propertyName,
SpdxElement[] elements,
boolean updateModel)
Sets the spdx element property value for this resource
|
protected void |
setPropertyValue(String nameSpace,
String propertyName,
SpdxElement element,
boolean updateModel)
Sets the spdx element property value for this resource
|
protected void |
setPropertyValue(String nameSpace,
String propertyName,
SpdxPackageVerificationCode verificationCode) |
protected void |
setPropertyValue(String nameSpace,
String propertyName,
StartEndPointer[] values)
Set a property value for this resource.
|
protected void |
setPropertyValue(String nameSpace,
String propertyName,
String value)
Set a property value for this resource.
|
protected void |
setPropertyValue(String nameSpace,
String propertyName,
String[] values)
Set a property values for this resource.
|
protected void |
setPropertyValues(String nameSpace,
String propertyName,
Annotation[] annotations) |
void |
setPropertyValues(String nameSpace,
String propertyName,
AnyLicenseInfo[] licenses)
Set a property value for this resource.
|
protected void |
setPropertyValues(String nameSpace,
String propertyName,
Checksum[] checksumValues) |
void |
setPropertyValues(String nameSpace,
String propertyName,
ExternalDocumentRef[] externalDocRefs) |
protected void |
setPropertyValues(String nameSpace,
String propertyName,
Relationship[] relationships)
Set a property value for this resource.
|
protected void |
setPropertyValues(String nameSpace,
String propertyName,
SPDXReview[] reviewers) |
void |
setSingleObjectForSameNode()
Called to signal that a newly created resource is only used for a single node
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitequivalent, verifyprotected org.apache.jena.rdf.model.Model model
protected org.apache.jena.rdf.model.Resource resource
protected org.apache.jena.graph.Node node
protected IModelContainer modelContainer
protected boolean refreshOnGet
public RdfModelObject(IModelContainer modelContainer, org.apache.jena.graph.Node node) throws InvalidSPDXAnalysisException
modelContainer - Container containing the RDF Modelnode - Node describing this objectInvalidSPDXAnalysisExceptionpublic RdfModelObject()
public org.apache.jena.rdf.model.Resource createResource(IModelContainer modelContainer) throws InvalidSPDXAnalysisException
IRdfModelcreateResource in interface IRdfModelmodelContainer - Contains the Jena model where to create the resourceInvalidSPDXAnalysisExceptionpublic org.apache.jena.rdf.model.Resource createResource(IModelContainer modelContainer, boolean updateModel) throws InvalidSPDXAnalysisException
modelContainer - updateModel - If true, update the model from the element. If false, update the
element from the model. This is used for relationships to make sure we don't overwrite
the original element when setting the related element property value.InvalidSPDXAnalysisExceptionpublic abstract void getPropertiesFromModel()
throws InvalidSPDXAnalysisException
InvalidSPDXAnalysisExceptionpublic org.apache.jena.rdf.model.Resource findDuplicateResource(IModelContainer modelContainer, String uri) throws InvalidSPDXAnalysisException
modelContainer - uri - InvalidSPDXAnalysisExceptionpublic abstract String getUri(IModelContainer modelContainer) throws InvalidSPDXAnalysisException
modelContainer - InvalidSPDXAnalysisExceptionpublic abstract org.apache.jena.rdf.model.Resource getType(org.apache.jena.rdf.model.Model model)
public abstract void populateModel()
throws InvalidSPDXAnalysisException
InvalidSPDXAnalysisExceptionprotected boolean resourcesEqual(org.apache.jena.rdf.model.Resource r1,
org.apache.jena.rdf.model.Resource r2)
r1 - r2 - protected SpdxElement[] findMultipleElementPropertyValues(String namespace, String propertyName) throws InvalidSPDXAnalysisException
namespace - propertyName - InvalidSPDXAnalysisExceptionprotected SpdxElement findElementPropertyValue(String namespace, String propertyName) throws InvalidSPDXAnalysisException
namespace - propertyName - InvalidSPDXAnalysisExceptionpublic String findSinglePropertyValue(String namespace, String propertyName)
namespace - Namespace for the property namepropertyName - Name of the propertypublic Integer findIntPropertyValue(String namespace, String propertyName)
namespace - Namespace for the property namepropertyName - Name of the propertyprotected void setPropertyValue(String nameSpace, String propertyName, Integer value)
nameSpace - RDF Namespace for the propertypropertyName - RDF Property Name (the RDFvalue - Integer value to associate to this resourcepublic String[] findMultiplePropertyValues(String namespace, String propertyName)
namespace - Namespace for the property namepropertyName - Name of the propertyprotected void setPropertyValue(String nameSpace, String propertyName, String[] values)
nameSpace - RDF Namespace for the propertypropertyName - RDF Property Name (the RDFvalues - Values to associate to this resourceprotected void setPropertyValue(String nameSpace, String propertyName, boolean value)
nameSpace - RDF Namespace for the propertypropertyName - RDF Property Namevalue - boolean value to setprotected void setPropertyValue(String nameSpace, String propertyName, SpdxElement[] elements, boolean updateModel) throws InvalidSPDXAnalysisException
nameSpace - propertyName - element - updateModel - If true, update the model from the element. If false, update the
element from the model. This is used for relationships to make sure we don't overwrite
the original element when setting the related element property value.InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, SpdxElement element, boolean updateModel) throws InvalidSPDXAnalysisException
nameSpace - propertyName - element - updateModel - If true, update the model from the element. If false, update the
element from the model. This is used for relationships to make sure we don't overwrite
the original element when setting the related element property value.InvalidSPDXAnalysisExceptionprotected void addPropertyValue(String nameSpace, String propertyName, SpdxElement element, boolean updateModel) throws InvalidSPDXAnalysisException
nameSpace - propertyName - element - updateModel - If true, update the model from the element. If false, update the
element from the model. This is used for relationships to make sure we don't overwrite
the original element when setting the related element property value.InvalidSPDXAnalysisExceptionprotected void addPropertyValue(String nameSpace, String propertyName, SpdxElement element) throws InvalidSPDXAnalysisException
nameSpace - propertyName - element - InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, SpdxElement element) throws InvalidSPDXAnalysisException
InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, SpdxElement[] element) throws InvalidSPDXAnalysisException
InvalidSPDXAnalysisExceptionprotected void setPropertyValues(String nameSpace, String propertyName, Annotation[] annotations) throws InvalidSPDXAnalysisException
InvalidSPDXAnalysisExceptionprotected void addPropertyValue(String nameSpace, String propertyName, Annotation annotation) throws InvalidSPDXAnalysisException
InvalidSPDXAnalysisExceptionprotected void addPropertyValue(String nameSpace, String propertyName, ExternalRef externalRef) throws InvalidSPDXAnalysisException
InvalidSPDXAnalysisExceptionprotected Annotation[] findAnnotationPropertyValues(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - InvalidSPDXAnalysisExceptionprotected Relationship[] findRelationshipPropertyValues(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - InvalidSPDXAnalysisExceptionprotected StartEndPointer[] findStartEndPointerPropertyValues(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, StartEndPointer[] values) throws InvalidSPDXAnalysisException
nameSpace - RDF Namespace for the propertypropertyName - RDF Property Namevalue - Values to setInvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, String value)
nameSpace - RDF Namespace for the propertypropertyName - RDF Property Namevalue - Values to setprotected void removePropertyValue(String nameSpace, String propertyName)
nameSpace - RDF Namespace for the propertypropertyName - RDF Property Nameprotected void setPropertyValues(String nameSpace, String propertyName, Relationship[] relationships) throws InvalidSPDXAnalysisException
nameSpace - propertyName - relationships - InvalidSPDXAnalysisExceptionprotected void addPropertyValue(String nameSpace, String propertyName, Relationship relationship) throws InvalidSPDXAnalysisException
nameSpace - propertyName - relationship - InvalidSPDXAnalysisExceptionpublic void setPropertyValues(String nameSpace, String propertyName, AnyLicenseInfo[] licenses) throws InvalidSPDXAnalysisException
nameSpace - propertyName - licenses - InvalidSPDXAnalysisExceptionpublic void addPropertyValue(String nameSpace, String propertyName, AnyLicenseInfo license) throws InvalidSPDXAnalysisException
nameSpace - propertyName - license - InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, AnyLicenseInfo license) throws InvalidSPDXAnalysisException
nameSpace - propertyName - license - InvalidSPDXAnalysisExceptionpublic AnyLicenseInfo[] findAnyLicenseInfoPropertyValues(String namespace, String propertyName) throws InvalidSPDXAnalysisException
namespace - Namespace for the property namepropertyName - Name of the propertyInvalidSPDXAnalysisExceptionpublic AnyLicenseInfo findAnyLicenseInfoPropertyValue(String namespace, String propertyName) throws InvalidSPDXAnalysisException
namespace - Namespace for the property namepropertyName - Name of the propertyInvalidSPDXAnalysisExceptionprotected Checksum[] findMultipleChecksumPropertyValues(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - InvalidSPDXAnalysisExceptionprotected Checksum findChecksumPropertyValue(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - InvalidSPDXAnalysisExceptionprotected void addPropertyValue(String nameSpace, String propertyName, Checksum checksumValue) throws InvalidSPDXAnalysisException
nameSpace - propertyName - checksumValues - InvalidSPDXAnalysisExceptionprotected void setPropertyValues(String nameSpace, String propertyName, Checksum[] checksumValues) throws InvalidSPDXAnalysisException
nameSpace - propertyName - checksumValues - InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, ReferenceType referenceType) throws InvalidSPDXAnalysisException
nameSpace - propertyName - referenceType - InvalidSPDXAnalysisExceptionprotected ReferenceType findReferenceTypePropertyValue(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, Checksum checksumValue) throws InvalidSPDXAnalysisException
nameSpace - propertyName - checksumValue - InvalidSPDXAnalysisExceptionprotected DoapProject[] findMultipleDoapPropertyValues(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - checksumValue - InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, DoapProject[] doapProjectValues) throws InvalidSPDXAnalysisException
nameSpace - propertyName - doapProjectValues - InvalidSPDXAnalysisExceptionprotected String findUriPropertyValue(String namespace, String propertyName)
namespace - propertyName - protected String[] findUriPropertyValues(String namespace, String propertyName)
namespace - propertyName - protected void setPropertyUriValues(String nameSpace, String propertyName, String[] uris) throws InvalidSPDXAnalysisException
nameSpace - propertyName - referenceTypeUri - InvalidSPDXAnalysisExceptionprotected void addPropertyUriValue(String nameSpace, String propertyName, String uri) throws InvalidSPDXAnalysisException
nameSpace - propertyName - uri - InvalidSPDXAnalysisExceptionprotected void setPropertyUriValue(String nameSpace, String propertyName, String uri) throws InvalidSPDXAnalysisException
nameSpace - propertyName - uri - InvalidSPDXAnalysisExceptionprotected SPDXCreatorInformation findCreationInfoPropertyValue(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, SPDXCreatorInformation creatorInfo)
nameSpace - propertyName - creatorInfo - protected SinglePointer findSinglePointerPropertyValue(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, SinglePointer singlePointer) throws InvalidSPDXAnalysisException
nameSpace - propertyName - creatorInfo - InvalidSPDXAnalysisExceptionpublic ExternalDocumentRef[] findExternalDocRefPropertyValues(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
InvalidSPDXAnalysisExceptionpublic static ExternalDocumentRef[] findExternalDocRefPropertyValues(String nameSpace, String propertyName, IModelContainer extDocModelContainer, org.apache.jena.graph.Node nodeContainingExternalRefs) throws InvalidSPDXAnalysisException
nameSpace - propSpdxExternalDocRef - InvalidSPDXAnalysisExceptionpublic void setPropertyValues(String nameSpace, String propertyName, ExternalDocumentRef[] externalDocRefs) throws InvalidSPDXAnalysisException
nameSpace - propertyName - externalDocRefs - InvalidSPDXAnalysisExceptionprotected void setPropertyValues(String nameSpace, String propertyName, SPDXReview[] reviewers)
nameSpace - propertyName - reviewers - protected SPDXReview[] findReviewPropertyValues(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - InvalidSPDXAnalysisExceptionprotected SpdxPackageVerificationCode findVerificationCodePropertyValue(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, SpdxPackageVerificationCode verificationCode) throws InvalidSPDXAnalysisException
nameSpace - propertyName - verificationCode - InvalidSPDXAnalysisExceptionprotected ExternalRef[] findExternalRefPropertyValues(String nameSpace, String propertyName) throws InvalidSPDXAnalysisException
nameSpace - propertyName - externalRef - InvalidSPDXAnalysisExceptionprotected void setPropertyValue(String nameSpace, String propertyName, ExternalRef[] externalRefs) throws InvalidSPDXAnalysisException
nameSpace - propertyName - externalRefs - InvalidSPDXAnalysisExceptionpublic boolean arraysEquivalent(IRdfModel[] array1, IRdfModel[] array2)
array1 - array2 - public boolean equivalentConsideringNull(IRdfModel o1, IRdfModel o2)
o1 - o2 - public void setMultipleObjectsForSameNode()
IRdfModelsetMultipleObjectsForSameNode in interface IRdfModelpublic void setSingleObjectForSameNode()
IRdfModelsetSingleObjectForSameNode in interface IRdfModelpublic boolean isRefreshOnGet()
public org.apache.jena.graph.Node getNode()
Copyright © 2018 Linux Foundation. All Rights Reserved.