Package org.spdx.library.model.v2
Class SpdxSnippet
- java.lang.Object
-
- org.spdx.core.CoreModelObject
-
- org.spdx.library.model.v2.ModelObjectV2
-
- org.spdx.library.model.v2.SpdxElement
-
- org.spdx.library.model.v2.SpdxItem
-
- org.spdx.library.model.v2.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SpdxSnippet.SpdxSnippetBuilder
-
Field Summary
-
Fields inherited from class org.spdx.library.model.v2.ModelObjectV2
LATEST_SPDX_2_VERSION
-
-
Constructor Summary
Constructors Constructor Description SpdxSnippet()
SpdxSnippet(String id)
SpdxSnippet(SpdxSnippet.SpdxSnippetBuilder spdxSnippetBuilder)
SpdxSnippet(org.spdx.storage.IModelStore modelStore, String documentUri, String id, org.spdx.core.IModelCopyManager copyManager, boolean create)
-
Method Summary
All 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 objectint
compareTo(SpdxSnippet o)
StartEndPointer
getByteRange()
org.spdx.storage.PropertyDescriptor
getLicenseInfoFromFilesPropertyDescriptor()
Optional<StartEndPointer>
getLineRange()
SpdxFile
getSnippetFromFile()
String
getType()
SpdxSnippet
setByteRange(int startByte, int endByte)
SpdxSnippet
setLineRange(int startLine, int endLine)
SpdxSnippet
setSnippetFromFile(SpdxFile snippetFromFile)
String
toString()
-
Methods inherited from class org.spdx.library.model.v2.SpdxItem
getAttributionText, getCopyrightText, getLicenseComments, getLicenseConcluded, getLicenseInfoFromFiles, setCopyrightText, setLicenseComments, setLicenseConcluded, setName
-
Methods inherited from class org.spdx.library.model.v2.SpdxElement
addAnnotation, addNameToWarnings, addRelationship, getAnnotations, getComment, getName, getNamePropertyDescriptor, getRelationships, removeAnnotation, removeRelationship, setAnnotations, setComment, setRelationships
-
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, equals, getAnyLicenseInfoPropertyValue, getDocumentUri, getElementPropertyValue, getId, hashCode, isEquivalentToNull, isNoAssertion, isRelatedElement, toTypedValue, verify
-
Methods inherited from class org.spdx.core.CoreModelObject
addPropertyValueToCollection, clearValueCollection, clone, copyFrom, enterCriticalSection, equivalent, equivalent, getBooleanPropertyValue, getCopyManager, getDoublePropertyValue, getEnumPropertyValue, getIdPrefix, getIntegerPropertyValue, getModelStore, getObjectPropertyValue, getObjectPropertyValue, getObjectPropertyValueCollection, getObjectPropertyValueSet, getObjectUri, getPropertyValueDescriptors, getSpecVersion, getStringCollection, getStringPropertyValue, isCollectionMembersAssignableTo, isExternal, isStrict, leaveCriticalSection, removeProperty, removePropertyValueFromCollection, setCopyManager, setIdPrefix, setPropertyValue, setStrict, updateAddPropertyValueToCollection, updateClearValueCollection, updatePropertyValue, updateRemoveProperty, updateRemovePropertyValueFromCollection, verify, verify, verifyCollection
-
-
-
-
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 datadocumentUri
- URI for the SPDX document containing the model dataid
- identifiercopyManager
- if non-null, allows for copying of any properties set which use other model stores or document URI'screate
- 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 classorg.spdx.core.CoreModelObject
-
getLicenseInfoFromFilesPropertyDescriptor
public org.spdx.storage.PropertyDescriptor getLicenseInfoFromFilesPropertyDescriptor()
- Overrides:
getLicenseInfoFromFilesPropertyDescriptor
in classSpdxItem
- 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 rangeendByte
- 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, inclusiveendLine
- 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
-
compareTo
public int compareTo(SpdxSnippet o)
- Specified by:
compareTo
in interfaceComparable<SpdxSnippet>
-
toString
public String toString()
- Overrides:
toString
in classModelObjectV2
-
-