Skip to content

Commit 26cb9fe

Browse files
bactgoneall
authored andcommitted
Bulletizes README
- Breaks long detailed paragraphs to bullets - Add sub headings for long sections - Highlights class/method/package names Signed-off-by: Arthit Suriyawongkul <[email protected]>
1 parent 06a4874 commit 26cb9fe

File tree

1 file changed

+69
-18
lines changed

1 file changed

+69
-18
lines changed

README.md

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55

66
Java library which implements the Java object model for SPDX and provides useful helper functions.
77

8+
The API documentation is available at:
9+
<https://spdx.github.io/Spdx-Java-Library/>
10+
811
## Code quality badges
912

10-
| [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=java-spdx-library&metric=bugs)](https://sonarcloud.io/dashboard?id=java-spdx-library) | [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=java-spdx-library&metric=security_rating)](https://sonarcloud.io/dashboard?id=java-spdx-library) | [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=java-spdx-library&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=java-spdx-library) | [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=java-spdx-library&metric=sqale_index)](https://sonarcloud.io/dashboard?id=java-spdx-library) |
13+
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=java-spdx-library&metric=bugs)](https://sonarcloud.io/dashboard?id=java-spdx-library)
14+
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=java-spdx-library&metric=security_rating)](https://sonarcloud.io/dashboard?id=java-spdx-library)
15+
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=java-spdx-library&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=java-spdx-library)
16+
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=java-spdx-library&metric=sqale_index)](https://sonarcloud.io/dashboard?id=java-spdx-library)
1117

1218
## Library Version Compatibility
1319

@@ -19,17 +25,44 @@ See the [README-V3-UPGRADE.md](README-V3-UPGRADE.md) file for information on how
1925

2026
## Storage Interface
2127

22-
The Spdx-Java-Library allows for different implementations of SPDX object storage. The storage facility implements the org.spdx.storage.IModelStore interface. This is a low level Service Provider Interface (SPI). The ISerializableModelStore extends the IModelStore and supports serializing and de-serializing the store to an I/O Stream. This interface is currently used to implement JSON, XML, YAML, and RDF/XML formats. The default storage interface is an in-memory Map which should be sufficient for light weight usage of the library.
23-
24-
Most common use of the library would de-serialize an existing SPDX document using one of the supported formats and model stores. To create SPDX objects from scratch, simply create the Java objects found in the org.spdx.library.model package. The model follows the [SPDX Object Model](https://github.com/spdx/spdx-spec/blob/2a7aff7afa089a774916bd5c64fc2cb83637ea07/model/SPDX-UML-Class-Diagram.jpg). The model objects themselves are stateless and do not store information. All information is retrieved from the model store when properties are access. Storage to the classes will store the updates through the use of the storage interface.
28+
- The Spdx-Java-Library allows for different implementations of SPDX object
29+
storage.
30+
- The storage facility implements the `org.spdx.storage.IModelStore` interface.
31+
This is a low level Service Provider Interface (SPI).
32+
- The `ISerializableModelStore` extends the `IModelStore` and supports
33+
serializing and de-serializing the store to an I/O Stream.
34+
This interface is currently used to implement JSON, XML, YAML, and RDF/XML
35+
formats.
36+
- The default storage interface is an in-memory Map which should be sufficient
37+
for light weight usage of the library.
38+
39+
### Storage Interface Usage
40+
41+
- Most common use of the library would de-serialize an existing SPDX document
42+
using one of the supported formats and model stores.
43+
- To create SPDX objects from scratch, simply create the Java objects found in
44+
the `org.spdx.library.model` package.
45+
- The model follows the [SPDX Object Model][spdx-object-model].
46+
- The model objects themselves are stateless and do not store information.
47+
- All information is retrieved from the model store when properties are access.
48+
- Storage to the classes will store the updates through the use of the storage
49+
interface.
50+
51+
[spdx-object-model]: https://github.com/spdx/spdx-spec/blob/2a7aff7afa089a774916bd5c64fc2cb83637ea07/model/SPDX-UML-Class-Diagram.jpg
2552

2653
## Multi-Threaded Considerations
2754

28-
The methods enterCriticalSection and leaveCriticalSection are available to support multi-threaded applications. These methods serialize access to the model store for the specific SPDX document used for the SPDX model object.
55+
The methods `enterCriticalSection` and `leaveCriticalSection` are available to
56+
support multi-threaded applications.
57+
58+
These methods serialize access to the model store for the specific SPDX
59+
document used for the SPDX model object.
2960

3061
## Getting Started
3162

32-
The library is available in [Maven Central org.spdx:java-spdx-library](https://search.maven.org/artifact/org.spdx/java-spdx-library).
63+
The library is available in Maven Central as
64+
[`org.spdx:java-spdx-library`](https://search.maven.org/artifact/org.spdx/java-spdx-library)
65+
(note the order of the word "java-spdx").
3366

3467
If you are using Maven, you can add the following dependency in your POM file:
3568

@@ -41,12 +74,15 @@ If you are using Maven, you can add the following dependency in your POM file:
4174
</dependency>
4275
```
4376

44-
[API JavaDocs are available here](https://spdx.github.io/Spdx-Java-Library/).
77+
The API documentation is available at:
78+
<https://spdx.github.io/Spdx-Java-Library/>
4579

4680
There are a couple of static classes that help common usage scenarios:
4781

48-
- org.spdx.library.SpdxModelFactory supports the creation of specific model objects
49-
- org.spdx.library.model.license.LicenseInfoFactory supports the parsing of SPDX license expressions, creation, and comparison of SPDX licenses
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
5086

5187
## Configuration options
5288

@@ -58,26 +94,41 @@ The library has these configuration options:
5894
2. `org.spdx.downloadCacheEnabled` - a boolean that enables or disables the download cache. Defaults to `false` (the cache is disabled). The cache location is determined as per the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) (i.e. `${XDG_CACHE_HOME}/Spdx-Java-Library` or `${HOME}/.cache/Spdx-Java-Library`).
5995
3. `org.spdx.downloadCacheCheckIntervalSecs` - a long that controls how often each cache entry is rechecked for staleness, in units of seconds. Defaults to 86,400 seconds (24 hours). Set to 0 (zero) to have each cache entry checked every time (note: this will result in a lot more network I/O and negatively impact performance, albeit there is still a substantial performance saving vs not using the cache at all).
6096

61-
Note that these configuration options can only be modified prior to first use of Spdx-Java-Library. Once the library is initialized, subsequent changes will have no effect.
97+
Note that these configuration options can only be modified prior to first use
98+
of Spdx-Java-Library.
99+
*Once the library is initialized, subsequent changes will have no effect.*
100+
101+
## Initialization
62102

63103
The first thing that needs to be done in your implementation is call `SpdxModelFactory.init()` - this will load all the supported versions.
64104

65-
If you are programmatically creating SPDX data, you will start by creating a model store. The simplest model store is an in-memory model store which can be created with `store = new InMemSpdxStore()`. 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()`.
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()`.
107+
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()`.
66109

67110
The first object you create will depend on the major version:
68111

69-
- For SPDX 2.X, you would start by creating an SpdxDocument. The factory method `SpdxDocument document = SpdxModelFactory.createSpdxDocumentV2(IModelStore modelStore, String documentUri, IModelCopyManager copyManager)` will create a new SPDX document. Once created, you can use the setters to set the specific fields. You can then use the convenience create methods on the document to create additional SPDX objects (e.g. `document.createSpdxFile(...)`);
70-
- For SPDX 3.X, you will start with a CreationInfo class. 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. 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)`. The created objects will copy the creationInfo.
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.
71120

72121
## Update for new versions of the spec
73122

74123
To update Spdx-Java-Library, the following is a very brief checklist:
75124

76-
1. Create a Java .jar file for the new version which contains an implementation of `ISpdxModelInfo` - typically named SpdxModelInfoVXXX - where XXX is the version of the spec.
77-
2. Update the SpdxModelFactory source file to load the model info by adding the line `ModelRegistry.getModelRegistry().registerModel(new SpdxModelInfoVXXX());` in the static block at the very beginning of the class.
78-
3. If there are any conversions that are needed when copying to or from the new model version, add conversion code to the `ModelCopyConverter` class.
79-
4. Update SpdxModelFactory unit test for the highest version check
125+
1. Create a Java .jar file for the new version which contains an implementation of `ISpdxModelInfo` - typically named `SpdxModelInfoVXXX` - where "XXX" is the version of the spec.
126+
2. Update the SpdxModelFactory source file to load the model info by adding the line `ModelRegistry.getModelRegistry().registerModel(new SpdxModelInfoVXXX());` in the static block at the very beginning of the class.
127+
3. If there are any conversions that are needed when copying to or from the new model version, add conversion code to the `ModelCopyConverter` class.
128+
4. Update SpdxModelFactory unit test for the highest version check
80129

81130
## Development Status
82131

83-
Note: This library is currently unstable, and under development. Reviews, suggestions are welcome. Please enter an issue with any suggestions.
132+
Note: This library is currently unstable, and under development.
133+
Reviews, suggestions are welcome.
134+
Please enter an issue with any suggestions.

0 commit comments

Comments
 (0)