Class 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
    • Constructor Detail

      • LicenseExpressionParser

        public LicenseExpressionParser()
    • Method Detail

      • parseLicenseExpression

        public static org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo parseLicenseExpression​(String expression,
                                                                                                          org.spdx.storage.IModelStore store,
                                                                                                          String customLicenseUriPrefix,
                                                                                                          @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 an 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.
        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
      • 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 an 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