Package org.spdx.storage.listedlicense
Class ExceptionJson
- java.lang.Object
-
- org.spdx.storage.listedlicense.ExceptionJson
-
public class ExceptionJson extends Object
Simple POJO to hold the license exception data loaded from a JSON fileLicenses in the JSON format can be found at spdx.org/licenses/[exceptionid].json
- Author:
- Gary O'Neall
-
-
Field Summary
Fields Modifier and Type Field Description static List<org.spdx.storage.PropertyDescriptor>ALL_PROPERTY_DESCRIPTORSAll property descriptors for Exceptionsstatic Map<org.spdx.storage.PropertyDescriptor,String>PROPERTY_DESCRIPTOR_TO_VALUE_NAMEMap of property descriptors to the value name
-
Constructor Summary
Constructors Constructor Description ExceptionJson()Create an ExceptionJsonExceptionJson(String id)Create an ExceptionJson
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddPrimitiveValueToList(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)voidaddValueToList(String propertyName, String valueId, String type)voidclearPropertyValueList(org.spdx.storage.PropertyDescriptor propertyDescriptor)Clears a list of values for a propertyvoidcopyFrom(org.spdx.library.model.v2.license.ListedLicenseException fromException)Copies from an SPDX version 2 exceptionvoidcopyFrom(org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException fromException)Copies all properties from an exceptionList<org.spdx.storage.PropertyDescriptor>getPropertyValueDescriptors()ObjectgetValue(org.spdx.storage.PropertyDescriptor propertyDescriptor)List<?>getValueList(org.spdx.storage.PropertyDescriptor propertyDescriptor)static booleanisCollectionMembersAssignableTo(org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz)booleanisCollectionProperty(org.spdx.storage.PropertyDescriptor propertyDescriptor)booleanisPropertyValueAssignableTo(org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz)booleanremovePrimitiveValueToList(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)voidremoveProperty(org.spdx.storage.PropertyDescriptor propertyDescriptor)Removes the propertyvoidsetPrimitiveValue(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)voidsetTypedProperty(String propertyName, String valueId, String type)
-
-
-
Field Detail
-
ALL_PROPERTY_DESCRIPTORS
public static final List<org.spdx.storage.PropertyDescriptor> ALL_PROPERTY_DESCRIPTORS
All property descriptors for Exceptions
-
-
Constructor Detail
-
ExceptionJson
public ExceptionJson(String id)
Create an ExceptionJson- Parameters:
id- license exception ID
-
ExceptionJson
public ExceptionJson()
Create an ExceptionJson
-
-
Method Detail
-
setTypedProperty
public void setTypedProperty(String propertyName, String valueId, String type) throws org.spdx.core.InvalidSpdxPropertyException
- Parameters:
propertyName- property namevalueId- ID for the valuetype- SPDX type- Throws:
org.spdx.core.InvalidSpdxPropertyException- on invalid type for the SPDX property
-
setPrimitiveValue
public void setPrimitiveValue(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSpdxPropertyException- Parameters:
propertyDescriptor- descriptor for the property to be setvalue- value to set- Throws:
org.spdx.core.InvalidSpdxPropertyException- on invalid property
-
clearPropertyValueList
public void clearPropertyValueList(org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSpdxPropertyExceptionClears a list of values for a property- Parameters:
propertyDescriptor- descriptor for the property- Throws:
org.spdx.core.InvalidSpdxPropertyException- if it is not a list type
-
addValueToList
public void addValueToList(String propertyName, String valueId, String type) throws org.spdx.core.InvalidSpdxPropertyException
- Parameters:
propertyName- Name of the propertyvalueId- ID for the valuetype- SPDX type- Throws:
org.spdx.core.InvalidSpdxPropertyException- on invalid type to add a value
-
addPrimitiveValueToList
public boolean addPrimitiveValueToList(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSpdxPropertyException- Parameters:
propertyDescriptor- descriptor for the propertyvalue- Value to set- Returns:
- true if the value was added
- Throws:
org.spdx.core.InvalidSpdxPropertyException- on SPDX parsing errors
-
getValueList
public List<?> getValueList(org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSpdxPropertyException
- Parameters:
propertyDescriptor- descriptor for the property- Returns:
- list of values associated with the property
- Throws:
org.spdx.core.InvalidSpdxPropertyException- if the propertyDescriptor is not for a list type
-
getValue
public Object getValue(org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSpdxPropertyException
- Parameters:
propertyDescriptor- descriptor for the property- Returns:
- Value associated with the property or null if no value was set
- Throws:
org.spdx.core.InvalidSpdxPropertyException- if the property descriptor is not valid
-
removeProperty
public void removeProperty(org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSpdxPropertyExceptionRemoves the property- Parameters:
propertyDescriptor- descriptor for the property- Throws:
org.spdx.core.InvalidSpdxPropertyException- if the property descriptor is not valid
-
copyFrom
public void copyFrom(org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException fromException) throws org.spdx.core.InvalidSPDXAnalysisExceptionCopies all properties from an exception- Parameters:
fromException- exception to copy from- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on error getting values from the exception
-
copyFrom
public void copyFrom(org.spdx.library.model.v2.license.ListedLicenseException fromException) throws org.spdx.core.InvalidSPDXAnalysisExceptionCopies from an SPDX version 2 exception- Parameters:
fromException- exception to copy from- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on error getting values from the exception
-
removePrimitiveValueToList
public boolean removePrimitiveValueToList(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSpdxPropertyException- Parameters:
propertyDescriptor- descriptor for the propertyvalue- value to remove- Returns:
- true if the collection was modified
- Throws:
org.spdx.core.InvalidSpdxPropertyException- if the propertyDescriptor is not valid
-
isPropertyValueAssignableTo
public boolean isPropertyValueAssignableTo(org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz) throws org.spdx.core.InvalidSpdxPropertyException- Parameters:
propertyDescriptor- descriptor for the propertyclazz- class to test assignability- Returns:
- true if the propertyDescriptor can be assigned a value of type clazz
- Throws:
org.spdx.core.InvalidSpdxPropertyException- if the propertyDescriptor is not valid
-
isCollectionMembersAssignableTo
public static boolean isCollectionMembersAssignableTo(org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz)- Parameters:
propertyDescriptor- descriptor for the propertyclazz- class to test assignability- Returns:
- true if the list associated with the propertyDescriptor have a value added of type clazz
-
isCollectionProperty
public boolean isCollectionProperty(org.spdx.storage.PropertyDescriptor propertyDescriptor)
- Parameters:
propertyDescriptor- descriptor for the property- Returns:
- true if the property represents a collection
-
getPropertyValueDescriptors
public List<org.spdx.storage.PropertyDescriptor> getPropertyValueDescriptors()
- Returns:
- all present property descriptors
-
-