You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you are using Maven, you can add the following dependency in your POM file:
68
-
69
-
```xml
70
-
<dependency>
71
-
<groupId>org.spdx</groupId>
72
-
<artifactId>java-spdx-library</artifactId>
73
-
<version>(,2.0]</version>
74
-
</dependency>
75
-
```
63
+
See the [GETTING-STARTED.md](GETTING-STARTED.md) file for how to get started in different scenarios.
64
+
65
+
## API Documentation
76
66
77
67
The API documentation is available at:
78
68
<https://spdx.github.io/Spdx-Java-Library/>
79
69
80
-
There are a couple of static classes that help common usage scenarios:
81
-
82
-
-`org.spdx.library.SpdxModelFactory` supports the creation of specific
83
-
model objects
84
-
-`org.spdx.library.model.license.LicenseInfoFactory` supports the parsing of
85
-
SPDX license expressions, creation, and comparison of SPDX licenses
86
-
87
70
## Configuration options
88
71
89
72
`Spdx-Java-Library` can be configured using either Java system properties or a Java properties file located in the runtime CLASSPATH at `/resources/spdx-java-library.properties`.
@@ -100,23 +83,38 @@ of Spdx-Java-Library.
100
83
101
84
## Initialization
102
85
103
-
The first thing that needs to be done in your implementation is call `SpdxModelFactory.init()` - this will load all the supported versions.
86
+
Before executing any of the model class methods, the model versions need to be initialized. This is done by calling:
87
+
88
+
```java
89
+
SpdxModelFactory.init();
90
+
```
91
+
92
+
SPDX data is stored in a "model store" and copying between model stores requires a copy manager.
104
93
105
-
If you are programmatically creating SPDX data, you will start by creating a model store.
106
-
The simplest model store is an in-memory model store which can be created with `store = new InMemSpdxStore()`.
94
+
A simple store is provided in the java library. To create the simple in-memory model store and a copy manager, execute the following:
107
95
108
-
A copy manager will be needed if you are working with more than one store (e.g. a serialized format of SPDX data and in memory). If you're not sure, you should just create one. This can be done with `copyManager = new ModelCopyManager()`.
The first object you create will depend on the major version:
113
+
The `newDefaultDocumentUri` is a default document URI used for SPDX Spec version 2 model objects.
111
114
112
-
- For SPDX 2.X, you would start by creating an `SpdxDocument`.
113
-
- The factory method `SpdxDocument document = SpdxModelFactory.createSpdxDocumentV2(IModelStore modelStore, String documentUri, IModelCopyManager copyManager)` will create a new SPDX document.
114
-
- Once created, you can use the setters to set the specific fields.
115
-
- You can then use the convenience create methods on the document to create additional SPDX objects (e.g. `document.createSpdxFile(...)`);
116
-
- For SPDX 3.X, you will start with a `CreationInfo` class.
117
-
- The factory method `CreationInfo creationInfo = SpdxModelClassFactory.createCreationInfo(IModelStore modelStore, String createdByUri,String createdByName, @Nullable IModelCopyManager copyManager)` will create and initialize a CreationInfo with today's date and the Agent information.
118
-
- To create any additional objects, you can use the builder convenience methods from the creationInfo (or any Elements created by the creationInfo) e.g. `creationInfo.createSoftwareSpdxFile(String spdxFileObjectUri)`.
119
-
- The created objects will copy the creationInfo.
115
+
IMPORTANT NOTE: The call to `DefaultModelStore.initialize` must be made prior to or immediately after the call
116
+
to `SpdxModelFactory.init()`. Otherwise, any data stored in the previous default model object will be lost.
117
+
The `SpdxModelFactory.init()` will not overwrite an already initialized default model store.
0 commit comments