Package org.spdx.library.model.v2
Class ExternalSpdxElement
- java.lang.Object
-
- org.spdx.core.CoreModelObject
-
- org.spdx.library.model.v2.ModelObjectV2
-
- org.spdx.library.model.v2.SpdxElement
-
- org.spdx.library.model.v2.ExternalSpdxElement
-
- All Implemented Interfaces:
org.spdx.core.IndividualUriValue
public class ExternalSpdxElement extends SpdxElement implements org.spdx.core.IndividualUriValue
This is an SPDX element which is in an external document. Note that the ExternalSpdxElement is implemented differently than the previous major version of the SPDX libraries. The constructor now takes the documentUri and ID of the target external SPDX element NOT the documentUri of the referencing document and the ID is the SPDX ID, not the documentRef version.- 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 ExternalSpdxElement(String documentUri, String id)
ExternalSpdxElement(org.spdx.storage.IModelStore modelStore, String documentUri, String id, org.spdx.core.IModelCopyManager copyManager)
ExternalSpdxElement(org.spdx.storage.IModelStore modelStore, String documentUri, String id, org.spdx.core.IModelCopyManager copyManager, boolean create)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<String>
_verify(Set<String> verifiedIds, String specVersion)
Implementation of the specific verifications for this model objectboolean
addAnnotation(Annotation annotation)
Add an annotationboolean
addRelationship(Relationship relationship)
Add a relationshipboolean
equals(Object comp)
boolean
equivalent(org.spdx.core.CoreModelObject compare)
boolean
equivalent(org.spdx.core.CoreModelObject compare, boolean ignoreRelatedElements)
static String
externalDocumentIdToNamespace(String externalDocumentId, org.spdx.storage.IModelStore stModelStore, String stDocumentUri, org.spdx.core.IModelCopyManager copyManager)
static String
externalSpdxElementIdToURI(String externalSpdxElementId, org.spdx.storage.IModelStore stModelStore, String stDocumentUri, org.spdx.core.IModelCopyManager copyManager)
Collection<Annotation>
getAnnotations()
Optional<String>
getComment()
String
getExternalDocumentId(SpdxDocument documentReferencingExternal)
String
getExternalElementId()
String
getIndividualURI()
Optional<String>
getName()
Collection<Relationship>
getRelationships()
String
getType()
int
hashCode()
boolean
isExternal()
String
referenceElementId(SpdxDocument documentReferencingExternal)
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 commentExternalSpdxElement
setName(String name)
Set the nameSpdxElement
setRelationships(Collection<Relationship> relationships)
clear and reset the relationships to the parameter relationshipstatic String
uriToExternalSpdxElementReference(String uri, org.spdx.storage.IModelStore stModelStore, String stDocumentUri, org.spdx.core.IModelCopyManager copyManager, String specVersion)
Convert a URI to an ID for an External SPDX Element-
Methods inherited from class org.spdx.library.model.v2.SpdxElement
addNameToWarnings, getNamePropertyDescriptor
-
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, getAnyLicenseInfoPropertyValue, getDocumentUri, getElementPropertyValue, getId, isEquivalentToNull, isNoAssertion, isRelatedElement, toString, toTypedValue, verify
-
Methods inherited from class org.spdx.core.CoreModelObject
addPropertyValueToCollection, clearValueCollection, clone, copyFrom, enterCriticalSection, getBooleanPropertyValue, getCopyManager, getDoublePropertyValue, getEnumPropertyValue, getIdPrefix, getIntegerPropertyValue, getModelStore, getObjectPropertyValue, getObjectPropertyValue, getObjectPropertyValueCollection, getObjectPropertyValueSet, getObjectUri, getPropertyValueDescriptors, getSpecVersion, getStringCollection, getStringPropertyValue, isCollectionMembersAssignableTo, isStrict, leaveCriticalSection, removeProperty, removePropertyValueFromCollection, setCopyManager, setIdPrefix, setPropertyValue, setStrict, updateAddPropertyValueToCollection, updateClearValueCollection, updatePropertyValue, updateRemoveProperty, updateRemovePropertyValueFromCollection, verify, verify, verifyCollection
-
-
-
-
Constructor Detail
-
ExternalSpdxElement
public ExternalSpdxElement(String documentUri, String id) throws org.spdx.core.InvalidSPDXAnalysisException
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
ExternalSpdxElement
public ExternalSpdxElement(org.spdx.storage.IModelStore modelStore, String documentUri, String id, @Nullable org.spdx.core.IModelCopyManager copyManager, boolean create) throws org.spdx.core.InvalidSPDXAnalysisException
- Parameters:
modelStore
- Store to store THIS reference to an external SPDX elementdocumentUri
- documentURI for representing the external documentid
- ID of the external SPDX elementcreate
- this parameter is ignored since it is external- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
ExternalSpdxElement
public ExternalSpdxElement(org.spdx.storage.IModelStore modelStore, String documentUri, String id, @Nullable org.spdx.core.IModelCopyManager copyManager) throws org.spdx.core.InvalidSPDXAnalysisException
- Parameters:
modelStore
- Store to store THIS reference to an external SPDX elementdocumentUri
- documentURI for representing the external documentid
- ID of the external SPDX element- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
-
Method Detail
-
getExternalDocumentId
public String getExternalDocumentId(SpdxDocument documentReferencingExternal) throws org.spdx.core.InvalidSPDXAnalysisException
- Parameters:
documentReferencingExternal
- document containing the external reference- Returns:
- external document ID for the external reference
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
isExternal
public boolean isExternal()
- Overrides:
isExternal
in classorg.spdx.core.CoreModelObject
-
getExternalElementId
public String getExternalElementId() throws org.spdx.core.InvalidSPDXAnalysisException
- Returns:
- element ID used in the external document
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getType
public String getType()
- Specified by:
getType
in classorg.spdx.core.CoreModelObject
-
_verify
protected List<String> _verify(Set<String> verifiedIds, String specVersion)
Description copied from class:ModelObjectV2
Implementation of the specific verifications for this model object- Overrides:
_verify
in classSpdxElement
- Parameters:
verifiedIds
- 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
-
referenceElementId
public String referenceElementId(SpdxDocument documentReferencingExternal) throws org.spdx.core.InvalidSPDXAnalysisException
- Parameters:
documentReferencingExternal
- document containing the external reference- Returns:
- the ID used for referencing this external element within the documentReferencingExternal of the form DocRef-XXX:SpdxRef-YYY
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
- on error in SPDX parsing
-
externalSpdxElementIdToURI
public static String externalSpdxElementIdToURI(String externalSpdxElementId, org.spdx.storage.IModelStore stModelStore, String stDocumentUri, org.spdx.core.IModelCopyManager copyManager) throws org.spdx.core.InvalidSPDXAnalysisException
- Parameters:
externalSpdxElementId
- ID which is referencing the external document using the docRef:id patternstModelStore
- model storestDocumentUri
- Document URI which is referencing the external documentcopyManager
-- Returns:
- The URI associated with the external SPDX element with the ID externalSpdxElementId
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
uriToExternalSpdxElementReference
public static String uriToExternalSpdxElementReference(String uri, org.spdx.storage.IModelStore stModelStore, String stDocumentUri, org.spdx.core.IModelCopyManager copyManager, String specVersion) throws org.spdx.core.InvalidSPDXAnalysisException
Convert a URI to an ID for an External SPDX Element- Parameters:
uri
- URI with the external document namespace and the external SPDX ref in the form namespace#SPDXRef-[NUM]stModelStore
-stDocumentUri
- documentUri for the document referencing the external documentcopyManager
- if non-null, create the external Doc ref if it is not a property of the SPDX DocumentspecVersion
- version of the spec used for this external SPDX element- Returns:
- internal reference for the external SPDX element ID in the form DocumentRef-XX:SPDXRef-YY
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
externalDocumentIdToNamespace
public static String externalDocumentIdToNamespace(String externalDocumentId, org.spdx.storage.IModelStore stModelStore, String stDocumentUri, org.spdx.core.IModelCopyManager copyManager) throws org.spdx.core.InvalidSPDXAnalysisException
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
equivalent
public boolean equivalent(org.spdx.core.CoreModelObject compare)
- Overrides:
equivalent
in classorg.spdx.core.CoreModelObject
-
equivalent
public boolean equivalent(org.spdx.core.CoreModelObject compare, boolean ignoreRelatedElements) throws org.spdx.core.InvalidSPDXAnalysisException
- Overrides:
equivalent
in classorg.spdx.core.CoreModelObject
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getIndividualURI
public String getIndividualURI()
- Specified by:
getIndividualURI
in interfaceorg.spdx.core.IndividualUriValue
-
addAnnotation
public boolean addAnnotation(Annotation annotation) throws org.spdx.core.InvalidSPDXAnalysisException
Description copied from class:SpdxElement
Add an annotation- Overrides:
addAnnotation
in classSpdxElement
- Returns:
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
addRelationship
public boolean addRelationship(Relationship relationship) throws org.spdx.core.InvalidSPDXAnalysisException
Description copied from class:SpdxElement
Add a relationship- Overrides:
addRelationship
in classSpdxElement
- Returns:
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setComment
public void setComment(String comment) throws org.spdx.core.InvalidSPDXAnalysisException
Description copied from class:SpdxElement
Sets the comment- Overrides:
setComment
in classSpdxElement
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setName
public ExternalSpdxElement setName(String name) throws org.spdx.core.InvalidSPDXAnalysisException
Description copied from class:SpdxElement
Set the name- Overrides:
setName
in classSpdxElement
- Returns:
- this so that you can chain setters
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getAnnotations
public Collection<Annotation> getAnnotations() throws org.spdx.core.InvalidSPDXAnalysisException
- Overrides:
getAnnotations
in classSpdxElement
- 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- Overrides:
setAnnotations
in classSpdxElement
- Parameters:
annotations
-- Returns:
- this to chain setters
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
removeAnnotation
public boolean removeAnnotation(Annotation annotation) throws org.spdx.core.InvalidSPDXAnalysisException
Remove an annotation- Overrides:
removeAnnotation
in classSpdxElement
- Parameters:
annotation
-- Returns:
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getRelationships
public Collection<Relationship> getRelationships() throws org.spdx.core.InvalidSPDXAnalysisException
- Overrides:
getRelationships
in classSpdxElement
- 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- Overrides:
setRelationships
in classSpdxElement
- Parameters:
relationships
-- Returns:
- this to chain sets
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
removeRelationship
public boolean removeRelationship(Relationship relationship) throws org.spdx.core.InvalidSPDXAnalysisException
Remove a relationship- Overrides:
removeRelationship
in classSpdxElement
- Parameters:
relationship
-- Returns:
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getComment
public Optional<String> getComment() throws org.spdx.core.InvalidSPDXAnalysisException
- Overrides:
getComment
in classSpdxElement
- Returns:
- the comment
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getName
public Optional<String> getName() throws org.spdx.core.InvalidSPDXAnalysisException
- Overrides:
getName
in classSpdxElement
- Returns:
- the name
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
equals
public boolean equals(Object comp)
- Overrides:
equals
in classModelObjectV2
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classModelObjectV2
-
-