Class SpdxFile

  • All Implemented Interfaces:
    Comparable<SpdxFile>

    public class SpdxFile
    extends SpdxItem
    implements Comparable<SpdxFile>
    A File represents a named sequence of information that is contained in a software package.
    Author:
    Gary O'Neall
    • Constructor Detail

      • SpdxFile

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

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

        public SpdxFile​(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
      • SpdxFile

        protected SpdxFile​(SpdxFile.SpdxFileBuilder spdxFileBuilder)
                    throws org.spdx.core.InvalidSPDXAnalysisException
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
    • Method Detail

      • getType

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

        public String getSha1()
                       throws org.spdx.core.InvalidSPDXAnalysisException
        Returns:
        the Sha1 checksum value for this file, or a blank string if no sha1 checksum has been set
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • setCopyrightText

        public SpdxFile setCopyrightText​(@Nullable
                                         String copyrightText)
                                  throws org.spdx.core.InvalidSPDXAnalysisException
        Overrides:
        setCopyrightText in class SpdxItem
        Parameters:
        copyrightText - the copyrightText to set
        Returns:
        myself - so you can chain setters
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • setName

        public SpdxFile setName​(@Nullable
                                String name)
                         throws org.spdx.core.InvalidSPDXAnalysisException
        Description copied from class: SpdxElement
        Set the name
        Overrides:
        setName in class SpdxItem
        Returns:
        this so that you can chain setters
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • setLicenseConcluded

        public SpdxFile setLicenseConcluded​(@Nullable
                                            AnyLicenseInfo license)
                                     throws org.spdx.core.InvalidSPDXAnalysisException
        Description copied from class: SpdxItem
        Set the licenseConcluded
        Overrides:
        setLicenseConcluded in class SpdxItem
        Returns:
        this so you can chain setters
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • setLicenseComments

        public SpdxFile setLicenseComments​(String licenseComments)
                                    throws org.spdx.core.InvalidSPDXAnalysisException
        Overrides:
        setLicenseComments in class SpdxItem
        Parameters:
        licenseComments - the licenseComment to set
        Returns:
        this so you chan chain setters
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getLicenseInfoFromFilesPropertyDescriptor

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

        protected org.spdx.storage.PropertyDescriptor getNamePropertyDescriptor()
        Overrides:
        getNamePropertyDescriptor in class SpdxElement
        Returns:
        the property name used for the Name property. Override this function if using a subproperty of SPDX Name
      • getFileTypes

        public Collection<FileType> getFileTypes()
                                          throws org.spdx.core.InvalidSPDXAnalysisException
        Returns:
        File types for the file
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • addFileType

        public boolean addFileType​(FileType fileType)
                            throws org.spdx.core.InvalidSPDXAnalysisException
        Add a file type to this file
        Parameters:
        fileType -
        Returns:
        true if the list was modified
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • addChecksum

        public boolean addChecksum​(Checksum checksum)
                            throws org.spdx.core.InvalidSPDXAnalysisException
        Add a checksum
        Parameters:
        checksum -
        Returns:
        true if the list was modified
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getFileContributors

        public Collection<String> getFileContributors()
        Returns:
        the fileContributors
      • addFileContributor

        public boolean addFileContributor​(String contributor)
        Add a file contributor to the file contributors collection
        Parameters:
        contributor -
        Returns:
      • getNoticeText

        public Optional<String> getNoticeText()
                                       throws org.spdx.core.InvalidSPDXAnalysisException
        Returns:
        the noticeText
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • setNoticeText

        public SpdxFile setNoticeText​(@Nullable
                                      String noticeText)
                               throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        noticeText - the noticeText to set
        Returns:
        this so you can chain setters
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getFileDependency

        @Deprecated
        public Collection<SpdxFile> getFileDependency()
                                               throws org.spdx.core.InvalidSPDXAnalysisException
        Deprecated.
        Returns:
        file dependencies - note: this is deprecated, use relationships between files rather than this field
        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