Package org.spdx.library.model
Class ModelObject
java.lang.Object
org.spdx.library.model.ModelObject
- Direct Known Subclasses:
Annotation
,AnyLicenseInfo
,Checksum
,CompoundPointer
,CrossRef
,ExternalDocumentRef
,ExternalRef
,GenericModelObject
,LicenseException
,Relationship
,SinglePointer
,SpdxCreatorInformation
,SpdxElement
,SpdxPackageVerificationCode
public abstract class ModelObject extends Object
- Author:
- Gary O'Neall
Superclass for all SPDX model objects
Provides the primary interface to the storage class that access and stores the data for
the model objects.
This class includes several helper methods to manage the storage and retrieval of properties.
Each model object is in itself stateless. All state is maintained in the Model Store.
The Document URI uniquely identifies the document containing the model object.
The concrete classes are expected to implements getters for the model class properties which translate
into calls to the getTYPEPropertyValue where TYPE is the type of value to be returned and the property name
is passed as a parameter.
There are 2 methods of setting values:
- call the setPropertyValue, clearValueCollection or addValueToCollection methods - this will call the modelStore and store the
value immediately
- Gather a list of updates by calling the updatePropertyValue, updateClearValueList, or updateAddPropertyValue
methods. These methods return a ModelUpdate which can be applied later by calling the
apply()
method. A convenience methodWrite.applyUpdatesInOneTransaction
will perform all updates within a single transaction. This method may result in higher performance updates for some Model Store implementations. Note that none of the updates will be applied until the storage manager update method is invoked. Property values are restricted to the following types: - String - Java Strings - Booolean - Java Boolean or primitive boolean types - ModelObject - A concrete subclass of this type - Collection<T> - A Collection of type T where T is one of the supported non-collection types This class also handles the conversion of a ModelObject to and from a TypeValue for storage in the ModelStore.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
strict
if true, checks input values for setters to verify valid SPDX inputs -
Constructor Summary
Constructors Constructor Description ModelObject()
Create a new Model Object using an Anonomous ID with the defualt store and default document URIModelObject(String id)
Open or create a model object with the default store and default document URIModelObject(IModelStore modelStore, String documentUri, String id, ModelCopyManager copyManager, boolean create)
-
Method Summary
Modifier and Type Method Description protected abstract List<String>
_verify(List<String> verifiedElementIds)
Implementation of the specific verifications for this model objectprotected void
addPropertyValueToCollection(String propertyName, Object value)
Add a value to a collection of values associated with a property.protected static void
addValueToCollection(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName, Object value, ModelCopyManager copyManager)
Add a value to a collection of values associated with a property.protected void
clearValueCollection(String propertyName)
Clears a collection of values associated with a propertyprotected static void
clearValueCollection(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName)
Clears a collection of values associated with a property creating the property if it does not existModelObject
clone(IModelStore modelStore)
Clone a new object using a different model storevoid
copyFrom(ModelObject source)
Copy all the properties from the source objectAnnotation
createAnnotation(String annotator, AnnotationType annotationType, String date, String comment)
ByteOffsetPointer
createByteOffsetPointer(SpdxElement referencedElement, int offset)
Checksum
createChecksum(ChecksumAlgorithm algorithm, String value)
ConjunctiveLicenseSet
createConjunctiveLicenseSet(Collection<AnyLicenseInfo> members)
SpdxCreatorInformation
createCreationInfo(List<String> creators, String date)
CrossRef.CrossRefBuilder
createCrossRef(String url)
Create a CrossRef Builder with an Anonymous ID type using the same model store and document URIDisjunctiveLicenseSet
createDisjunctiveLicenseSet(Collection<AnyLicenseInfo> members)
ExternalDocumentRef
createExternalDocumentRef(String externalDocumentId, String externalDocumentUri, Checksum checksum)
ExternalRef
createExternalRef(ReferenceCategory category, ReferenceType referenceType, String locator, String comment)
LineCharPointer
createLineCharPointer(SpdxElement referencedElement, int lineNumber)
SpdxPackage.SpdxPackageBuilder
createPackage(String id, String name, AnyLicenseInfo concludedLicense, String copyrightText, AnyLicenseInfo licenseDeclared)
Create an SpdxPackageBuilder with all required fields for a filesAnalyzed=false using this objects model store and document URISpdxPackageVerificationCode
createPackageVerificationCode(String value, Collection<String> excludedFileNames)
Relationship
createRelationship(SpdxElement relatedElement, RelationshipType relationshipType, String comment)
SpdxFile.SpdxFileBuilder
createSpdxFile(String id, String name, AnyLicenseInfo concludedLicense, Collection<AnyLicenseInfo> seenLicense, String copyrightText, Checksum sha1)
Create an SpdxFileBuilder with all of the required properties - the build() method will build the fileSpdxSnippet.SpdxSnippetBuilder
createSpdxSnippet(String id, String name, AnyLicenseInfo concludedLicense, Collection<AnyLicenseInfo> seenLicense, String copyrightText, SpdxFile snippetFromFile, int startByte, int endByte)
Create an SpdxSnippetBuilder with all of the required properties - the build() method will build the fileStartEndPointer
createStartEndPointer(SinglePointer startPointer, SinglePointer endPointer)
IModelStore.IModelStoreLock
enterCriticalSection(boolean readLockRequested)
Enter a critical section.boolean
equals(Object o)
boolean
equivalent(ModelObject compare)
boolean
equivalent(ModelObject compare, boolean ignoreRelatedElements)
protected Optional<AnyLicenseInfo>
getAnyLicenseInfoPropertyValue(String propertyName)
Converts property values to an AnyLicenseInfo if possible - if NONE or NOASSERTION URI value, convert to the appropriate licenseprotected Optional<Boolean>
getBooleanPropertyValue(String propertyName)
ModelCopyManager
getCopyManager()
String
getDocumentUri()
protected Optional<SpdxElement>
getElementPropertyValue(String propertyName)
Converts property values to an SpdxElement if possible - if NONE or NOASSERTION URI value, convert to the appropriate SpdxElementprotected Optional<Enum<?>>
getEnumPropertyValue(String propertyName)
String
getId()
protected Optional<Integer>
getIntegerPropertyValue(String propertyName)
IModelStore
getModelStore()
protected Optional<Object>
getObjectPropertyValue(String propertyName)
Get an object value for a propertyprotected static Optional<Object>
getObjectPropertyValue(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName, ModelCopyManager copyManager)
Get an object value for a propertyprotected ModelCollection<?>
getObjectPropertyValueCollection(String propertyName, Class<?> type)
protected ModelSet<?>
getObjectPropertyValueSet(String propertyName, Class<?> type)
List<String>
getPropertyValueNames()
protected Collection<String>
getStringCollection(String propertyName)
protected Optional<String>
getStringPropertyValue(String propertyName)
abstract String
getType()
int
hashCode()
protected IModelStore.IdType
idToIdType(String id)
protected boolean
isCollectionMembersAssignableTo(String propertyName, Class<?> clazz)
boolean
isStrict()
void
leaveCriticalSection(IModelStore.IModelStoreLock lock)
Leave a critical section.protected void
removeProperty(String propertyName)
Removes a property and its value from the model store if it existsprotected static void
removeProperty(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName)
Removes a property and its value from the model store if it existsprotected void
removePropertyValueFromCollection(String propertyName, Object value)
Remove a property value from a collectionprotected static void
removePropertyValueFromCollection(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName, Object value)
Remove a property value from a collectionprotected static void
replacePropertyValueCollection(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName, Collection<?> values, ModelCopyManager copyManager)
Replace the entire value collection for a property.void
setCopyManager(ModelCopyManager copyManager)
protected void
setPropertyValue(String propertyName, Object value)
Set a property value for a property name, creating the property if necessaryprotected static void
setPropertyValue(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName, Object value, ModelCopyManager copyManager)
Set a property value for a property name, creating the property if necessaryvoid
setStrict(boolean strict)
String
toString()
protected TypedValue
toTypedValue()
protected IModelStore.ModelUpdate
updateAddPropertyValueToCollection(String propertyName, Object value)
Create an update when, when applied, adds a value to a collection of values associated with a property.protected IModelStore.ModelUpdate
updateClearValueCollection(String propertyName)
Create an update when, when applied by the ModelStore, clears a collection of values associated with a propertyprotected IModelStore.ModelUpdate
updatePropertyValue(String propertyName, Object value)
Create an update when, when applied by the ModelStore, sets a property value for a property name, creating the property if necessaryprotected IModelStore.ModelUpdate
updateRemoveProperty(String propertyName)
Create an update when, when applied by the ModelStore, removes a property and its value from the model store if it existsprotected IModelStore.ModelUpdate
updateRemovePropertyValueFromCollection(String propertyName, Object value)
Create an update when, when applied, removes a property value from a collectionList<String>
verify()
List<String>
verify(List<String> verifiedIElementds)
protected List<String>
verifyCollection(Collection<? extends ModelObject> collection, String warningPrefix, List<String> verifiedIds)
Verifies all elements in a collection
-
Field Details
-
strict
protected boolean strictif true, checks input values for setters to verify valid SPDX inputs
-
-
Constructor Details
-
ModelObject
Create a new Model Object using an Anonomous ID with the defualt store and default document URI- Throws:
InvalidSPDXAnalysisException
-
ModelObject
Open or create a model object with the default store and default document URI- Parameters:
id
- ID for this object - must be unique within the SPDX document- Throws:
InvalidSPDXAnalysisException
-
ModelObject
public ModelObject(IModelStore modelStore, String documentUri, String id, @Nullable ModelCopyManager copyManager, boolean create) throws InvalidSPDXAnalysisException- Parameters:
modelStore
- Storage for the model objectsdocumentUri
- SPDX Document URI for a document associated with this modelid
- ID for this object - must be unique within the SPDX documentcopyManager
- - if supplied, model objects will be implictly copied into this model store and document URI when referenced by setting methodscreate
- - if true, the object will be created in the store if it is not already present- Throws:
InvalidSPDXAnalysisException
-
-
Method Details
-
getType
- Returns:
- The class name for this object. Class names are defined in the constants file
-
_verify
Implementation of the specific verifications for this model object- Parameters:
verifiedElementIds
- list of all Element Id's which have already been verified - prevents infinite recursion- Returns:
- Any verification errors or warnings associated with this object
-
verify
- Parameters:
verifiedIElementds
- list of all element Id's which have already been verified - prevents infinite recursion- Returns:
- Any verification errors or warnings associated with this object
-
verify
- Returns:
- Any verification errors or warnings associated with this object
-
getDocumentUri
- Returns:
- the Document URI for this object
-
getId
- Returns:
- ID for the object
-
getModelStore
- Returns:
- the model store for this object
-
isStrict
public boolean isStrict()- Returns:
- if strict input checking is enabled
-
setStrict
public void setStrict(boolean strict)- Parameters:
strict
- if true, inputs will be validated against the SPDX spec
-
enterCriticalSection
public IModelStore.IModelStoreLock enterCriticalSection(boolean readLockRequested) throws InvalidSPDXAnalysisExceptionEnter a critical section. leaveCriticialSection must be called.- Parameters:
readLockRequested
- true implies a read lock, false implies write lock.- Throws:
InvalidSPDXAnalysisException
-
leaveCriticalSection
Leave a critical section. Releases the lock form the matching enterCriticalSection -
getPropertyValueNames
- Returns:
- all names of property values currently associated with this object
- Throws:
InvalidSPDXAnalysisException
-
getObjectPropertyValue
protected Optional<Object> getObjectPropertyValue(String propertyName) throws InvalidSPDXAnalysisExceptionGet an object value for a property- Parameters:
propertyName
- Name of the property- Returns:
- value associated with a property
- Throws:
InvalidSPDXAnalysisException
-
getObjectPropertyValue
protected static Optional<Object> getObjectPropertyValue(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName, ModelCopyManager copyManager) throws InvalidSPDXAnalysisExceptionGet an object value for a property- Parameters:
stModelStore
-stDocumentUri
-stId
-propertyName
-copyManager
- if non null, any ModelObject property value not stored in the stModelStore under the stDocumentUri will be copied to make it available- Returns:
- value associated with a property
- Throws:
InvalidSPDXAnalysisException
-
setPropertyValue
protected static void setPropertyValue(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName, @Nullable Object value, ModelCopyManager copyManager) throws InvalidSPDXAnalysisExceptionSet a property value for a property name, creating the property if necessary- Parameters:
stModelStore
- Model store for the propertiesstDocumentUri
- Unique document URIstId
- ID of the item to associate the property withpropertyName
- Name of the property associated with this objectvalue
- Value to associate with the propertycopyManager
- if non null, any ModelObject property value not stored in the stModelStore under the stDocumentUri will be copied to make it available- Throws:
InvalidSPDXAnalysisException
-
setPropertyValue
protected void setPropertyValue(String propertyName, @Nullable Object value) throws InvalidSPDXAnalysisExceptionSet a property value for a property name, creating the property if necessary- Parameters:
propertyName
- Name of the property associated with this objectvalue
- Value to associate with the property- Throws:
InvalidSPDXAnalysisException
-
updatePropertyValue
Create an update when, when applied by the ModelStore, sets a property value for a property name, creating the property if necessary- Parameters:
propertyName
- Name of the property associated with this objectvalue
- Value to associate with the property- Returns:
- an update which can be applied by invoking the apply method
-
getStringPropertyValue
protected Optional<String> getStringPropertyValue(String propertyName) throws InvalidSPDXAnalysisException- Parameters:
propertyName
- Name of a property- Returns:
- the Optional String value associated with a property, null if no value is present
- Throws:
SpdxInvalidTypeException
InvalidSPDXAnalysisException
-
getIntegerPropertyValue
protected Optional<Integer> getIntegerPropertyValue(String propertyName) throws InvalidSPDXAnalysisException- Parameters:
propertyName
- Name of a property- Returns:
- the Optional Integer value associated with a property, null if no value is present
- Throws:
InvalidSPDXAnalysisException
-
getEnumPropertyValue
protected Optional<Enum<?>> getEnumPropertyValue(String propertyName) throws InvalidSPDXAnalysisException- Throws:
InvalidSPDXAnalysisException
-
getBooleanPropertyValue
protected Optional<Boolean> getBooleanPropertyValue(String propertyName) throws InvalidSPDXAnalysisException- Parameters:
propertyName
- Name of the property- Returns:
- the Optional Boolean value for a property
- Throws:
SpdxInvalidTypeException
InvalidSPDXAnalysisException
-
getAnyLicenseInfoPropertyValue
protected Optional<AnyLicenseInfo> getAnyLicenseInfoPropertyValue(String propertyName) throws InvalidSPDXAnalysisExceptionConverts property values to an AnyLicenseInfo if possible - if NONE or NOASSERTION URI value, convert to the appropriate license- Parameters:
propertyName
-- Returns:
- AnyLicenseInfo
- Throws:
InvalidSPDXAnalysisException
-
getElementPropertyValue
protected Optional<SpdxElement> getElementPropertyValue(String propertyName) throws InvalidSPDXAnalysisExceptionConverts property values to an SpdxElement if possible - if NONE or NOASSERTION URI value, convert to the appropriate SpdxElement- Parameters:
propertyName
- name of the property- Returns:
- SpdxElement stored
- Throws:
InvalidSPDXAnalysisException
-
removeProperty
protected static void removeProperty(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName) throws InvalidSPDXAnalysisExceptionRemoves a property and its value from the model store if it exists- Parameters:
stModelStore
- Model store for the propertiesstDocumentUri
- Unique document URIstId
- ID of the item to associate the property withpropertyName
- Name of the property associated with this object to be removed- Throws:
InvalidSPDXAnalysisException
-
removeProperty
Removes a property and its value from the model store if it exists- Parameters:
propertyName
- Name of the property associated with this object to be removed- Throws:
InvalidSPDXAnalysisException
-
updateRemoveProperty
Create an update when, when applied by the ModelStore, removes a property and its value from the model store if it exists- Parameters:
propertyName
- Name of the property associated with this object to be removed- Returns:
- an update which can be applied by invoking the apply method
-
clearValueCollection
protected static void clearValueCollection(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName) throws InvalidSPDXAnalysisExceptionClears a collection of values associated with a property creating the property if it does not exist- Parameters:
stModelStore
- Model store for the propertiesstDocumentUri
- Unique document URIstId
- ID of the item to associate the property withpropertyName
- Name of the property- Throws:
InvalidSPDXAnalysisException
-
clearValueCollection
Clears a collection of values associated with a property- Parameters:
propertyName
- Name of the property- Throws:
InvalidSPDXAnalysisException
-
updateClearValueCollection
Create an update when, when applied by the ModelStore, clears a collection of values associated with a property- Parameters:
propertyName
- Name of the property- Returns:
- an update which can be applied by invoking the apply method
-
addValueToCollection
protected static void addValueToCollection(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName, Object value, ModelCopyManager copyManager) throws InvalidSPDXAnalysisExceptionAdd a value to a collection of values associated with a property. If a value is a ModelObject and does not belong to the document, it will be copied into the object store- Parameters:
stModelStore
- Model store for the propertiesstDocumentUri
- Unique document URIstId
- ID of the item to associate the property withpropertyName
- Name of the propertyvalue
- to addcopyManager
-- Throws:
InvalidSPDXAnalysisException
-
addPropertyValueToCollection
protected void addPropertyValueToCollection(String propertyName, Object value) throws InvalidSPDXAnalysisExceptionAdd a value to a collection of values associated with a property. If a value is a ModelObject and does not belong to the document, it will be copied into the object store- Parameters:
propertyName
- Name of the propertyvalue
- to add- Throws:
InvalidSPDXAnalysisException
-
updateAddPropertyValueToCollection
protected IModelStore.ModelUpdate updateAddPropertyValueToCollection(String propertyName, Object value)Create an update when, when applied, adds a value to a collection of values associated with a property. If a value is a ModelObject and does not belong to the document, it will be copied into the object store- Parameters:
propertyName
- Name of the propertyvalue
- to add- Returns:
- an update which can be applied by invoking the apply method
-
replacePropertyValueCollection
protected static void replacePropertyValueCollection(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName, Collection<?> values, ModelCopyManager copyManager) throws InvalidSPDXAnalysisExceptionReplace the entire value collection for a property. If a value is a ModelObject and does not belong to the document, it will be copied into the object store- Parameters:
stModelStore
- Model store for the propertiesstDocumentUri
- Unique document URIstId
- ID of the item to associate the property withpropertyName
- name of the propertyvalues
- collection of new propertiescopyManager
- if non-null, any ModelObject property value not stored in the stModelStore under the stDocumentUri will be copied to make it available- Throws:
InvalidSPDXAnalysisException
-
removePropertyValueFromCollection
protected static void removePropertyValueFromCollection(IModelStore stModelStore, String stDocumentUri, String stId, String propertyName, Object value) throws InvalidSPDXAnalysisExceptionRemove a property value from a collection- Parameters:
stModelStore
- Model store for the propertiesstDocumentUri
- Unique document URIstId
- ID of the item to associate the property withpropertyName
- name of the propertyvalue
- Value to be removed- Throws:
InvalidSPDXAnalysisException
-
removePropertyValueFromCollection
protected void removePropertyValueFromCollection(String propertyName, Object value) throws InvalidSPDXAnalysisExceptionRemove a property value from a collection- Parameters:
propertyName
- name of the propertyvalue
- Value to be removed- Throws:
InvalidSPDXAnalysisException
-
updateRemovePropertyValueFromCollection
protected IModelStore.ModelUpdate updateRemovePropertyValueFromCollection(String propertyName, Object value)Create an update when, when applied, removes a property value from a collection- Parameters:
propertyName
- name of the propertyvalue
- Value to be removed- Returns:
- an update which can be applied by invoking the apply method
-
getObjectPropertyValueSet
protected ModelSet<?> getObjectPropertyValueSet(String propertyName, Class<?> type) throws InvalidSPDXAnalysisException- Parameters:
propertyName
- Name of the property- Returns:
- Set of values associated with a property
- Throws:
InvalidSPDXAnalysisException
-
getObjectPropertyValueCollection
protected ModelCollection<?> getObjectPropertyValueCollection(String propertyName, Class<?> type) throws InvalidSPDXAnalysisException- Parameters:
propertyName
- Name of the property- Returns:
- Collection of values associated with a property
- Throws:
InvalidSPDXAnalysisException
-
getStringCollection
protected Collection<String> getStringCollection(String propertyName) throws InvalidSPDXAnalysisException- Parameters:
propertyName
- Name of property- Returns:
- Collection of Strings associated with the property
- Throws:
SpdxInvalidTypeException
InvalidSPDXAnalysisException
-
isCollectionMembersAssignableTo
protected boolean isCollectionMembersAssignableTo(String propertyName, Class<?> clazz) throws InvalidSPDXAnalysisException- Throws:
InvalidSPDXAnalysisException
-
equivalent
- Parameters:
compare
-- Returns:
- true if all the properties have the same or equivalent values
- Throws:
InvalidSPDXAnalysisException
-
equivalent
public boolean equivalent(ModelObject compare, boolean ignoreRelatedElements) throws InvalidSPDXAnalysisException- Parameters:
compare
-ignoreRelatedElements
- if true, do not compare properties relatedSpdxElement - used to prevent infinite recursion- Returns:
- true if all the properties have the same or equivalent values
- Throws:
InvalidSPDXAnalysisException
-
hashCode
public int hashCode() -
equals
-
clone
Clone a new object using a different model store- Parameters:
modelStore
-- Returns:
-
copyFrom
Copy all the properties from the source object- Parameters:
source
-- Throws:
InvalidSPDXAnalysisException
-
setCopyManager
-
getCopyManager
- Returns:
- the copy manager - value may be null if copies are not allowd
-
idToIdType
- Parameters:
id
- String for the object- Returns:
- type of the ID
-
toTypedValue
- Throws:
InvalidSPDXAnalysisException
-
verifyCollection
protected List<String> verifyCollection(Collection<? extends ModelObject> collection, String warningPrefix, List<String> verifiedIds)Verifies all elements in a collection- Parameters:
collection
- collection to be verifiesverifiedIds
- verifiedIds list of all Id's which have already been verifieds - prevents infinite recursionwarningPrefix
- String to prefix any warning messages
-
createAnnotation
public Annotation createAnnotation(String annotator, AnnotationType annotationType, String date, String comment) throws InvalidSPDXAnalysisException- Parameters:
annotator
- This field identifies the person, organization or tool that has commented on a file, package, or the entire document.annotationType
- This field describes the type of annotation. Annotations are usually created when someone reviews the file, and if this is the case the annotation type should be REVIEW. If the author wants to store extra information about one of the elements during creation, it is recommended to use the type of OTHER.date
- Identify when the comment was made. This is to be specified according to the combined date and time in the UTC format, as specified in the ISO 8601 standard.comment
-- Returns:
- Throws:
InvalidSPDXAnalysisException
-
createRelationship
public Relationship createRelationship(SpdxElement relatedElement, RelationshipType relationshipType, @Nullable String comment) throws InvalidSPDXAnalysisException- Parameters:
relatedElement
- The SPDX Element that is relatedrelationshipType
- Type of relationship - See the specification for a description of the typescomment
- optional comment for the relationship- Returns:
- Throws:
InvalidSPDXAnalysisException
-
createChecksum
public Checksum createChecksum(ChecksumAlgorithm algorithm, String value) throws InvalidSPDXAnalysisException- Parameters:
algorithm
- Checksum algorithmvalue
- Checksum value- Returns:
- Checksum using the same model store and document URI as this Model Object
- Throws:
InvalidSPDXAnalysisException
-
createPackageVerificationCode
public SpdxPackageVerificationCode createPackageVerificationCode(String value, Collection<String> excludedFileNames) throws InvalidSPDXAnalysisException- Parameters:
value
- Verification code calculated valueexcludedFileNames
- file names of files excluded from the verification code calculation- Returns:
- Package verification code using the same model store and document URI as this Model Object
- Throws:
InvalidSPDXAnalysisException
-
createExternalDocumentRef
public ExternalDocumentRef createExternalDocumentRef(String externalDocumentId, String externalDocumentUri, Checksum checksum) throws InvalidSPDXAnalysisException- Parameters:
externalDocumentUri
- Document URI for the external documentchecksum
- Checksum of the external DocumentexternalDocumentId
- ID to be used internally within this SPDX document- Returns:
- ExternalDocumentRef using the same model store and document URI as this Model Object
- Throws:
InvalidSPDXAnalysisException
-
createCreationInfo
public SpdxCreatorInformation createCreationInfo(List<String> creators, String date) throws InvalidSPDXAnalysisException- Parameters:
creators
- Creators Identify who (or what, in the case of a tool) created the SPDX file. If the SPDX file was created by an individual, indicate the person's name.date
- When the SPDX file was originally created. The date is to be specified according to combined date and time in UTC format as specified in ISO 8601 standard.- Returns:
- creationInfo using the same modelStore and documentUri as this object
- Throws:
InvalidSPDXAnalysisException
-
createExternalRef
public ExternalRef createExternalRef(ReferenceCategory category, ReferenceType referenceType, String locator, @Nullable String comment) throws InvalidSPDXAnalysisException- Parameters:
category
- Reference categoryreferenceType
- Reference typelocator
- Reference locatorcomment
- Optional comment- Returns:
- ExternalRef using the same modelStore and documentUri as this object
- Throws:
InvalidSPDXAnalysisException
-
createSpdxFile
public SpdxFile.SpdxFileBuilder createSpdxFile(String id, String name, AnyLicenseInfo concludedLicense, Collection<AnyLicenseInfo> seenLicense, String copyrightText, Checksum sha1) throws InvalidSPDXAnalysisExceptionCreate an SpdxFileBuilder with all of the required properties - the build() method will build the file- Parameters:
id
- - ID - must be an SPDX ID typename
- - File nameconcludedLicense
- license concludedseenLicense
- collection of seen licensescopyrightText
- Copyright textsha1
- Sha1 checksum- Returns:
- SPDX file using the same modelStore and documentUri as this object
- Throws:
InvalidSPDXAnalysisException
-
createPackage
public SpdxPackage.SpdxPackageBuilder createPackage(String id, String name, AnyLicenseInfo concludedLicense, String copyrightText, AnyLicenseInfo licenseDeclared)Create an SpdxPackageBuilder with all required fields for a filesAnalyzed=false using this objects model store and document URI- Parameters:
id
- - ID - must be an SPDX ID typename
- - File nameconcludedLicense
- license concludedcopyrightText
- Copyright textlicenseDeclared
- Declared license for the package- Returns:
- SpdxPackageBuilder with all required fields for a filesAnalyzed=false
-
createByteOffsetPointer
public ByteOffsetPointer createByteOffsetPointer(SpdxElement referencedElement, int offset) throws InvalidSPDXAnalysisException- Parameters:
referencedElement
-offset
-- Returns:
- ByteOffsetPointer using the same modelStore and documentUri as this object
- Throws:
InvalidSPDXAnalysisException
-
createLineCharPointer
public LineCharPointer createLineCharPointer(SpdxElement referencedElement, int lineNumber) throws InvalidSPDXAnalysisException- Parameters:
referencedElement
-lineNumber
-- Returns:
- LineCharPointer using the same modelStore and documentUri as this object
- Throws:
InvalidSPDXAnalysisException
-
createStartEndPointer
public StartEndPointer createStartEndPointer(SinglePointer startPointer, SinglePointer endPointer) throws InvalidSPDXAnalysisException- Parameters:
startPointer
-endPointer
-- Returns:
- StartEndPointer using the same modelStore and documentUri as this object
- Throws:
InvalidSPDXAnalysisException
-
createSpdxSnippet
public SpdxSnippet.SpdxSnippetBuilder createSpdxSnippet(String id, String name, AnyLicenseInfo concludedLicense, Collection<AnyLicenseInfo> seenLicense, String copyrightText, SpdxFile snippetFromFile, int startByte, int endByte) throws InvalidSPDXAnalysisExceptionCreate an SpdxSnippetBuilder with all of the required properties - the build() method will build the file- Parameters:
id
- - ID - must be an SPDX ID typename
- - File nameconcludedLicense
- license concludedseenLicense
- collection of seen licensescopyrightText
- Copyright textsnippetFromFile
- File where the snippet is locatedstartByte
- first byte of the snippet in the fileendByte
- last byte of the snippet in the file- Returns:
- SPDX snippet using the same modelStore and documentUri as this object
- Throws:
InvalidSPDXAnalysisException
-
createConjunctiveLicenseSet
public ConjunctiveLicenseSet createConjunctiveLicenseSet(Collection<AnyLicenseInfo> members) throws InvalidSPDXAnalysisException- Parameters:
members
-- Returns:
- ConjunctiveLicenseSet with default model store and document URI initialized with members
- Throws:
InvalidSPDXAnalysisException
-
createDisjunctiveLicenseSet
public DisjunctiveLicenseSet createDisjunctiveLicenseSet(Collection<AnyLicenseInfo> members) throws InvalidSPDXAnalysisException- Parameters:
members
-- Returns:
- DisjunctiveLicenseSet with default model store and document URI initialized with members
- Throws:
InvalidSPDXAnalysisException
-
createCrossRef
Create a CrossRef Builder with an Anonymous ID type using the same model store and document URI- Parameters:
url
- URL for the cross reference- Returns:
- a CrossRefBuilder which you can call
build()
on to build the CrossRef - Throws:
InvalidSPDXAnalysisException
-
toString
-