Class LicenseExpressionParser

java.lang.Object
org.spdx.utility.license.LicenseExpressionParser

public class LicenseExpressionParser extends Object
A parser for the SPDX License Expressions as documented in the SPDX appendix

This is a static help class. The primary method is parseLicenseExpression which returns an AnyLicenseInfo.

Author:
Gary O'Neall
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo
    parseLicenseExpression(String expression, org.spdx.storage.IModelStore store, String customLicenseUriPrefix, org.spdx.library.model.v3_0_1.core.CreationInfo creationInfo, org.spdx.core.IModelCopyManager copyManager, List<org.spdx.library.model.v3_0_1.core.DictionaryEntry> customIdToUri)
    Parses a license expression into n license for use in the Model using the SPDX Version 3.X model
    static org.spdx.library.model.v2.license.AnyLicenseInfo
    parseLicenseExpressionCompatV2(String expression, org.spdx.storage.IModelStore store, String documentUri, org.spdx.core.IModelCopyManager copyManager)
    Parses a license expression into n license for use in the Model using the SPDX Version 2.X model

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • LicenseExpressionParser

      public LicenseExpressionParser()
  • Method Details

    • parseLicenseExpression

      public static org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo parseLicenseExpression(String expression, org.spdx.storage.IModelStore store, String customLicenseUriPrefix, org.spdx.library.model.v3_0_1.core.CreationInfo creationInfo, @Nullable org.spdx.core.IModelCopyManager copyManager, @Nullable List<org.spdx.library.model.v3_0_1.core.DictionaryEntry> customIdToUri) throws org.spdx.core.InvalidSPDXAnalysisException
      Parses a license expression into n license for use in the Model using the SPDX Version 3.X model
      Parameters:
      expression - Expression to be parsed
      store - Store containing any extractedLicenseInfos - if any extractedLicenseInfos by ID already exist, they will be used. If none exist for an ID, they will be added. If null, the default model store will be used.
      customLicenseUriPrefix - Prefix for Object URI's created when appending custom license ID's or custom license additions. If any custom licenses or additions already exist, they will be used. If none exist for an ID, they will be added. If null, the default model document URI will be used.
      creationInfo - Creation information to use for newly created elements
      copyManager - if non-null, allows for copying of any properties set which use other model stores or document URI's
      customIdToUri - Mapping of the id prefixes used in the license expression to the namespace preceding the external ID
      Returns:
      the parsed license expression
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - on SPDX parsing errors
    • parseLicenseExpressionCompatV2

      public static org.spdx.library.model.v2.license.AnyLicenseInfo parseLicenseExpressionCompatV2(String expression, org.spdx.storage.IModelStore store, String documentUri, org.spdx.core.IModelCopyManager copyManager) throws org.spdx.core.InvalidSPDXAnalysisException
      Parses a license expression into n license for use in the Model using the SPDX Version 2.X model
      Parameters:
      expression - Expression to be parsed
      store - Store containing any extractedLicenseInfos - if any extractedLicenseInfos by ID already exist, they will be used. If none exist for an ID, they will be added. If null, the default model store will be used.
      documentUri - Document URI for the document containing any extractedLicenseInfos - if any extractedLicenseInfos by ID already exist, they will be used. If none exist for an ID, they will be added. If null, the default model document URI will be used.
      copyManager - if non-null, allows for copying of any properties set which use other model stores or document URI's
      Returns:
      the parsed license expression
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - on SPDX parsing errors