Class SpdxSnippet

  • All Implemented Interfaces:
    Comparable<SpdxSnippet>

    public class SpdxSnippet
    extends SpdxItem
    implements Comparable<SpdxSnippet>
    Snippets can optionally be used when a file is known to have some content that has been included from another original source.

    They are useful for denoting when part of a file may have been originally created under another license. Each instance of Snippet Information needs to be associated with a specific File in an SPDX Document.

    Author:
    Gary O'Neall
    • Constructor Detail

      • SpdxSnippet

        public SpdxSnippet()
                    throws org.spdx.core.InvalidSPDXAnalysisException
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • SpdxSnippet

        public SpdxSnippet​(String id)
                    throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        id - identifier
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • SpdxSnippet

        public SpdxSnippet​(org.spdx.storage.IModelStore modelStore,
                           String documentUri,
                           String id,
                           @Nullable
                           org.spdx.core.IModelCopyManager copyManager,
                           boolean create)
                    throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        modelStore - container which includes the model data
        documentUri - URI for the SPDX document containing the model data
        id - identifier
        copyManager - if non-null, allows for copying of any properties set which use other model stores or document URI's
        create - if true, create the license if it does not exist
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • SpdxSnippet

        public SpdxSnippet​(SpdxSnippet.SpdxSnippetBuilder spdxSnippetBuilder)
                    throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        spdxSnippetBuilder -
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
    • Method Detail

      • getType

        public String getType()
        Specified by:
        getType in class org.spdx.core.CoreModelObject
      • getLicenseInfoFromFilesPropertyDescriptor

        public org.spdx.storage.PropertyDescriptor getLicenseInfoFromFilesPropertyDescriptor()
        Overrides:
        getLicenseInfoFromFilesPropertyDescriptor in class SpdxItem
        Returns:
        Property name for licenseInfoFromFiles. Override if using a subproperty of "licenseDeclared".
      • getSnippetFromFile

        @Nullable
        public SpdxFile getSnippetFromFile()
                                    throws org.spdx.core.InvalidSPDXAnalysisException
        Returns:
        the snippetFromFile, null if the file is not present in the model
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • setSnippetFromFile

        public SpdxSnippet setSnippetFromFile​(SpdxFile snippetFromFile)
                                       throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        snippetFromFile - the snippetFromFile to set
        Returns:
        this to chain setters
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getByteRange

        public StartEndPointer getByteRange()
                                     throws org.spdx.core.InvalidSPDXAnalysisException
        Returns:
        the byteRange or null if no byte range is present
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • setByteRange

        public SpdxSnippet setByteRange​(int startByte,
                                        int endByte)
                                 throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        startByte - first byte of the range
        endByte - end byte of the range
        Returns:
        this to chain setters
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getLineRange

        public Optional<StartEndPointer> getLineRange()
                                               throws org.spdx.core.InvalidSPDXAnalysisException
        Returns:
        the lineRange
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • setLineRange

        public SpdxSnippet setLineRange​(int startLine,
                                        int endLine)
                                 throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        startLine - the start position of lineRange to set, inclusive
        endLine - the end position of lineRange to set, exclusive
        Returns:
        this to chain setters
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • _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 SpdxItem
        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