Class ExceptionJson


  • public class ExceptionJson
    extends Object
    Simple POJO to hold the license exception data loaded from a JSON file

    Licenses in the JSON format can be found at spdx.org/licenses/[exceptionid].json

    Author:
    Gary O'Neall
    • Field Detail

      • ALL_PROPERTY_DESCRIPTORS

        public static final List<org.spdx.storage.PropertyDescriptor> ALL_PROPERTY_DESCRIPTORS
        All property descriptors for Exceptions
      • PROPERTY_DESCRIPTOR_TO_VALUE_NAME

        public static final Map<org.spdx.storage.PropertyDescriptor,​String> PROPERTY_DESCRIPTOR_TO_VALUE_NAME
        Map of property descriptors to the value name
    • 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 name
        valueId - ID for the value
        type - SPDX type
        Throws:
        org.spdx.core.InvalidSpdxPropertyException - on invalid type for the SPDX property
      • setPrimativeValue

        public void setPrimativeValue​(org.spdx.storage.PropertyDescriptor propertyDescriptor,
                                      Object value)
                               throws org.spdx.core.InvalidSpdxPropertyException
        Parameters:
        propertyDescriptor - descriptor for the property to be set
        value - value to set
        Throws:
        org.spdx.core.InvalidSpdxPropertyException - on invalid property
      • clearPropertyValueList

        public void clearPropertyValueList​(org.spdx.storage.PropertyDescriptor propertyDescriptor)
                                    throws org.spdx.core.InvalidSpdxPropertyException
        Clears 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 property
        valueId - ID for the value
        type - 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 property
        value - 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.InvalidSpdxPropertyException
        Removes 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.InvalidSPDXAnalysisException
        Copies 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.InvalidSPDXAnalysisException
        Copies 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 property
        value - 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 property
        clazz - 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 boolean isCollectionMembersAssignableTo​(org.spdx.storage.PropertyDescriptor propertyDescriptor,
                                                       Class<?> clazz)
        Parameters:
        propertyDescriptor - descriptor for the property
        clazz - 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