diff --git a/pom.xml b/pom.xml
index 4a2dbfe..924c6cf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -96,17 +96,17 @@
org.spdx
java-spdx-library
- 1.1.6
+ 1.1.8-SNAPSHOT
org.spdx
spdx-rdf-store
- 1.1.6
+ 1.1.7-SNAPSHOT
org.spdx
spdx-jackson-store
- 1.1.6
+ 1.1.7-SNAPSHOT
org.apache.ws.xmlschema
@@ -116,18 +116,28 @@
org.spdx
spdx-spreadsheet-store
- 1.1.6
+ 1.1.7-SNAPSHOT
org.spdx
spdx-tagvalue-store
- 1.1.6
+ 1.1.7-SNAPSHOT
com.github.java-json-tools
json-schema-validator
2.2.14
+
+ org.apache.jena
+ jena-shacl
+ 4.8.0
+
+
+ com.github.spullara.mustache.java
+ compiler
+ 0.7.9
+
diff --git a/resources/javaTemplates/EnumTemplate.txt b/resources/javaTemplates/EnumTemplate.txt
new file mode 100644
index 0000000..3987d3c
--- /dev/null
+++ b/resources/javaTemplates/EnumTemplate.txt
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) {{{year}}} Source Auditor Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package {{{pkgName}}};
+
+{{{classComment}}}
+public enum {{{name}}} implements IndividualUriValue {
+
+ {{#enumValues}}
+ {{{.}}}
+ {{/enumValues}}
+
+ private String longName;
+
+ private {{{name}}}(String longName) {
+ this.longName = longName;
+ }
+
+ @Override
+ public String getIndividualURI() {
+ return getNameSpace() + "/" + getLongName();
+ }
+
+ public String getLongName() {
+ return longName;
+ }
+
+ public String getNameSpace() {
+ return "{{{classUri}}}";
+ }
diff --git a/resources/javaTemplates/ModelObjectTemplate.txt b/resources/javaTemplates/ModelObjectTemplate.txt
new file mode 100644
index 0000000..c80da7b
--- /dev/null
+++ b/resources/javaTemplates/ModelObjectTemplate.txt
@@ -0,0 +1,280 @@
+/**
+ * Copyright (c) {{{year}}} Source Auditor Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package {{{pkgName}}};
+
+{{#imports}}
+{{.}}
+{{/imports}}
+
+{{{classComments}}}
+public class {{{name}}} extends {{{superClass}}} {{#compareUsingProperties}}implements Comparable<{{{name}}}>{{/compareUsingProperties}} {
+
+ {{#objectPropertyValueCollection}}
+ TO BE IMPLEMENTED
+ {{/objectPropertyValueCollection}}
+ {{#stringCollection}}
+ TO BE IMPLEMENTED
+ {{/stringCollection}}
+ {{#objectPropertyValueSet}}
+ TO BE IMPLEMENTED
+ {{/objectPropertyValueSet}}
+
+ /**
+ * Create the {{{name}}} with default model store and generated anonymous ID
+ * @throws InvalidSPDXAnalysisException when unable to create the {{{name}}}
+ */
+ public {{{name}}}() throws InvalidSPDXAnalysisException {
+ super();
+ }
+
+ /**
+ * @param objectUri URI or anonymous ID for the {{{name}}}
+ * @throws InvalidSPDXAnalysisException when unable to create the {{{name}}}
+ */
+ public {{{name}}}(String objectUri) throws InvalidSPDXAnalysisException {
+ super(objectUri);
+ }
+
+ /**
+ * @param modelStore Model store where the {{{name}}} is to be stored
+ * @param objectUri URI or anonymous ID for the {{{name}}}
+ * @param copyManager Copy manager for the {{{name}}} - can be null if copying is not required
+ * @param create true if {{{name}}} is to be created
+ * @throws InvalidSPDXAnalysisException when unable to create the {{{name}}}
+ */
+ public {{{name}}}(IModelStore modelStore, String objectUri, ModelCopyManager copyManager,
+ boolean create) throws InvalidSPDXAnalysisException {
+ super(modelStore, objectUri, copyManager, create);
+ }
+
+ /* (non-Javadoc)
+ * @see org.spdx.library.model.ModelObject#getType()
+ */
+ @Override
+ public String getType() {
+ return {{{name}}};
+ }
+
+ /* (non-Javadoc)
+ * @see org.spdx.library.model.ModelObject#_verify(java.util.List)
+ */
+ @Override
+ protected List _verify(Set verifiedIds, String specVersion) {
+ List retval = new ArrayList<>();
+ {{#verifySuperclass}}
+ retval.addAll(super._verify(verifiedIds, specVersion);
+ {{/verifySuperclass}}
+ {{#elementProperties}}
+ Optional<{{{elementProperties.type}}}> {{{elementProperties.name}}};
+ try {
+ {{{elementProperties.name}}} = {{{elementProperties.getter}}};
+ if ({{{elementProperties.name}}}.isPresent()) {
+ retval.addAll({{{elementProperties.name}}}.get().verify(verifiedIds, specVersion));
+ {{#elementProperties.required}}
+ else {
+ if (getProfile() in {{{elementProperties.requiredProfiles}}}) {
+ retval.add("Missing {{{elementProperties.name}}} in {{{name}}}");
+ }
+ {{/elementProperties.required}}
+ }
+ } catch (InvalidSPDXAnalysisException e) {
+ retval.add("Error getting {{{elementProperties.name}}} for {{{name}}}: "+e.getMessage());
+ }
+ {{/elementProperties}}
+ {{#objectProperties}}
+ Optional<{{{objectProperties.type}}}> {{{objectProperties.name}}};
+ try {
+ {{{objectProperties.name}}} = {{{objectProperties.getter}}};
+ if ({{{objectProperties.name}}}.isPresent()) {
+ retval.addAll({{{objectProperties.name}}}.get().verify(verifiedIds, specVersion));
+ {{#objectProperties.required}}
+ else {
+ if (getProfile() in {{{objectProperties.requiredProfiles}}}) {
+ retval.add("Missing {{{objectProperties.name}}} in {{{name}}}");
+ }
+ {{/objectProperties.required}}
+ }
+ } catch (InvalidSPDXAnalysisException e) {
+ retval.add("Error getting {{{objectProperties.name}}} for {{{name}}}: "+e.getMessage());
+ }
+ {{/objectProperties}}
+ {{#anyLicenseInfoProperties}}
+ Optional<{{{anyLicenseInfoProperties.type}}}> {{{anyLicenseInfoProperties.name}}};
+ try {
+ {{{anyLicenseInfoProperties.name}}} = {{{anyLicenseInfoProperties.getter}}};
+ if ({{{anyLicenseInfoProperties.name}}}.isPresent()) {
+ retval.addAll({{{anyLicenseInfoProperties.name}}}.get().verify(verifiedIds, specVersion));
+ {{#anyLicenseInfoProperties.required}}
+ else {
+ if (getProfile() in {{{anyLicenseInfoProperties.requiredProfiles}}}) {
+ retval.add("Missing {{{anyLicenseInfoProperties.name}}} in {{{name}}}");
+ }
+ {{/anyLicenseInfoProperties.required}}
+ }
+ } catch (InvalidSPDXAnalysisException e) {
+ retval.add("Error getting {{{anyLicenseInfoProperties.name}}} for {{{name}}}: "+e.getMessage());
+ }
+ {{/anyLicenseInfoProperties}}
+ {{#enumerationProperties}}
+ try {
+ Optional<{{{enumerationProperties.type}}}> {{{enumerationProperties.name}}} = {{{enumerationProperties.getter}}};
+ {{#enumerationProperties.required}}
+ if (!{{{enumerationProperties.name}}}.isPresent()) {
+ retval.add("Missing {{{enumerationProperties.name}}} in {{{name}}}");
+ }
+ {{/enumerationProperties.required}}
+ } catch (InvalidSPDXAnalysisException e) {
+ retval.add("Error getting {{{enumerationProperties.name}}} for {{{name}}}: "+e.getMessage());
+ }
+ {{/enumerationProperties}}
+ {{#booleanProperties}}
+ try {
+ Optional<{{{booleanProperties.type}}}> {{{booleanProperties.name}}} = {{{booleanProperties.getter}}};
+ {{#booleanProperties.required}}
+ if (!{{{booleanProperties.name}}}.isPresent()) {
+ retval.add("Missing {{{booleanProperties.name}}} in {{{name}}}");
+ }
+ {{/booleanProperties.required}}
+ } catch (InvalidSPDXAnalysisException e) {
+ retval.add("Error getting {{{booleanProperties.name}}} for {{{name}}}: "+e.getMessage());
+ }
+ {{/booleanProperties}}
+ {{#integerProperties}}
+ try {
+ Optional<{{{integerProperties.type}}}> {{{integerProperties.name}}} = {{{integerProperties.getter}}};
+ {{#integerProperties.required}}
+ if (!{{{integerProperties.name}}}.isPresent()) {
+ retval.add("Missing {{{integerProperties.name}}} in {{{name}}}");
+ }
+ {{/integerProperties.required}}
+ {{#integerProperties.min}}
+ TODO Implement
+ {{/integerProperties.min}}
+ {{#integerProperties.max}}
+ TODO Implement
+ {{/integerProperties.max}}
+ } catch (InvalidSPDXAnalysisException e) {
+ retval.add("Error getting {{{integerProperties.name}}} for {{{name}}}: "+e.getMessage());
+ }
+ {{/integerProperties}}
+ {{#stringProperties}}
+ try {
+ Optional<{{{stringProperties.type}}}> {{{stringProperties.name}}} = {{{stringProperties.getter}}};
+ {{#stringProperties.required}}
+ if (!{{{stringProperties.name}}}.isPresent()) {
+ retval.add("Missing {{{stringProperties.name}}} in {{{name}}}");
+ }
+ {{/stringProperties.required}}
+ {{#stringProperties.pattern}}
+ TODO: Implement Pattern.compile etc
+ {{/stringProperties.pattern}}
+ } catch (InvalidSPDXAnalysisException e) {
+ retval.add("Error getting {{{stringProperties.name}}} for {{{name}}}: "+e.getMessage());
+ }
+ {{/stringProperties}}
+
+
+ {{#objectPropertyValueCollection}}
+ TO BE IMPLEMENTED
+ {{/objectPropertyValueCollection}}
+ {{#stringCollection}}
+ TO BE IMPLEMENTED
+ {{/stringCollection}}
+ {{#objectPropertyValueSet}}
+ TO BE IMPLEMENTED
+ {{/objectPropertyValueSet}}
+ return retval;
+ }
+
+ // Getters and Setters
+ {{#objectPropertyValueCollection}}
+ TO BE IMPLEMENTED
+ {{/objectPropertyValueCollection}}
+ {{#stringCollection}}
+ TO BE IMPLEMENTED
+ {{/stringCollection}}
+ {{#objectPropertyValueSet}}
+ TO BE IMPLEMENTED
+ {{/objectPropertyValueSet}}
+
+
+ {{#elementProperties}}
+ /**
+ * @return the {{{elementProperties.name}}}
+ */
+ public Optional<{{{elementProperties.type}}}> {{{elementProperties.getter}}} throws InvalidSPDXAnalysisException {
+ return getElementPropertyValue({{{elementProperties.propertyConstant}}});
+ }
+
+ /**
+ * @param {{{elementProperties.name}}} the {{{elementProperties.name}}} to set
+ * @return this to chain setters
+ * @throws InvalidSPDXAnalysisException
+ */
+ public {{{name}}} {{{elementProperties.setter}}}({{{elementProperties.type}}} {{{elementProperties.name}}}) throws InvalidSPDXAnalysisException {
+ setPropertyValue({{{elementProperties.uri}}}, {{{elementProperties.propertyConstant}}});
+ return this;
+ }
+ {{/elementProperties}}
+
+ {{#compareUsingProperties}}
+ /* (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo({{{name}}} o) {
+ int retval = 0;
+ {{#compareProperties}}
+ Optional<{{{compareWithProperties.type}}}> my{{{compareWithProperties.name}}} = {{{compareWithProperties.getter}}};
+ Optional<{{{compareWithProperties.type}}}> compare{{{compareWithProperties.name}}} = o.{{{compareWithProperties.getter}}};
+ retval = compareOptional(my{{{compareWithProperties.name}}}, compare{{{compareWithProperties.name}}});
+ if (retval != 0) {
+ return retval;
+ }
+ {{/compareProperties}}
+ return retval;
+ }
+ {{/compareUsingProperties}}
+
+ @Override
+ public String toString() {
+ {{^usePropertiesForToString}}
+ return "{{{name}}}: "+getObjectUri();
+ {{/usePropertiesForToString}}
+ {{#usePropertiesForToString}}
+ try {
+ StringBuilder sb = new StringBuilder();
+ {{#toStringProperties}}
+ Optional<{{{toStringProperties.type}}}> {{{toStringProperties.name}}} = {{{toStringProperties.getter}}};
+ if ({{{toStringProperties.name}}}.isPresent()) {
+ sb.append({{{toStringProperties.name}}}.get().toString());
+ } else {
+ sb.append("{{{toStringProperties.type}}}-Missing");
+ }
+ sb.append(" ");
+ {{/toStringProperties}}
+ sb.setLenght(sb.length() == 0 ? 0 : sb.length()-1);
+ return sb.toString();
+ } catch (InvalidSPDXAnalysisException e) {
+ logger.error("Error in toString: ",e);
+ return "Error: "+e.getMessage();
+ }
+ {{/usePropertiesForToString}}
+ }
+}
diff --git a/resources/javaTemplates/SpdxConstants.txt b/resources/javaTemplates/SpdxConstants.txt
new file mode 100644
index 0000000..a95bca7
--- /dev/null
+++ b/resources/javaTemplates/SpdxConstants.txt
@@ -0,0 +1,460 @@
+/**
+ * Copyright (c) 2023 Source Auditor Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.spdx.library;
+
+import org.spdx.storage.PropertyDescriptor;
+
+/**
+ * Constants which map to the SPDX specifications
+ * @author Gary O'Neall
+ *
+ */
+public class SpdxConstants {
+
+ public enum SpdxMajorVersion {
+ VERSION_1,
+ VERSION_2,
+ VERSION_3;
+
+ public static SpdxMajorVersion latestVersion() {
+ return VERSION_3;
+ }
+ }
+
+ /**
+ * Core namespace
+ */
+ public static final String CORE_NAMESPACE = "https://rdf.spdx.org/v3/Core";
+ public static final PropertyDescriptor CORE_PROP_RELATED_SPDX_ELEMENT = new PropertyDescriptor("to", CORE_NAMESPACE);
+
+}
+
+
+/**
+ * Copyright (c) 2011 Source Auditor Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.spdx.library;
+
+import java.util.regex.Pattern;
+
+import org.spdx.storage.PropertyDescriptor;
+
+
+/**
+ * Constants which map to the SPDX specifications for versions prior to SPDX Spec version 3.0
+ * @author Gary O'Neall
+ *
+ */
+public class SpdxConstantsCompatV2 {
+
+ public static final String SPDX_VERSION_2 = "2";
+
+ // Namespaces
+ public static final String RDF_NAMESPACE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+ public static final String RDFS_NAMESPACE = "http://www.w3.org/2000/01/rdf-schema#";
+ public static final String SPDX_NAMESPACE = "http://spdx.org/rdf/terms#";
+ public static final String DOAP_NAMESPACE = "http://usefulinc.com/ns/doap#";
+ public static final String OWL_NAMESPACE = "http://www.w3.org/2002/07/owl#";
+ public static final String RDF_POINTER_NAMESPACE = "http://www.w3.org/2009/pointers#";
+ public static final String XML_SCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema#";
+
+ // RDF Properties - within the RDF_NAMESPACE
+ public static final PropertyDescriptor RDF_PROP_TYPE = new PropertyDescriptor("type", RDF_NAMESPACE);
+ public static final PropertyDescriptor RDF_PROP_RESOURCE = new PropertyDescriptor("resource", RDF_NAMESPACE);
+ public static final String[] RDF_PROPERTIES = new String[] {RDF_PROP_TYPE.getName(), RDF_PROP_RESOURCE.getName()};
+
+
+ // OWL Properties - within the OWL_NAMESPACE
+ public static final PropertyDescriptor PROP_OWL_SAME_AS = new PropertyDescriptor("sameAs", OWL_NAMESPACE);
+ public static final String[] OWL_PROPERTIES = new String[] {PROP_OWL_SAME_AS.getName()};
+
+ // RDFS Properties - within the RDFS_NAMESPACE
+ public static final PropertyDescriptor RDFS_PROP_COMMENT = new PropertyDescriptor("comment", RDFS_NAMESPACE);
+ public static final PropertyDescriptor RDFS_PROP_LABEL = new PropertyDescriptor("label", RDFS_NAMESPACE);
+ public static final PropertyDescriptor RDFS_PROP_SEE_ALSO = new PropertyDescriptor("seeAlso", RDFS_NAMESPACE);
+ public static final String[] RDFS_PROPERTIES = new String[] {RDFS_PROP_COMMENT.getName(),
+ RDFS_PROP_LABEL.getName(), RDFS_PROP_SEE_ALSO.getName()};
+
+ // DOAP Class Names - within the DOAP_NAMESPACE
+ public static final String CLASS_DOAP_PROJECT = "Project";
+ public static final String[] DOAP_CLASSES = {CLASS_DOAP_PROJECT};
+
+ // DOAP Project Property Names - within the DOAP_NAMESPACE
+ public static final PropertyDescriptor PROP_PROJECT_HOMEPAGE = new PropertyDescriptor("homepage", DOAP_NAMESPACE);
+ public static final String[] DOAP_PROPERTIES = new String[] {PROP_PROJECT_HOMEPAGE.getName()};
+
+ // Pointer Class Names - with in the RDF_POINTER_NAMESPACE
+ public static final String CLASS_POINTER_START_END_POINTER = "StartEndPointer";
+ public static final String CLASS_POINTER_BYTE_OFFSET_POINTER = "ByteOffsetPointer";
+ public static final String CLASS_POINTER_LINE_CHAR_POINTER = "LineCharPointer";
+ public static final String CLASS_POINTER_COMPOUNT_POINTER = "CompoundPointer";
+ public static final String CLASS_SINGLE_POINTER = "SinglePointer";
+ public static final String[] POINTER_CLASSES = new String[] {
+ CLASS_POINTER_START_END_POINTER, CLASS_POINTER_BYTE_OFFSET_POINTER,
+ CLASS_POINTER_LINE_CHAR_POINTER, CLASS_POINTER_COMPOUNT_POINTER, CLASS_SINGLE_POINTER
+ };
+
+ // Pointer Properties - with in the RDF_POINTER_NAMESPACE
+ public static final PropertyDescriptor PROP_POINTER_START_POINTER = new PropertyDescriptor("startPointer", RDF_POINTER_NAMESPACE);
+ public static final PropertyDescriptor PROP_POINTER_END_POINTER = new PropertyDescriptor("endPointer", RDF_POINTER_NAMESPACE);
+ public static final PropertyDescriptor PROP_POINTER_REFERENCE = new PropertyDescriptor("reference", RDF_POINTER_NAMESPACE);
+ public static final PropertyDescriptor PROP_POINTER_OFFSET = new PropertyDescriptor("offset", RDF_POINTER_NAMESPACE);
+ public static final PropertyDescriptor PROP_POINTER_LINE_NUMBER = new PropertyDescriptor("lineNumber", RDF_POINTER_NAMESPACE);
+ public static final String[] POINTER_PROPERTIES = new String[] {
+ PROP_POINTER_START_POINTER.getName(), PROP_POINTER_END_POINTER.getName(),
+ PROP_POINTER_REFERENCE.getName(), PROP_POINTER_OFFSET.getName(),
+ PROP_POINTER_LINE_NUMBER.getName()
+ };
+
+ // SPDX Class Names
+ public static final String CLASS_SPDX_DOCUMENT = "SpdxDocument";
+ public static final String CLASS_SPDX_PACKAGE = "Package";
+ public static final String CLASS_SPDX_CREATION_INFO = "CreationInfo";
+ public static final String CLASS_SPDX_CHECKSUM = "Checksum";
+ public static final String CLASS_SPDX_ANY_LICENSE_INFO = "AnyLicenseInfo";
+ public static final String CLASS_SPDX_SIMPLE_LICENSE_INFO = "SimpleLicensingInfo";
+ public static final String CLASS_SPDX_CONJUNCTIVE_LICENSE_SET = "ConjunctiveLicenseSet";
+ public static final String CLASS_SPDX_DISJUNCTIVE_LICENSE_SET = "DisjunctiveLicenseSet";
+ public static final String CLASS_SPDX_EXTRACTED_LICENSING_INFO = "ExtractedLicensingInfo";
+ public static final String CLASS_SPDX_LICENSE = "License";
+ public static final String CLASS_SPDX_LISTED_LICENSE = "ListedLicense";
+ public static final String CLASS_SPDX_LICENSE_EXCEPTION = "LicenseException";
+ public static final String CLASS_SPDX_LISTED_LICENSE_EXCEPTION = "ListedLicenseException";
+ public static final String CLASS_OR_LATER_OPERATOR = "OrLaterOperator";
+ public static final String CLASS_WITH_EXCEPTION_OPERATOR = "WithExceptionOperator";
+ public static final String CLASS_SPDX_FILE = "File";
+ public static final String CLASS_SPDX_REVIEW = "Review";
+ public static final String CLASS_SPDX_VERIFICATIONCODE = "PackageVerificationCode";
+ public static final String CLASS_ANNOTATION = "Annotation";
+ public static final String CLASS_RELATIONSHIP = "Relationship";
+ public static final String CLASS_SPDX_ITEM = "SpdxItem";
+ public static final String CLASS_SPDX_ELEMENT = "SpdxElement";
+ public static final String CLASS_SPDX_NONE_ELEMENT = "SpdxNoneElement";
+ public static final String CLASS_SPDX_NOASSERTION_ELEMENT = "SpdxNoAssertionElement";
+ public static final String CLASS_EXTERNAL_DOC_REF = "ExternalDocumentRef";
+ public static final String CLASS_SPDX_EXTERNAL_REFERENCE = "ExternalRef";
+ public static final String CLASS_SPDX_REFERENCE_TYPE = "ReferenceType";
+ public static final String CLASS_SPDX_SNIPPET = "Snippet";
+ public static final String CLASS_NONE_LICENSE = "SpdxNoneLicense";
+ public static final String CLASS_NOASSERTION_LICENSE = "SpdxNoAssertionLicense";
+ public static final String CLASS_EXTERNAL_SPDX_ELEMENT = "ExternalSpdxElement";
+ public static final String CLASS_EXTERNAL_EXTRACTED_LICENSE = "ExternalExtractedLicenseInfo";
+ public static final String CLASS_CROSS_REF = "CrossRef";
+
+ // all classes used including classes in non-SPDX namespaces
+ public static final String[] ALL_SPDX_CLASSES = {CLASS_SPDX_DOCUMENT, CLASS_SPDX_PACKAGE,
+ CLASS_SPDX_CREATION_INFO, CLASS_SPDX_CHECKSUM, CLASS_SPDX_ANY_LICENSE_INFO,
+ CLASS_SPDX_SIMPLE_LICENSE_INFO, CLASS_SPDX_CONJUNCTIVE_LICENSE_SET, CLASS_SPDX_DISJUNCTIVE_LICENSE_SET,
+ CLASS_SPDX_EXTRACTED_LICENSING_INFO, CLASS_SPDX_LICENSE, CLASS_SPDX_LISTED_LICENSE,
+ CLASS_SPDX_LICENSE_EXCEPTION, CLASS_SPDX_LISTED_LICENSE_EXCEPTION, CLASS_OR_LATER_OPERATOR, CLASS_WITH_EXCEPTION_OPERATOR,
+ CLASS_SPDX_FILE, CLASS_SPDX_REVIEW, CLASS_SPDX_VERIFICATIONCODE, CLASS_ANNOTATION,
+ CLASS_RELATIONSHIP, CLASS_SPDX_ITEM, CLASS_SPDX_ELEMENT,
+ CLASS_SPDX_NONE_ELEMENT, CLASS_SPDX_NOASSERTION_ELEMENT, CLASS_EXTERNAL_DOC_REF,
+ CLASS_SPDX_EXTERNAL_REFERENCE, CLASS_SPDX_REFERENCE_TYPE, CLASS_SPDX_SNIPPET,
+ CLASS_NONE_LICENSE, CLASS_NOASSERTION_LICENSE, CLASS_EXTERNAL_SPDX_ELEMENT,
+ CLASS_EXTERNAL_EXTRACTED_LICENSE, CLASS_CROSS_REF,
+ // DOAP Namespace
+ CLASS_DOAP_PROJECT,
+ // RDF Pointer Namespace
+ CLASS_POINTER_START_END_POINTER, CLASS_POINTER_BYTE_OFFSET_POINTER,
+ CLASS_POINTER_COMPOUNT_POINTER, CLASS_POINTER_LINE_CHAR_POINTER, CLASS_SINGLE_POINTER};
+
+ // classes that use the listed license URI for their namespace
+ public static final String[] LISTED_LICENSE_URI_CLASSES = {CLASS_SPDX_LISTED_LICENSE, CLASS_SPDX_LISTED_LICENSE_EXCEPTION};
+
+ // Enumeration class names
+ public static final String ENUM_FILE_TYPE = "FileType";
+ public static final String ENUM_ANNOTATION_TYPE = "AnnotationType";
+ public static final String ENUM_CHECKSUM_ALGORITHM_TYPE = "ChecksumAlgorithm";
+ public static final String ENUM_REFERENCE_CATEGORY_TYPE = "ReferenceCategory";
+ public static final String ENUM_REFERENCE_RELATIONSHIP_TYPE = "RelationshipType";
+ public static final String ENUM_PURPOSE = "Purpose";
+ // General SPDX Properties
+ public static final PropertyDescriptor PROP_VALUE_NONE = new PropertyDescriptor("none", SPDX_NAMESPACE);
+ public static final String URI_VALUE_NONE = PROP_VALUE_NONE.toString();
+ public static final PropertyDescriptor PROP_VALUE_NOASSERTION = new PropertyDescriptor("noassertion", SPDX_NAMESPACE);
+ public static final String URI_VALUE_NOASSERTION = PROP_VALUE_NOASSERTION.toString();
+ public static final String SPDX_IDENTIFIER = "SPDXID";
+ public static final String EXTERNAL_DOCUMENT_REF_IDENTIFIER = "externalDocumentId";
+
+ // SPDX Document Properties
+ // The comment property is the RDFS_PROP_COMMENT property in the rdfs namespace
+ public static final PropertyDescriptor PROP_SPDX_REVIEWED_BY = new PropertyDescriptor("reviewed", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_SPDX_EXTRACTED_LICENSES = new PropertyDescriptor("hasExtractedLicensingInfo", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_SPDX_VERSION = new PropertyDescriptor("specVersion", SPDX_NAMESPACE); // TODO: Migrate this to PROP_SPDX_SPEC_VERSION in 3.0. See issue
+ public static final PropertyDescriptor PROP_SPDX_SPEC_VERSION = new PropertyDescriptor("spdxVersion", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_SPDX_CREATION_INFO = new PropertyDescriptor("creationInfo", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_SPDX_PACKAGE = new PropertyDescriptor("describesPackage", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_SPDX_DATA_LICENSE = new PropertyDescriptor("dataLicense", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_SPDX_EXTERNAL_DOC_REF = new PropertyDescriptor("externalDocumentRef", SPDX_NAMESPACE);
+ public static final String SPDX_DOCUMENT_ID = "SPDXRef-DOCUMENT";
+ public static final PropertyDescriptor PROP_DOCUMENT_NAMESPACE = new PropertyDescriptor("documentNamespace", SPDX_NAMESPACE);
+
+ // SPDX Document properties for JSON and YAML files
+ public static final PropertyDescriptor PROP_DOCUMENT_DESCRIBES = new PropertyDescriptor("documentDescribes", SPDX_NAMESPACE); //TODO: This is not yet approved in the spec - see issue #
+ public static final PropertyDescriptor PROP_DOCUMENT_FILES = new PropertyDescriptor("files", SPDX_NAMESPACE); //TODO: This is not yet approved in the spec - see issue #
+ public static final PropertyDescriptor PROP_DOCUMENT_PACKAGES = new PropertyDescriptor("packages", SPDX_NAMESPACE); //TODO: This is not yet approved in the spec - see issue #
+ public static final PropertyDescriptor PROP_DOCUMENT_SNIPPETS = new PropertyDescriptor("snippets", SPDX_NAMESPACE); //TODO: This is not yet approved in the spec - see issue #
+ public static final PropertyDescriptor PROP_DOCUMENT_RELATIONSHIPS = new PropertyDescriptor("relationships", SPDX_NAMESPACE); //TODO: This is not yet approved in the spec - see issue #
+
+ // SPDX CreationInfo Properties
+ // The comment property is the RDFS_PROP_COMMENT property in the rdfs namespace
+ public static final PropertyDescriptor PROP_CREATION_CREATOR = new PropertyDescriptor("creator", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_CREATION_CREATED = new PropertyDescriptor("created", SPDX_NAMESPACE); // creation timestamp
+ public static final PropertyDescriptor PROP_LICENSE_LIST_VERSION = new PropertyDescriptor("licenseListVersion", SPDX_NAMESPACE);
+ public static final String CREATOR_PREFIX_PERSON = "Person:";
+ public static final String CREATOR_PREFIX_ORGANIZATION = "Organization:";
+ public static final String CREATOR_PREFIX_TOOL = "Tool:";
+
+ // SPDX Checksum Properties
+ public static final PropertyDescriptor PROP_CHECKSUM_ALGORITHM = new PropertyDescriptor("algorithm", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_CHECKSUM_VALUE = new PropertyDescriptor("checksumValue", SPDX_NAMESPACE);
+ public static final String ALGORITHM_SHA1 = "SHA1";
+ public static final String PROP_CHECKSUM_ALGORITHM_SHA1 = "checksumAlgorithm_sha1";
+
+ // SPDX PackageVerificationCode Properties
+ public static final PropertyDescriptor PROP_VERIFICATIONCODE_IGNORED_FILES = new PropertyDescriptor("packageVerificationCodeExcludedFile", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_VERIFICATIONCODE_VALUE = new PropertyDescriptor("packageVerificationCodeValue", SPDX_NAMESPACE);
+
+ // SPDX Element Properties
+ public static final PropertyDescriptor PROP_ANNOTATION = new PropertyDescriptor("annotation", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_RELATIONSHIP = new PropertyDescriptor("relationship", SPDX_NAMESPACE);
+
+ // SPDX Item Properties
+ public static final PropertyDescriptor PROP_LICENSE_CONCLUDED = new PropertyDescriptor("licenseConcluded", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_COPYRIGHT_TEXT = new PropertyDescriptor("copyrightText", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_LIC_COMMENTS = new PropertyDescriptor("licenseComments", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_LICENSE_DECLARED = new PropertyDescriptor("licenseDeclared", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_ATTRIBUTION_TEXT = new PropertyDescriptor("attributionText", SPDX_NAMESPACE);
+
+ // SPDX Package Properties
+ public static final PropertyDescriptor PROP_PACKAGE_DECLARED_NAME = new PropertyDescriptor("name", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_FILE_NAME = new PropertyDescriptor("packageFileName", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_CHECKSUM = new PropertyDescriptor("checksum", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_DOWNLOAD_URL = new PropertyDescriptor("downloadLocation", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_SOURCE_INFO = new PropertyDescriptor("sourceInfo", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_DECLARED_LICENSE = new PropertyDescriptor("licenseDeclared", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_CONCLUDED_LICENSE = PROP_LICENSE_CONCLUDED;
+ public static final PropertyDescriptor PROP_PACKAGE_DECLARED_COPYRIGHT = PROP_COPYRIGHT_TEXT;
+ public static final PropertyDescriptor PROP_PACKAGE_SHORT_DESC = new PropertyDescriptor("summary", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_DESCRIPTION = new PropertyDescriptor("description", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_FILE = new PropertyDescriptor("hasFile", SPDX_NAMESPACE);;
+ public static final PropertyDescriptor PROP_PACKAGE_VERIFICATION_CODE = new PropertyDescriptor("packageVerificationCode", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_LICENSE_INFO_FROM_FILES = new PropertyDescriptor("licenseInfoFromFiles", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_LICENSE_COMMENT = new PropertyDescriptor("licenseComments", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_VERSION_INFO = new PropertyDescriptor("versionInfo", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_ORIGINATOR = new PropertyDescriptor("originator", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_SUPPLIER = new PropertyDescriptor("supplier", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PACKAGE_FILES_ANALYZED = new PropertyDescriptor("filesAnalyzed", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_EXTERNAL_REF = new PropertyDescriptor("externalRef", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_PRIMARY_PACKAGE_PURPOSE = new PropertyDescriptor("primaryPackagePurpose", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_BUILT_DATE = new PropertyDescriptor("builtDate", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_RELEASE_DATE = new PropertyDescriptor("releaseDate", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_VALID_UNTIL_DATE = new PropertyDescriptor("validUntilDate", SPDX_NAMESPACE);
+ public static final Pattern REFERENCE_TYPE_URI_PATTERN = Pattern.compile("https?://spdx.org/rdf/references/.+");
+
+ // SPDX License Properties
+ // The comment property is the RDFS_PROP_COMMENT property in the rdfs namespace
+ // the seeAlso property is in the RDFS_PROP_SEE_ALSO property in the rdfs namespace
+ public static final PropertyDescriptor PROP_LICENSE_ID = new PropertyDescriptor("licenseId", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_LICENSE_TEXT = new PropertyDescriptor("licenseText", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_LICENSE_TEXT_HTML = new PropertyDescriptor("licenseTextHtml", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_EXTRACTED_TEXT = new PropertyDescriptor("extractedText", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_LICENSE_NAME = new PropertyDescriptor("licenseName", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_STD_LICENSE_NAME_VERSION_1 = new PropertyDescriptor("licenseName", SPDX_NAMESPACE); // old property name (pre 1.1 spec)
+ public static final PropertyDescriptor PROP_STD_LICENSE_NAME = new PropertyDescriptor("name", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_STD_LICENSE_URL_VERSION_1 = new PropertyDescriptor("licenseSourceUrl", SPDX_NAMESPACE); // This has been replaced with the rdfs:seeAlso property
+ public static final PropertyDescriptor PROP_STD_LICENSE_NOTES_VERSION_1 = new PropertyDescriptor("licenseNotes", SPDX_NAMESPACE); // old property name (pre 1.1 spec)
+ public static final PropertyDescriptor PROP_STD_LICENSE_HEADER_VERSION_1 = new PropertyDescriptor("licenseHeader", SPDX_NAMESPACE); // old property name (pre 1.1 spec)
+ public static final PropertyDescriptor PROP_STD_LICENSE_NOTICE = new PropertyDescriptor("standardLicenseHeader", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_STD_LICENSE_HEADER_TEMPLATE = new PropertyDescriptor("standardLicenseHeaderTemplate", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_LICENSE_HEADER_HTML = new PropertyDescriptor("standardLicenseHeaderHtml", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_STD_LICENSE_TEMPLATE_VERSION_1 = new PropertyDescriptor("licenseTemplate", SPDX_NAMESPACE); // old property name (pre 1.2 spec)
+ public static final PropertyDescriptor PROP_STD_LICENSE_TEMPLATE = new PropertyDescriptor("standardLicenseTemplate", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_STD_LICENSE_OSI_APPROVED = new PropertyDescriptor("isOsiApproved", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_STD_LICENSE_FSF_LIBRE = new PropertyDescriptor("isFsfLibre", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_STD_LICENSE_OSI_APPROVED_VERSION_1 = new PropertyDescriptor("licenseOsiApproved", SPDX_NAMESPACE); // old property name (pre 1.1 spec)
+ public static final PropertyDescriptor PROP_LICENSE_SET_MEMEBER = new PropertyDescriptor("member", SPDX_NAMESPACE);
+ public static final String TERM_LICENSE_NOASSERTION = PROP_VALUE_NOASSERTION.getName();
+ public static final String TERM_LICENSE_NONE = PROP_VALUE_NONE.getName();
+ public static final PropertyDescriptor PROP_LICENSE_EXCEPTION_ID = new PropertyDescriptor("licenseExceptionId", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_EXAMPLE = new PropertyDescriptor("example", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_EXCEPTION_TEXT = new PropertyDescriptor("licenseExceptionText", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_EXCEPTION_TEXT_HTML = new PropertyDescriptor("exceptionTextHtml", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_EXCEPTION_TEMPLATE = new PropertyDescriptor("licenseExceptionTemplate", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_LICENSE_EXCEPTION = new PropertyDescriptor("licenseException", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_LIC_ID_DEPRECATED = new PropertyDescriptor("isDeprecatedLicenseId", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_LIC_DEPRECATED_VERSION = new PropertyDescriptor("deprecatedVersion", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_CROSS_REF = new PropertyDescriptor("crossRef", SPDX_NAMESPACE);
+
+ // SPDX Listed License constants
+ public static final String LISTED_LICENSE_URL = "https://spdx.org/licenses/";
+ // http rather than https since RDF depends on the exact string,
+ // we were not able to update the namespace variable to match the URL's.
+ public static final String LISTED_LICENSE_NAMESPACE_PREFIX = "http://spdx.org/licenses/";
+
+ // crossrefs details (crossRef) properties
+ public static final PropertyDescriptor PROP_CROSS_REF_IS_VALID = new PropertyDescriptor("isValid", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_CROSS_REF_WAYBACK_LINK = new PropertyDescriptor("isWayBackLink", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_CROSS_REF_MATCH = new PropertyDescriptor("match", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_CROSS_REF_URL = new PropertyDescriptor("url", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_CROSS_REF_IS_LIVE = new PropertyDescriptor("isLive", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_CROSS_REF_TIMESTAMP = new PropertyDescriptor("timestamp", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_CROSS_REF_ORDER = new PropertyDescriptor("order", SPDX_NAMESPACE);
+
+ // SpdxElement Properties
+ public static final PropertyDescriptor PROP_NAME = new PropertyDescriptor("name", SPDX_NAMESPACE);
+
+ // SPDX File Properties
+ // The comment property is the RDFS_PROP_COMMENT property in the rdfs namespace
+ public static final PropertyDescriptor PROP_FILE_NAME = new PropertyDescriptor("fileName", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_FILE_TYPE = new PropertyDescriptor("fileType", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_FILE_LICENSE = PROP_LICENSE_CONCLUDED;
+ public static final PropertyDescriptor PROP_FILE_COPYRIGHT = PROP_COPYRIGHT_TEXT;
+ public static final PropertyDescriptor PROP_FILE_CHECKSUM = new PropertyDescriptor("checksum", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_FILE_SEEN_LICENSE = new PropertyDescriptor("licenseInfoInFile", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_FILE_LIC_COMMENTS = PROP_LIC_COMMENTS;
+ public static final PropertyDescriptor PROP_FILE_ARTIFACTOF = new PropertyDescriptor("artifactOf", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_FILE_FILE_DEPENDENCY = new PropertyDescriptor("fileDependency", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_FILE_CONTRIBUTOR = new PropertyDescriptor("fileContributor", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_FILE_NOTICE = new PropertyDescriptor("noticeText", SPDX_NAMESPACE);
+
+ // SPDX Snippet Properties
+ public static final PropertyDescriptor PROP_SNIPPET_FROM_FILE = new PropertyDescriptor("snippetFromFile", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_SNIPPET_RANGE = new PropertyDescriptor("range", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_LICENSE_INFO_FROM_SNIPPETS = new PropertyDescriptor("licenseInfoInSnippet", SPDX_NAMESPACE);
+
+ // SPDX File Type Properties
+ public static final String PROP_FILE_TYPE_SOURCE = "fileType_source";
+ public static final String PROP_FILE_TYPE_ARCHIVE = "fileType_archive";
+ public static final String PROP_FILE_TYPE_BINARY = "fileType_binary";
+ public static final String PROP_FILE_TYPE_OTHER = "fileType_other";
+
+ public static final String FILE_TYPE_SOURCE = "SOURCE";
+ public static final String FILE_TYPE_ARCHIVE = "ARCHIVE";
+ public static final String FILE_TYPE_BINARY = "BINARY";
+ public static final String FILE_TYPE_OTHER = "OTHER";
+
+ // SPDX Annotation Properties
+ public static final PropertyDescriptor PROP_ANNOTATOR = new PropertyDescriptor("annotator", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_ANNOTATION_DATE = new PropertyDescriptor("annotationDate", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_ANNOTATION_TYPE = new PropertyDescriptor("annotationType", SPDX_NAMESPACE);
+
+ // SPDX Relationship Properties
+ public static final PropertyDescriptor PROP_RELATED_SPDX_ELEMENT = new PropertyDescriptor("relatedSpdxElement", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_RELATIONSHIP_TYPE = new PropertyDescriptor("relationshipType", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_SPDX_ELEMENTID = new PropertyDescriptor("spdxElementId", SPDX_NAMESPACE);
+
+ // ExternalDocumentRef properties
+ public static final PropertyDescriptor PROP_EXTERNAL_DOC_CHECKSUM = new PropertyDescriptor("checksum", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_EXTERNAL_SPDX_DOCUMENT = new PropertyDescriptor("spdxDocument", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_EXTERNAL_DOCUMENT_ID = new PropertyDescriptor("externalDocumentId", SPDX_NAMESPACE);
+
+ // External Reference properties
+ public static final PropertyDescriptor PROP_REFERENCE_CATEGORY = new PropertyDescriptor("referenceCategory", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_REFERENCE_TYPE = new PropertyDescriptor("referenceType", SPDX_NAMESPACE);
+ public static final PropertyDescriptor PROP_REFERENCE_LOCATOR = new PropertyDescriptor("referenceLocator", SPDX_NAMESPACE);
+
+ // Date format - NOTE: This format does not handle milliseconds. Use Instant.parse for full ISO 8601 parsing
+ public static final String SPDX_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+
+ // license ID format
+ public static String NON_STD_LICENSE_ID_PRENUM = "LicenseRef-";
+ public static Pattern LICENSE_ID_PATTERN_NUMERIC =
+ Pattern.compile(NON_STD_LICENSE_ID_PRENUM+"(\\d+)$"); // Pattern for numeric only license IDs
+ public static Pattern LICENSE_ID_PATTERN = Pattern.compile(NON_STD_LICENSE_ID_PRENUM+"([0-9a-zA-Z\\.\\-\\_]+)\\+?$");
+
+ // SPDX Element Reference format
+ public static String SPDX_ELEMENT_REF_PRENUM = "SPDXRef-";
+ public static Pattern SPDX_ELEMENT_REF_PATTERN = Pattern.compile(SPDX_ELEMENT_REF_PRENUM+"([0-9a-zA-Z\\.\\-\\+]+)$");
+
+ // External Document ID format
+ public static String EXTERNAL_DOC_REF_PRENUM = "DocumentRef-";
+ public static Pattern EXTERNAL_DOC_REF_PATTERN = Pattern.compile(EXTERNAL_DOC_REF_PRENUM+"([0-9a-zA-Z\\.\\-\\+]+)$");
+ public static Pattern EXTERNAL_ELEMENT_REF_PATTERN = Pattern.compile("(.+[0-9a-zA-Z\\.\\-\\+]+):("+SPDX_ELEMENT_REF_PRENUM+"[0-9a-zA-Z\\.\\-\\+]+)$");
+ public static Pattern EXTERNAL_SPDX_ELEMENT_URI_PATTERN = Pattern.compile("(.+)#("+SPDX_ELEMENT_REF_PRENUM+"[0-9a-zA-Z\\.\\-\\+]+)$");
+ public static Pattern EXTERNAL_EXTRACTED_LICENSE_URI_PATTERN = Pattern.compile("(.+)#("+NON_STD_LICENSE_ID_PRENUM+"[0-9a-zA-Z\\.\\-\\+]+)$");
+ public static Pattern EXTERNAL_EXTRACTED_LICENSE_PATTERN = Pattern.compile("(.+[0-9a-zA-Z\\.\\-\\+]+):("+NON_STD_LICENSE_ID_PRENUM+"[0-9a-zA-Z\\.\\-\\+]+)$");
+
+ // SPDX version format
+ public static Pattern SPDX_VERSION_PATTERN = Pattern.compile("^SPDX-(\\d+)\\.(\\d+)$");
+
+ // Download Location Format
+ private static final String SUPPORTED_DOWNLOAD_REPOS = "(git|hg|svn|bzr)";
+ private static final String URL_PATTERN = "(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/|ssh:\\/\\/|git:\\/\\/|svn:\\/\\/|sftp:\\/\\/|ftp:\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+){0,100}\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?";
+ private static final String GIT_PATTERN = "(git\\+git@[a-zA-Z0-9\\.\\-]+:[a-zA-Z0-9/\\\\.@\\-]+)";
+ private static final String BAZAAR_PATTERN = "(bzr\\+lp:[a-zA-Z0-9\\.\\-]+)";
+ public static final Pattern DOWNLOAD_LOCATION_PATTERN = Pattern.compile("^(NONE|NOASSERTION|(("+SUPPORTED_DOWNLOAD_REPOS+"\\+)?"+URL_PATTERN+")|"+GIT_PATTERN+"|"+BAZAAR_PATTERN+")$", Pattern.CASE_INSENSITIVE);
+
+ // License list version Format
+
+ public static final Pattern LICENSE_LIST_VERSION_PATTERN = Pattern.compile("^[a-zA-Z0-9]+\\.[a-zA-Z0-9]+");
+ // Standard value strings
+ public static String NONE_VALUE = "NONE";
+ public static String NOASSERTION_VALUE = "NOASSERTION";
+ public static final String[] LITERAL_VALUES = new String[]{NONE_VALUE, NOASSERTION_VALUE};
+
+ // data license ID
+ public static final String SPDX_DATA_LICENSE_ID_VERSION_1_0 = "PDDL-1.0";
+ public static final String SPDX_DATA_LICENSE_ID = "CC0-1.0";
+
+ public static final String SPDX_LISTED_REFERENCE_TYPES_PREFIX = "http://spdx.org/rdf/references/";
+
+ // License XML constants
+ public static final String LICENSEXML_URI = "http://www.spdx.org/license";
+ public static final String LICENSEXML_ELEMENT_LICENSE_COLLECTION = "SPDXLicenseCollection";
+ public static final String LICENSEXML_ELEMENT_LICENSE = "license";
+ public static final String LICENSEXML_ELEMENT_EXCEPTION = "exception";
+ public static final String LICENSEXML_ATTRIBUTE_ID = "licenseId";
+ public static final String LICENSEXML_ATTRIBUTE_DEPRECATED = "isDeprecated";
+ public static final String LICENSEXML_ATTRIBUTE_DEPRECATED_VERSION = "deprecatedVersion";
+ public static final String LICENSEXML_ATTRIBUTE_OSI_APPROVED = "isOsiApproved";
+ public static final String LICENSEXML_ATTRIBUTE_FSF_LIBRE = "isFsfLibre";
+ public static final String LICENSEXML_ATTRIBUTE_NAME = "name";
+ public static final String LICENSEXML_ATTRIBUTE_LIST_VERSION_ADDED = "listVersionAdded";
+ public static final String LICENSEXML_ELEMENT_CROSS_REFS = "crossRefs";
+ public static final String LICENSEXML_ELEMENT_CROSS_REF = "crossRef";
+ public static final String LICENSEXML_ELEMENT_NOTES = "notes";
+ public static final String LICENSEXML_ELEMENT_STANDARD_LICENSE_HEADER = "standardLicenseHeader";
+ public static final String LICENSEXML_ELEMENT_TITLE_TEXT = "titleText";
+ public static final String LICENSEXML_ELEMENT_COPYRIGHT_TEXT = "copyrightText";
+ public static final String LICENSEXML_ELEMENT_BULLET = "bullet";
+ public static final String LICENSEXML_ELEMENT_LIST = "list";
+ public static final String LICENSEXML_ELEMENT_ITEM = "item";
+ public static final String LICENSEXML_ELEMENT_PARAGRAPH = "p";
+ public static final String LICENSEXML_ELEMENT_OPTIONAL = "optional";
+ public static final String LICENSEXML_ELEMENT_ALT = "alt";
+ public static final String LICENSEXML_ATTRIBUTE_ALT_NAME = "name";
+ public static final String LICENSEXML_ATTRIBUTE_ALT_MATCH = "match";
+ public static final String LICENSEXML_ELEMENT_BREAK = "br";
+ public static final String LICENSEXML_ELEMENT_TEXT = "text";
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/spdx/tools/SpdxViewer.java b/src/main/java/org/spdx/tools/SpdxViewer.java
index 85995ad..8451532 100644
--- a/src/main/java/org/spdx/tools/SpdxViewer.java
+++ b/src/main/java/org/spdx/tools/SpdxViewer.java
@@ -25,7 +25,6 @@
import org.spdx.library.InvalidSPDXAnalysisException;
import org.spdx.library.model.SpdxDocument;
-import org.spdx.spdxRdfStore.RdfStore;
import org.spdx.storage.ISerializableModelStore;
import org.spdx.tag.CommonCode;
import org.spdx.tools.SpdxToolsHelper.SerFileType;
diff --git a/src/main/java/org/spdx/tools/schema/OwlToJava.java b/src/main/java/org/spdx/tools/schema/OwlToJava.java
new file mode 100644
index 0000000..a898032
--- /dev/null
+++ b/src/main/java/org/spdx/tools/schema/OwlToJava.java
@@ -0,0 +1,599 @@
+/**
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright (c) 2023 Source Auditor Inc.
+ */
+package org.spdx.tools.schema;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.jena.ontology.OntModel;
+import org.apache.jena.ontology.DatatypeProperty;
+import org.apache.jena.ontology.Individual;
+import org.apache.jena.ontology.ObjectProperty;
+import org.apache.jena.ontology.OntClass;
+import org.apache.jena.ontology.OntProperty;
+import org.apache.jena.ontology.OntResource;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.Statement;
+import org.apache.jena.ext.com.google.common.base.Optional;
+import org.apache.jena.graph.Node;
+import org.apache.jena.shacl.Shapes;
+import org.apache.jena.shacl.parser.Shape;
+import org.spdx.library.InvalidSPDXAnalysisException;
+import org.spdx.library.model.IndividualUriValue;
+import org.spdx.library.model.ModelObject;
+import org.spdx.library.model.Relationship;
+
+import com.github.mustachejava.DefaultMustacheFactory;
+import com.github.mustachejava.Mustache;
+
+/**
+ * Generates Java source class files for the SPDX Java Library from the RDF Owl Document generated from the spec model
+ *
+ * @author Gary O'Neall
+ *
+ */
+public class OwlToJava {
+
+ static final String SPDX_URI_PREFIX = "https://spdx.org/rdf/";
+ static final String INDENT = "\t";
+ private static final int COMMENT_LINE_LEN = 72;
+ private static final String BOOLEAN_TYPE = "http://www.w3.org/2001/XMLSchema#boolean";
+ private static final String STRING_TYPE = "http://www.w3.org/2001/XMLSchema#string";
+ private static final String ELEMENT_TYPE_URI = "https://spdx.org/rdf/Core/Element";
+ private static final String ELEMENT_TYPE_ANY_LICENSE_INFO = "https://spdx.org/rdf/Licensing/AnyLicenseInfo";
+ static final String TEMPLATE_CLASS_PATH = "resources" + "/" + "javaTemplates";
+ static final String TEMPLATE_ROOT_PATH = "resources" + File.separator + "javaTemplates";
+ private static final String JAVA_CLASS_TEMPLATE = "ModelObjectTemplate.txt";
+ private static final String ENUM_CLASS_TEMPLATE = "EnumTemplate.txt";
+ private static final String DATE_TIME_TYPE = "https://spdx.org/rdf/Core/DateTime";
+ private static final String ANY_URI_TYPE = "http://www.w3.org/2001/XMLSchema#anyURI";
+
+ private static Set INTEGER_TYPES = new HashSet<>();
+ static {
+ INTEGER_TYPES.add("http://www.w3.org/2001/XMLSchema#positiveInteger");
+ INTEGER_TYPES.add("http://www.w3.org/2001/XMLSchema#decimal");
+ INTEGER_TYPES.add("http://www.w3.org/2001/XMLSchema#nonNegativeInteger");
+ //TODO: Add other types - needs research
+ }
+
+ OntModel model = null;
+ Shapes shapes = null;
+ Map shapeMap = null;
+
+ Set enumClassUris = new HashSet<>(); // Set of enum URI's
+
+ /**
+ * Property maps mapping a property URI to a map of metadata about the property suitable for passing into Mustache templates
+ */
+ Map> elementProperties = new HashMap<>();
+ Map> anyLicenseInfoProperties = new HashMap<>();
+ Map> objectProperties = new HashMap<>();
+ Map> enumerationProperties = new HashMap<>();
+ Map> booleanProperties = new HashMap<>();
+ Map> integerProperties = new HashMap<>();
+ Map> stringProperties = new HashMap<>();
+ Map> objectPropertyValueCollection = new HashMap<>();
+ Map> stringCollection = new HashMap<>();
+ Map> objectPropertyValueSet = new HashMap<>();
+
+ /**
+ * @param model model to use to generate the java files
+ */
+ public OwlToJava(OntModel model) {
+ this.model = model;
+ shapes = Shapes.parse(model);
+ shapeMap = shapes.getShapeMap();
+ }
+
+ public void generateJavaSource(File dir) throws IOException {
+ List allObjectProperties = model.listObjectProperties().toList();
+ List allDataProperties = model.listDatatypeProperties().toList();
+ List allIndividuals = model.listIndividuals().toList();
+ List allClasses = model.listClasses().toList();
+ collectPropertyInformation(allObjectProperties, allDataProperties, allClasses, allIndividuals);
+ allClasses.forEach(ontClass -> {
+ String comment = ontClass.getComment(null);
+ String classUri = ontClass.getURI();
+ String name = ontClass.getLocalName();
+ Shape classShape = shapeMap.get(ontClass.asNode());
+ List props = new ArrayList<>();
+ boolean enumeration = ontClass.isEnumeratedClass();
+ ontClass.listProperties().forEach(stmt -> {
+ props.add(stmt);
+ });
+ List subClasses = new ArrayList<>();
+ ontClass.listSubClasses().forEach(oc -> {
+ subClasses.add(oc);
+ });
+ List superClasses = new ArrayList<>();
+ addAllSuperClasses(ontClass, superClasses);
+ List properties = ontClass.listDeclaredProperties(true).toList();
+
+ try {
+ //TODO: Handle individual classes
+ if (isEnumClass(ontClass)) {
+ generateJavaEnum(dir, classUri, name, allIndividuals, comment);
+ } else {
+ generateJavaClass(dir, classUri, name, properties, comment);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ }
+
+ /**
+ * Collect property information into the field maps for properties and initialize the enum classes field
+ * @param allObjectProperties object properties in the schema
+ * @param allDataProperties data properties in the schema
+ * @param allClasses classes in the schema
+ * @param allIndividuals Individuals to determine enum class types
+ */
+ private void collectPropertyInformation(
+ List allObjectProperties,
+ List allDataProperties, List allClasses, List allIndividuals) {
+
+ Set enumerationTypes = new HashSet<>();
+ Set anyLicenseInfoTypes = new HashSet<>();
+ Set elementTypes = new HashSet<>();
+
+ for (Individual individual:allIndividuals) {
+ this.enumClassUris.add(individual.getOntClass(true).getURI());
+ }
+ allClasses.forEach(ontClass -> {
+ List superClasses = new ArrayList<>();
+ addAllSuperClasses(ontClass, superClasses);
+ if (isEnumClass(ontClass)) {
+ enumerationTypes.add(ontClass.getURI());
+ } else if (isAnyLicenseInfoClass(ontClass, superClasses)) {
+ anyLicenseInfoTypes.add(ontClass.getURI());
+ } else if (isElementClass(ontClass, superClasses)) {
+ elementTypes.add(ontClass.getURI());
+ }
+ });
+
+ for (ObjectProperty prop:allObjectProperties) {
+ OntResource rangeResource = prop.getRange();
+ String rangeUri = rangeResource == null ? "" : rangeResource.getURI() == null ? "" : rangeResource.getURI();
+ if (enumerationTypes.contains(rangeUri)) {
+ enumerationProperties.put(prop.getURI(), propertyToMustachMap(prop));
+ } else if (isSet(prop)) {
+ objectPropertyValueSet.put(prop.getURI(), propertyToMustachMap(prop));
+ } else if (isCollection(prop)) {
+ objectPropertyValueCollection.put(prop.getURI(), propertyToMustachMap(prop));
+ } else if (anyLicenseInfoTypes.contains(rangeUri)) {
+ anyLicenseInfoProperties.put(prop.getURI(), propertyToMustachMap(prop));
+ } else if (elementTypes.contains(rangeUri)) {
+ elementProperties.put(prop.getURI(), propertyToMustachMap(prop));
+ } else {
+ objectProperties.put(prop.getURI(), propertyToMustachMap(prop));
+ }
+ }
+
+ for (DatatypeProperty prop:allDataProperties) {
+ OntResource rangeResource = prop.getRange();
+ String rangeUri = rangeResource == null ? "" : rangeResource.getURI() == null ? "" : rangeResource.getURI();
+ if (enumerationTypes.contains(rangeUri)) {
+ enumerationProperties.put(prop.getURI(), propertyToMustachMap(prop));
+ } else if (BOOLEAN_TYPE.equals(rangeUri)) {
+ booleanProperties.put(prop.getURI(), propertyToMustachMap(prop));
+ } else if (INTEGER_TYPES.contains(rangeUri)) {
+ integerProperties.put(prop.getURI(), propertyToMustachMap(prop));
+ //TODO: Add in specific types and type checking for DATE_TIME_TYPE and ANY_URI_TYPE
+ } else if (STRING_TYPE.equals(rangeUri) || DATE_TIME_TYPE.equals(rangeUri) || ANY_URI_TYPE.equals(rangeUri)) {
+ if (isCollection(prop)) {
+ stringCollection.put(prop.getURI(), propertyToMustachMap(prop));
+ } else {
+ stringProperties.put(prop.getURI(), propertyToMustachMap(prop));
+ }
+ } else {
+// throw new OwlToJavaException("Unknown data type URI "+rangeUri+" for property URI "+prop.getURI());
+ int i = 0;
+ i++;
+ }
+ }
+ }
+
+ /**
+ * Add super classes including transitive superclasses to the superClasses list
+ * @param ontClass class to add superClasses for
+ * @param superClasses
+ */
+ private void addAllSuperClasses(OntClass ontClass,
+ List superClasses) {
+ ontClass.listSuperClasses().forEach(superClass -> {
+ superClasses.add(superClass);
+ addAllSuperClasses(superClass, superClasses);
+ });
+ }
+
+ /**
+ * @param prop prop to test
+ * @return true if the property is a collection
+ */
+ private boolean isCollection(OntProperty prop) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ * @param prop prop to test
+ * @return true if the property is a set
+ */
+ private boolean isSet(OntProperty prop) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ * @param ontClass class
+ * @param superClasses list of all superclasses for the class
+ * @return true if the class is an Element or a subclass of Element
+ */
+ private boolean isElementClass(OntClass ontClass,
+ List superClasses) {
+ if (ELEMENT_TYPE_URI.equals(ontClass.getURI())) {
+ return true;
+ }
+ for (OntClass superClass:superClasses) {
+ if (ELEMENT_TYPE_URI.equals(superClass.getURI())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param ontClass class
+ * @param superClasses list of all superclasses for the class
+ * @return true if the class is an AnyLicenseInfo or a subclass of AnyLicenseInfo
+ */
+ private boolean isAnyLicenseInfoClass(OntClass ontClass,
+ List superClasses) {
+ if (ELEMENT_TYPE_ANY_LICENSE_INFO.equals(ontClass.getURI())) {
+ return true;
+ }
+ for (OntClass superClass:superClasses) {
+ if (ELEMENT_TYPE_ANY_LICENSE_INFO.equals(superClass.getURI())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param ontClass class
+ * @return true if the class is an enumeration
+ */
+ private boolean isEnumClass(OntClass ontClass) {
+ if (ontClass.isEnumeratedClass()) {
+ return true;
+ }
+ //TODO: Switch to enums to remove this hack
+ List properties = ontClass.listDeclaredProperties().toList();
+ for (OntProperty prop:properties) {
+ OntResource res = prop.getRange();
+ String uri = res.getURI();
+ }
+ return this.enumClassUris.contains(ontClass.getURI());
+ }
+
+ /**
+ * @param dir Directory to store the source files in
+ * @param classUri URI for the class
+ * @param name local name for the class
+ * @param properties properties for the class
+ * @param comment Description of the class
+ * @throws IOException
+ */
+ private void generateJavaClass(File dir, String classUri, String name,
+ List properties, String comment) throws IOException {
+ String pkgName = uriToPkg(classUri);
+ File sourceFile = createJavaSourceFile(classUri, dir);
+ Map mustacheMap = new HashMap<>();
+ mustacheMap.put("name", name);
+ mustacheMap.put("elementProperties", findProperties(properties, elementProperties));
+ mustacheMap.put("objectProperties", findProperties(properties, objectProperties));
+ mustacheMap.put("anyLicenseInfoProperties", findProperties(properties, anyLicenseInfoProperties));
+ mustacheMap.put("enumerationProperties", findProperties(properties, enumerationProperties));
+ mustacheMap.put("booleanProperties", findProperties(properties, booleanProperties));
+ mustacheMap.put("integerProperties", findProperties(properties, integerProperties));
+ mustacheMap.put("stringProperties", findProperties(properties, stringProperties));
+ mustacheMap.put("objectPropertyValueCollection", findProperties(properties, objectPropertyValueCollection));
+ mustacheMap.put("stringCollection", findProperties(properties, stringCollection));
+ mustacheMap.put("objectPropertyValueSet", findProperties(properties, objectPropertyValueSet));
+ mustacheMap.put("year", "2023"); // TODO - use actual year
+ mustacheMap.put("pkgName", pkgName);
+ List imports = buildImports();
+ mustacheMap.put("imports", imports.toArray(new String[imports.size()]));
+ mustacheMap.put("classComments", toClassComment(comment));
+ String superClass = getSuperClass();
+ mustacheMap.put("superClass", superClass);
+ mustacheMap.put("verifySuperclass", superClass != "ModelObject");
+ //TODO: Implement
+ mustacheMap.put("compareUsingProperties", false); // use properties to implement compareTo
+ mustacheMap.put("compareProperties", new ArrayList