Class 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
    • 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 element
        documentUri - documentURI for representing the external document
        id - ID of the external SPDX element
        create - 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 element
        documentUri - documentURI for representing the external document
        id - 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 class org.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 class org.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 class SpdxElement
        Parameters:
        verifiedIds - list of all Element Id's which have already been verified - prevents infinite recursion
        specVersion - 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 pattern
        stModelStore - model store
        stDocumentUri - Document URI which is referencing the external document
        copyManager -
        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 document
        copyManager - if non-null, create the external Doc ref if it is not a property of the SPDX Document
        specVersion - 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 class org.spdx.core.CoreModelObject
      • equivalent

        public boolean equivalent​(org.spdx.core.CoreModelObject compare,
                                  boolean ignoreRelatedElements)
                           throws org.spdx.core.InvalidSPDXAnalysisException
        Overrides:
        equivalent in class org.spdx.core.CoreModelObject
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getIndividualURI

        public String getIndividualURI()
        Specified by:
        getIndividualURI in interface org.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 class SpdxElement
        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 class SpdxElement
        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 class SpdxElement
        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 class SpdxElement
        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 class SpdxElement
        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 class SpdxElement
        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 class SpdxElement
        Parameters:
        annotation -
        Returns:
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getRelationships

        public Collection<Relationship> getRelationships()
                                                  throws org.spdx.core.InvalidSPDXAnalysisException
        Overrides:
        getRelationships in class SpdxElement
        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 class SpdxElement
        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 class SpdxElement
        Parameters:
        relationship -
        Returns:
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getComment

        public Optional<String> getComment()
                                    throws org.spdx.core.InvalidSPDXAnalysisException
        Overrides:
        getComment in class SpdxElement
        Returns:
        the comment
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getName

        public Optional<String> getName()
                                 throws org.spdx.core.InvalidSPDXAnalysisException
        Overrides:
        getName in class SpdxElement
        Returns:
        the name
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException