Package org.spdx.rdfparser.model
Class SpdxElement
java.lang.Object
org.spdx.rdfparser.model.RdfModelObject
org.spdx.rdfparser.model.SpdxElement
- Direct Known Subclasses:
ExternalSpdxElement,SpdxConstantElement,SpdxDocument,SpdxItem
public class SpdxElement extends RdfModelObject
An SpdxElement is any thing described in SPDX, either a document or an SpdxItem.
SpdxElements can be related to other SpdxElements.
All subclasses should override getType, equals and hashCode.
If a subproperty is used for the name property name, getNamePropertyName should be overridden.
If absolute URIs are required, getUri should be overriden.
- Author:
- Gary O'Neall
-
Field Summary
Fields Modifier and Type Field Description protected Annotation[]annotationsprotected Stringcommentprotected Stringnameprotected Relationship[]relationshipsFields inherited from class org.spdx.rdfparser.model.RdfModelObject
model, modelContainer, node, refreshOnGet, resource -
Constructor Summary
Constructors Constructor Description SpdxElement(String name, String comment, Annotation[] annotations, Relationship[] relationships)SpdxElement(IModelContainer modelContainer, org.apache.jena.graph.Node node) -
Method Summary
Modifier and Type Method Description voidaddAnnotation(Annotation annotation)protected voidaddNameToWarnings(List<String> warnings)Add the name of the element to all strings in the listvoidaddRelationship(Relationship relationship)booleanarraysEquivalent(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 nullsbooleanarraysEquivalent(IRdfModel[] array1, IRdfModel[] array2, boolean testRelationships)Compares 2 arrays to see if the property values for the element RdfModelObjects are the same independent of order and considering nullsSpdxElementclone()SpdxElementclone(Map<String,SpdxElement> clonedElementIds)Clones this element, but prevents infinite recursion by keeping track of all elements which have been clonedprotected Annotation[]cloneAnnotations()protected Relationship[]cloneRelationships(Map<String,SpdxElement> clonedElementIds)booleanequivalent(IRdfModel o)Returns true if the compare object contains properties which would be equal if they were contained in the same RDF Modelbooleanequivalent(IRdfModel o, boolean testRelationships)Test for equivalentbooleanequivalentConsideringNull(IRdfModel o1, IRdfModel o2)Compares the properties of two RdfModelObjects considering possible null valuesbooleanequivalentConsideringNull(SpdxElement o1, SpdxElement o2, boolean testRelationship)Compares the properties of two RdfModelObjects considering possible null valuesAnnotation[]getAnnotations()StringgetComment()StringgetId()The ID is a unique identify for the SPDX element.StringgetName()protected StringgetNamePropertyName()voidgetPropertiesFromModel()Fetch all of the properties from the model and populate the local Java propertiesRelationship[]getRelationships()org.apache.jena.rdf.model.ResourcegetType(org.apache.jena.rdf.model.Model model)StringgetUri(IModelContainer modelContainer)Get the URI for this RDF object.voidpopulateModel()Populate the RDF model from the Java propertiesvoidsetAnnotations(Annotation[] annotations)voidsetComment(String comment)voidsetId(String id)The ID is a unique identify for the SPDX element.voidsetName(String name)Set the namevoidsetRelationships(Relationship[] relationships)StringtoString()List<String>verify()Methods inherited from class org.spdx.rdfparser.model.RdfModelObject
addPropertyUriValue, addPropertyValue, addPropertyValue, addPropertyValue, addPropertyValue, addPropertyValue, addPropertyValue, addPropertyValue, createResource, createResource, equals, findAnnotationPropertyValues, findAnyLicenseInfoPropertyValue, findAnyLicenseInfoPropertyValues, findChecksumPropertyValue, findCreationInfoPropertyValue, findDuplicateResource, findElementPropertyValue, findExternalDocRefPropertyValues, findExternalDocRefPropertyValues, findExternalRefPropertyValues, findIntPropertyValue, findMultipleChecksumPropertyValues, findMultipleCrossRefPropertyValues, findMultipleDoapPropertyValues, findMultipleElementPropertyValues, findMultiplePropertyValues, findReferenceTypePropertyValue, findRelationshipPropertyValues, findReviewPropertyValues, findSinglePointerPropertyValue, findSinglePropertyValue, findStartEndPointerPropertyValues, findUriPropertyValue, findUriPropertyValues, findVerificationCodePropertyValue, getNode, hashCode, isRefreshOnGet, removePropertyValue, resourcesEqual, setMultipleObjectsForSameNode, setPropertyUriValue, setPropertyUriValues, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, SetPropertyValue, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValues, setSingleObjectForSameNode
-
Field Details
-
Constructor Details
-
SpdxElement
public SpdxElement(IModelContainer modelContainer, org.apache.jena.graph.Node node) throws InvalidSPDXAnalysisException- Throws:
InvalidSPDXAnalysisException
-
SpdxElement
public SpdxElement(String name, String comment, Annotation[] annotations, Relationship[] relationships)- Parameters:
name- Name of the elementcomment- Optional comment on the elementannotations- Optional annotations for the elementrelationships- Optional relationships with other elements
-
-
Method Details
-
getPropertiesFromModel
Description copied from class:RdfModelObjectFetch all of the properties from the model and populate the local Java properties- Specified by:
getPropertiesFromModelin classRdfModelObject- Throws:
InvalidSPDXAnalysisException
-
populateModel
Description copied from class:RdfModelObjectPopulate the RDF model from the Java properties- Specified by:
populateModelin classRdfModelObject- Throws:
InvalidSPDXAnalysisException
-
verify
- Returns:
- List of validation errors for any non SPDX compliant properties.
-
addNameToWarnings
Add the name of the element to all strings in the list- Parameters:
warnings-
-
getAnnotations
- Returns:
- the annotations
-
setAnnotations
- Parameters:
annotations- the annotations to set- Throws:
InvalidSPDXAnalysisException
-
getComment
- Returns:
- the comment
-
setComment
- Parameters:
comment- the comment to set
-
getName
- Returns:
- the name
-
getNamePropertyName
- Returns:
- the property name used for the Name property. Override this function if using a subproperty of SPDX Name
-
setName
Set the name- Parameters:
name- the name to set
-
getRelationships
- Returns:
- the relationships
-
setRelationships
- Parameters:
relationships- the relationships to set- Throws:
InvalidSPDXAnalysisException
-
getId
The ID is a unique identify for the SPDX element. It is only required if this element is to be used outside of the RDF model containing the element.- Returns:
- the id
-
setId
The ID is a unique identify for the SPDX element. It is only required if this element is to be used outside of the RDF model containing the element.- Parameters:
id-- Throws:
InvalidSPDXAnalysisException
-
getUri
Description copied from class:RdfModelObjectGet the URI for this RDF object. Null if this is for an anonomous node.- Specified by:
getUriin classRdfModelObject- Returns:
- Throws:
InvalidSPDXAnalysisException
-
getType
public org.apache.jena.rdf.model.Resource getType(org.apache.jena.rdf.model.Model model)- Specified by:
getTypein classRdfModelObject- Returns:
- the RDF class name for the object
-
cloneAnnotations
-
cloneRelationships
-
clone
-
clone
Clones this element, but prevents infinite recursion by keeping track of all elements which have been cloned- Parameters:
clonedElementIds- element ID's fo all elements which have been cloned- Returns:
-
equivalent
Description copied from interface:IRdfModelReturns true if the compare object contains properties which would be equal if they were contained in the same RDF Model- Returns:
-
equivalent
Test for equivalent- Parameters:
o-testRelationships- If true, test relationships- Returns:
-
toString
-
addRelationship
- Parameters:
describesRelationship-- Throws:
InvalidSPDXAnalysisException
-
addAnnotation
- Parameters:
annotation-- Throws:
InvalidSPDXAnalysisException
-
arraysEquivalent
Compares 2 arrays to see if the property values for the element RdfModelObjects are the same independent of order and considering nulls- Overrides:
arraysEquivalentin classRdfModelObject- Parameters:
array1-array2-testRelationships- If true, test relationships for an SpdxElement (used to manage infinite recursion on circular relationships)- Returns:
-
arraysEquivalent
Compares 2 arrays to see if the property values for the element RdfModelObjects are the same independent of order and considering nulls- Parameters:
array1-array2-testRelationships- If true, test relationships for an SpdxElement (used to manage infinite recursion on circular relationships)- Returns:
-
equivalentConsideringNull
Compares the properties of two RdfModelObjects considering possible null values- Overrides:
equivalentConsideringNullin classRdfModelObject- Parameters:
o1-o2-- Returns:
-
equivalentConsideringNull
Compares the properties of two RdfModelObjects considering possible null values- Parameters:
o1-o2-testRelationships- If true, test relationships for an SpdxElement (used to manage infinite recursion on circular relationships)- Returns:
-