Package org.spdx.library.model.v2
Class SpdxElement
- java.lang.Object
-
- org.spdx.core.CoreModelObject
-
- org.spdx.library.model.v2.ModelObjectV2
-
- org.spdx.library.model.v2.SpdxElement
-
- Direct Known Subclasses:
ExternalSpdxElement
,GenericSpdxElement
,SpdxConstantElement
,SpdxDocument
,SpdxItem
public abstract class SpdxElement extends ModelObjectV2
An SpdxElement is any thing described in SPDX, either a document or an SpdxItem. SpdxElements can be related to other SpdxElements. If a subproperty is used for the name property name, getNamePropertyName should be overridden.- Author:
- Gary O'Neall
-
-
Field Summary
-
Fields inherited from class org.spdx.library.model.v2.ModelObjectV2
LATEST_SPDX_2_VERSION
-
-
Constructor Summary
Constructors Constructor Description SpdxElement()
SpdxElement(String id)
SpdxElement(org.spdx.storage.IModelStore modelStore, String documentUri, String id, org.spdx.core.IModelCopyManager copyManager, boolean create)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<String>
_verify(Set<String> verifiedElementIds, String specVersion)
Implementation of the specific verifications for this model objectboolean
addAnnotation(Annotation annotation)
Add an annotationprotected List<String>
addNameToWarnings(List<String> warnings)
Add the name of the element to all strings in the listboolean
addRelationship(Relationship relationship)
Add a relationshipCollection<Annotation>
getAnnotations()
Optional<String>
getComment()
Optional<String>
getName()
protected org.spdx.storage.PropertyDescriptor
getNamePropertyDescriptor()
Collection<Relationship>
getRelationships()
boolean
removeAnnotation(Annotation annotation)
Remove an annotationboolean
removeRelationship(Relationship relationship)
Remove a relationshipSpdxElement
setAnnotations(Collection<Annotation> annotations)
Clears and resets the annotations collection to the parametervoid
setComment(String comment)
Sets the commentSpdxElement
setName(String name)
Set the nameSpdxElement
setRelationships(Collection<Relationship> relationships)
clear and reset the relationships to the parameter relationship-
Methods inherited from class org.spdx.library.model.v2.ModelObjectV2
_verify, createAnnotation, createByteOffsetPointer, createChecksum, createConjunctiveLicenseSet, createCreationInfo, createCrossRef, createDisjunctiveLicenseSet, createExternalDocumentRef, createExternalRef, createExtractedLicense, createLineCharPointer, createPackage, createPackageVerificationCode, createRelationship, createSpdxFile, createSpdxSnippet, createStartEndPointer, equals, getAnyLicenseInfoPropertyValue, getDocumentUri, getElementPropertyValue, getId, hashCode, isEquivalentToNull, isNoAssertion, isRelatedElement, toString, toTypedValue, verify
-
Methods inherited from class org.spdx.core.CoreModelObject
addPropertyValueToCollection, clearValueCollection, clone, copyFrom, enterCriticalSection, equivalent, equivalent, getBooleanPropertyValue, getCopyManager, getDoublePropertyValue, getEnumPropertyValue, getIdPrefix, getIntegerPropertyValue, getModelStore, getObjectPropertyValue, getObjectPropertyValue, getObjectPropertyValueCollection, getObjectPropertyValueSet, getObjectUri, getPropertyValueDescriptors, getSpecVersion, getStringCollection, getStringPropertyValue, getType, isCollectionMembersAssignableTo, isExternal, isStrict, leaveCriticalSection, removeProperty, removePropertyValueFromCollection, setCopyManager, setIdPrefix, setPropertyValue, setStrict, updateAddPropertyValueToCollection, updateClearValueCollection, updatePropertyValue, updateRemoveProperty, updateRemovePropertyValueFromCollection, verify, verify, verifyCollection
-
-
-
-
Constructor Detail
-
SpdxElement
public SpdxElement() throws org.spdx.core.InvalidSPDXAnalysisException
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
SpdxElement
public SpdxElement(String id) throws org.spdx.core.InvalidSPDXAnalysisException
- Parameters:
id
- identifier- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
SpdxElement
public SpdxElement(org.spdx.storage.IModelStore modelStore, String documentUri, String id, org.spdx.core.IModelCopyManager copyManager, boolean create) throws org.spdx.core.InvalidSPDXAnalysisException
- Parameters:
modelStore
- container which includes the model datadocumentUri
- URI for the SPDX document containing the model dataid
- identifiercopyManager
- if non-null, allows for copying of any properties set which use other model stores or document URI'screate
- if true, create the license if it does not exist- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
-
Method Detail
-
_verify
protected List<String> _verify(Set<String> verifiedElementIds, String specVersion)
Description copied from class:ModelObjectV2
Implementation of the specific verifications for this model object- Specified by:
_verify
in classModelObjectV2
- Parameters:
verifiedElementIds
- list of all Element Id's which have already been verified - prevents infinite recursionspecVersion
- Version of the SPDX spec to verify against- Returns:
- Any verification errors or warnings associated with this object
-
addNameToWarnings
protected List<String> addNameToWarnings(List<String> warnings)
Add the name of the element to all strings in the list- Parameters:
warnings
-- Returns:
- the same last after being modified (Note: a new list is not created - this modifies the warnings list)
-
getAnnotations
public Collection<Annotation> getAnnotations() throws org.spdx.core.InvalidSPDXAnalysisException
- Returns:
- Annotations
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setAnnotations
public SpdxElement setAnnotations(Collection<Annotation> annotations) throws org.spdx.core.InvalidSPDXAnalysisException
Clears and resets the annotations collection to the parameter- Parameters:
annotations
-- Returns:
- this to chain setters
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
addAnnotation
public boolean addAnnotation(Annotation annotation) throws org.spdx.core.InvalidSPDXAnalysisException
Add an annotation- Parameters:
annotation
-- Returns:
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
removeAnnotation
public boolean removeAnnotation(Annotation annotation) throws org.spdx.core.InvalidSPDXAnalysisException
Remove an annotation- Parameters:
annotation
-- Returns:
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getRelationships
public Collection<Relationship> getRelationships() throws org.spdx.core.InvalidSPDXAnalysisException
- Returns:
- Relationships
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setRelationships
public SpdxElement setRelationships(Collection<Relationship> relationships) throws org.spdx.core.InvalidSPDXAnalysisException
clear and reset the relationships to the parameter relationship- Parameters:
relationships
-- Returns:
- this to chain sets
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
addRelationship
public boolean addRelationship(Relationship relationship) throws org.spdx.core.InvalidSPDXAnalysisException
Add a relationship- Parameters:
relationship
-- Returns:
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
removeRelationship
public boolean removeRelationship(Relationship relationship) throws org.spdx.core.InvalidSPDXAnalysisException
Remove a relationship- Parameters:
relationship
-- Returns:
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getComment
public Optional<String> getComment() throws org.spdx.core.InvalidSPDXAnalysisException
- Returns:
- the comment
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setComment
public void setComment(String comment) throws org.spdx.core.InvalidSPDXAnalysisException
Sets the comment- Parameters:
comment
-- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getNamePropertyDescriptor
protected org.spdx.storage.PropertyDescriptor getNamePropertyDescriptor()
- Returns:
- the property name used for the Name property. Override this function if using a subproperty of SPDX Name
-
getName
public Optional<String> getName() throws org.spdx.core.InvalidSPDXAnalysisException
- Returns:
- the name
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setName
public SpdxElement setName(String name) throws org.spdx.core.InvalidSPDXAnalysisException
Set the name- Parameters:
name
-- Returns:
- this so that you can chain setters
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
-