Package org.spdx.library.model
Class ExternalSpdxElement
java.lang.Object
org.spdx.library.model.ModelObject
org.spdx.library.model.SpdxElement
org.spdx.library.model.ExternalSpdxElement
- All Implemented Interfaces:
IndividualUriValue
public class ExternalSpdxElement extends SpdxElement implements IndividualUriValue
This is an SPDX element which is in an external document. The ID must be in the form SpdxConstants.EXTERNAL_ELEMENT_REF_PATTERN.pattern()
- Author:
- Gary O'Neall
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ExternalSpdxElement(String id)ExternalSpdxElement(IModelStore modelStore, String documentUri, String id, ModelCopyManager copyManager, boolean create) -
Method Summary
Modifier and Type Method Description protected List<String>_verify(Set<String> verifiedIds, String specVersion)Implementation of the specific verifications for this model objectbooleanaddAnnotation(Annotation annotation)Add an annotationbooleanaddRelationship(Relationship relationship)Add a relationshipbooleanequals(Object comp)booleanequivalent(ModelObject compare)static StringexternalDocumentIdToNamespace(String externalDocumentId, IModelStore stModelStore, String stDocumentUri, ModelCopyManager copyManager)static StringexternalSpdxElementIdToURI(String externalSpdxElementId, IModelStore stModelStore, String stDocumentUri, ModelCopyManager copyManager)Collection<Annotation>getAnnotations()Optional<String>getComment()StringgetExternalDocumentId()StringgetExternalElementId()StringgetExternalSpdxElementURI()StringgetIndividualURI()Optional<String>getName()Collection<Relationship>getRelationships()StringgetType()inthashCode()booleanremoveAnnotation(Annotation annotation)Remove an annotationbooleanremoveRelationship(Relationship relationship)Remove a relationshipSpdxElementsetAnnotations(Collection<Annotation> annotations)Clears and resets the annotations collection to the parametervoidsetComment(String comment)Sets the commentExternalSpdxElementsetName(String name)Set the nameSpdxElementsetRelationships(Collection<Relationship> relationships)clear and reset the relationships to the paramater relationshipstatic ExternalSpdxElementuriToExternalSpdxElement(String uri, IModelStore stModelStore, String stDocumentUri, ModelCopyManager copyManager)Create an ExternalSpdxElement based on a URI of the form externaldocumentnamespace#SPDXRef-[NUM]static StringuriToExternalSpdxElementId(String uri, IModelStore stModelStore, String stDocumentUri, ModelCopyManager copyManager)Convert a URI to an ID for an External SPDX ElementMethods inherited from class org.spdx.library.model.SpdxElement
addNameToWarnings, getNamePropertyNameMethods inherited from class org.spdx.library.model.ModelObject
addPropertyValueToCollection, addValueToCollection, clearValueCollection, clearValueCollection, clone, copyFrom, createAnnotation, createByteOffsetPointer, createChecksum, createConjunctiveLicenseSet, createCreationInfo, createCrossRef, createDisjunctiveLicenseSet, createExternalDocumentRef, createExternalRef, createLineCharPointer, createPackage, createPackageVerificationCode, createRelationship, createSpdxFile, createSpdxSnippet, createStartEndPointer, enterCriticalSection, equivalent, getAnyLicenseInfoPropertyValue, getBooleanPropertyValue, getCopyManager, getDocumentUri, getElementPropertyValue, getEnumPropertyValue, getId, getIntegerPropertyValue, getModelStore, getObjectPropertyValue, getObjectPropertyValue, getObjectPropertyValueCollection, getObjectPropertyValueSet, getPropertyValueNames, getStringCollection, getStringPropertyValue, idToIdType, isCollectionMembersAssignableTo, isStrict, leaveCriticalSection, removeProperty, removeProperty, removePropertyValueFromCollection, removePropertyValueFromCollection, replacePropertyValueCollection, setCopyManager, setPropertyValue, setPropertyValue, setStrict, toString, toTypedValue, updateAddPropertyValueToCollection, updateClearValueCollection, updatePropertyValue, updateRemoveProperty, updateRemovePropertyValueFromCollection, verify, verify, verify, verifyCollection
-
Constructor Details
-
ExternalSpdxElement
- Parameters:
id-- Throws:
InvalidSPDXAnalysisException
-
ExternalSpdxElement
public ExternalSpdxElement(IModelStore modelStore, String documentUri, String id, @Nullable ModelCopyManager copyManager, boolean create) throws InvalidSPDXAnalysisException- Parameters:
modelStore-documentUri-id-create-- Throws:
InvalidSPDXAnalysisException
-
-
Method Details
-
getExternalDocumentId
- Returns:
- external document ID for the external reference
- Throws:
InvalidSPDXAnalysisException
-
getExternalElementId
- Returns:
- element ID used in the external document
- Throws:
InvalidSPDXAnalysisException
-
getType
- Specified by:
getTypein classModelObject- Returns:
- The class name for this object. Class names are defined in the constants file
-
_verify
Description copied from class:ModelObjectImplementation of the specific verifications for this model object- Overrides:
_verifyin 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
-
getExternalSpdxElementURI
- Returns:
- the External URI associated with this external SPDX element
- Throws:
InvalidSPDXAnalysisException
-
externalSpdxElementIdToURI
public static String externalSpdxElementIdToURI(String externalSpdxElementId, IModelStore stModelStore, String stDocumentUri, ModelCopyManager copyManager) throws InvalidSPDXAnalysisException- Parameters:
externalSpdxElementId-stModelStore-stDocumentUri-copyManager-- Returns:
- The URI associated with the external SPDX element with the ID externalSpdxElementId
- Throws:
InvalidSPDXAnalysisException
-
uriToExternalSpdxElementId
public static String uriToExternalSpdxElementId(String uri, IModelStore stModelStore, String stDocumentUri, ModelCopyManager copyManager) throws InvalidSPDXAnalysisExceptionConvert 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-copyManager- if true, create the external doc ref if it is not already in the ModelStore- Returns:
- external SPDX element ID in the form DocumentRef-XX:SPDXRef-YY
- Throws:
InvalidSPDXAnalysisException
-
uriToExternalSpdxElement
public static ExternalSpdxElement uriToExternalSpdxElement(String uri, IModelStore stModelStore, String stDocumentUri, ModelCopyManager copyManager) throws InvalidSPDXAnalysisExceptionCreate an ExternalSpdxElement based on a URI of the form externaldocumentnamespace#SPDXRef-[NUM]- Parameters:
uri- RI of the form externaldocumentnamespace#SPDXRef-[NUM]stModelStore-stDocumentUri-copyManager- if non-null, create the external doc ref if it is not already in the ModelStore- Returns:
- ExternalSpdxRef
- Throws:
InvalidSPDXAnalysisException
-
externalDocumentIdToNamespace
public static String externalDocumentIdToNamespace(String externalDocumentId, IModelStore stModelStore, String stDocumentUri, ModelCopyManager copyManager) throws InvalidSPDXAnalysisException- Throws:
InvalidSPDXAnalysisException
-
equivalent
- Overrides:
equivalentin classModelObject- Returns:
- true if all the properties have the same or equivalent values
-
getIndividualURI
- Specified by:
getIndividualURIin interfaceIndividualUriValue- Returns:
- a unique identifier for this value. Typically the namespace + the long name
-
addAnnotation
Description copied from class:SpdxElementAdd an annotation- Overrides:
addAnnotationin classSpdxElement- Returns:
- Throws:
InvalidSPDXAnalysisException
-
addRelationship
Description copied from class:SpdxElementAdd a relationship- Overrides:
addRelationshipin classSpdxElement- Returns:
- Throws:
InvalidSPDXAnalysisException
-
setComment
Description copied from class:SpdxElementSets the comment- Overrides:
setCommentin classSpdxElement- Throws:
InvalidSPDXAnalysisException
-
setName
Description copied from class:SpdxElementSet the name- Overrides:
setNamein classSpdxElement- Returns:
- this so that you can chain setters
- Throws:
InvalidSPDXAnalysisException
-
getAnnotations
- Overrides:
getAnnotationsin classSpdxElement- Returns:
- Annotations
- Throws:
InvalidSPDXAnalysisException
-
setAnnotations
public SpdxElement setAnnotations(Collection<Annotation> annotations) throws InvalidSPDXAnalysisExceptionClears and resets the annotations collection to the parameter- Overrides:
setAnnotationsin classSpdxElement- Parameters:
annotations-- Returns:
- this to chain setters
- Throws:
InvalidSPDXAnalysisException
-
removeAnnotation
Remove an annotation- Overrides:
removeAnnotationin classSpdxElement- Parameters:
annotation-- Returns:
- Throws:
InvalidSPDXAnalysisException
-
getRelationships
- Overrides:
getRelationshipsin classSpdxElement- Returns:
- Relationships
- Throws:
InvalidSPDXAnalysisException
-
setRelationships
public SpdxElement setRelationships(Collection<Relationship> relationships) throws InvalidSPDXAnalysisExceptionclear and reset the relationships to the paramater relationship- Overrides:
setRelationshipsin classSpdxElement- Parameters:
relationships-- Returns:
- this to chain sets
- Throws:
InvalidSPDXAnalysisException
-
removeRelationship
Remove a relationship- Overrides:
removeRelationshipin classSpdxElement- Parameters:
relationship-- Returns:
- Throws:
InvalidSPDXAnalysisException
-
getComment
- Overrides:
getCommentin classSpdxElement- Returns:
- the comment
- Throws:
InvalidSPDXAnalysisException
-
getName
- Overrides:
getNamein classSpdxElement- Returns:
- the name
- Throws:
InvalidSPDXAnalysisException
-
equals
- Overrides:
equalsin classModelObject
-
hashCode
public int hashCode()- Overrides:
hashCodein classModelObject
-