Skip to content

Commit ad4d800

Browse files
bactgoneall
authored andcommitted
Fix few typos and add language to code block
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
1 parent f483016 commit ad4d800

4 files changed

Lines changed: 33 additions & 21 deletions

File tree

GETTING-STARTED.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@
44

55
### Programmatically Creating SPDX Data
66

7-
Before executing any of the model class methods, the model versions need to be intialized. This is done by calling:
7+
Before executing any of the model class methods, the model versions need to be initialized. This is done by calling:
88

9-
```
9+
```java
1010
SpdxModelFactory.init();
1111
```
1212

1313
SPDX data is stored in a "model store" and copying between model stores requires a copy manager.
1414

1515
A simple store is provided in the java library. To create the simple in-memory model store and a copy manager, execute the following:
1616

17-
```
17+
```java
1818
InMemSpdxStore modelStore = new InMemSpdxStore();
1919
IModelCopyManager copyManager = new ModelCopyManager();
2020
```
2121

2222
All SPDX elements are required to have a unique SPDX ID which is an Object URI. In the SPDX Java libraries, this is commonly referred to as the `objectUri` to avoid confusion with the SPDX 2.X version short SPDX IDs.
2323

24-
A good practice is to create a common prefix to use for your programatic session. The prefix should be unique to the session. There are convenience methods in the library to append identifiers uniques to the model store.
24+
A good practice is to create a common prefix to use for your programmatic session. The prefix should be unique to the session. There are convenience methods in the library to append identifiers unique to the model store.
2525

2626
In these examples, we'll use:
2727

28-
```
28+
```java
2929
String prefix = "https://org.spdx.spdxdata/899b1918-f72a-4755-9215-6262b3c346df/";
3030
```
3131

3232
Since SPDX 3.0 requires creation info on every element, the easiest way to start is to use the SPDX 3 model convenience method `SpdxModelClassFactory.createCreationInfo(...)` which will create the `Agent` and `CreationInfo` classes which can be added to all of the subsequent elements.
3333

3434
For example:
3535

36-
```
36+
```java
3737
CreationInfo creationInfo = SpdxModelClassFactory.createCreationInfo(
3838
modelStore, prefix + "Agent/Gary01123", "Gary O'Neall",
3939
copyManager);
@@ -43,28 +43,28 @@ We're now ready to create our first SPDX element. You can start anywhere, but l
4343

4444
There is a factory method you can use to get started:
4545

46-
```
46+
```java
4747
Sbom sbom = SpdxModelClassFactory.getModelObject(modelStore,
4848
prefix + "sbom/mysbom", SpdxConstantsV3.SOFTWARE_SBOM,
4949
copyManager, true, prefix);
5050
```
5151

5252
Let's not forget to add the creation info:
5353

54-
```
54+
```java
5555
sbom.setCreationInfo(creationInfo);
5656
```
5757

5858
From here on, things get easier. We can get and set properties to the sbom we just created.
5959

6060
If we want to create another SPDX object or element, we can use the builder convenience methods available to all SPDX objects. For example, if we want to create a package to add to the SBOM we can call:
6161

62-
```
62+
```java
6363
sbom.getElements().add(
6464
sbom.createSpdxPackage(prefix + "package/mypackage")
6565
.setName("Package Name")
6666
.build()
6767
);
6868
```
6969

70-
The model store, creation info, copy manager, and prefix information will all be copied from the sbom allowing you to focus just on the properties you need to add.
70+
The model store, creation info, copy manager, and prefix information will all be copied from the sbom allowing you to focus just on the properties you need to add.

README-SPI-MODEL-STORE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ NOTE: This README is currently under development.
99
## Storing and Retrieving Values
1010

1111
### Converting Object Types
12+
1213
The class org.spdx.library.ModelStorageClassConverter contains static methods to convert object types supported by the SPI.
1314

1415
storedObjectToModelObject will convert a stored object to a Model object.
1516

1617
modelObjectToStoredObject will convert a model object to a stored object.
1718

18-
These methods should be used to avoid common errors when converting between supported object types.
19+
These methods should be used to avoid common errors when converting between supported object types.
1920

2021
## Using the Serialization interfaces
2122

2223
Note: You can extend the default org.spdx.storage.simple.InMemSpdxStore with a couple of serialization / de-serialization methods to implement a storage interface to a serializeable format (such as a JSON or YAML file).
2324

2425
## Handling Collections of Values
2526

26-
## Notes on Concurrency and Multi-threading
27+
## Notes on Concurrency and Multi-threading

README-V3-UPGRADE.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The packages in `org.spdx.licenseTemplates` are now in the `java-spdx-core` repo
2222
A new class `LicenseTextHelper` was added and the method `isLicenseTextEquivalent(String, String)` along with many supporting methods were moved to `LicenseTextHelper` from `org.spdx.utility.compare.LicenseCompareHelper`.
2323

2424
## Changes to SPDX version 2 package, class, and method names
25+
2526
To support accessing SPDX 2.X model object while updating the library for SPDX 3.0 support, the package names for the SPDX 2.X model objects are now named `org.spdx.library.model.v2.[package]`.
2627

2728
Many of the class and property names have been changed to append `CompatV2` to clearly designate a compatible object is being referenced.
@@ -37,14 +38,16 @@ will check for the old DocumentRef format and attempt a conversion.
3738
Note that this incompatibility was introduced due to using a common mode store API which in some cases will not have the documentUri as a required parameter
3839

3940
## Changes to deserialize interface
41+
4042
Since SPDX documents are not generally required in SPDX spec version 3.0, the SPDX namespace was removed from the return value for deserialized and also removed as a parameter for the serialize method. Serialize will now serialize all objects - which may be multiple SPDX documents.
4143

4244
To find all the SPDX documents in a serialization, you can execute:
4345

44-
```
46+
```java
4547
List<SpdxDocument> docs = (List<SpdxDocument>)SpdxModelFactory.getSpdxObjects(store, null, SpdxConstantsCompatV2.CLASS_SPDX_DOCUMENT, null, null)
4648
.collect(Collectors.toList());
4749
```
50+
4851
after deserialization to get a list of all SPDX documents.
4952

5053
For the RDF store, to keep compatible with the SPDX 2.X requirements, it now only supports a single document namespace.
@@ -54,9 +57,9 @@ For the RDF store, to keep compatible with the SPDX 2.X requirements, it now onl
5457
### Change propertyName to propertyDescriptor
5558

5659
One significant change to the model store which impacts most of the API's.
57-
All `String` `propertyName` properties are replaced by a `propertyDescriptor` of type `ProperyDescriptor`.
60+
All `String` `propertyName` properties are replaced by a `propertyDescriptor` of type `PropertyDescriptor`.
5861
The `PropertyDescriptor` has a `name` property and a `nameSpace` property.
59-
The property constants defined in `org.spdx.library.SpdxConstants` have all been changed to use constant `PropertyDescriptor`s.
62+
The property constants defined in `org.spdx.library.SpdxConstants` have all been changed to use constant `PropertyDescriptor`s.
6063
If you're using the constants, you may not need to change much beyond the method signatures for anything that was passing along the `propertyName`.
6164

6265
### Make DocumentNamespace Optional
@@ -75,4 +78,4 @@ There is a convenience helper method `CompatibleModelStoreWrapper.typedValueFrom
7578

7679
To help with the migration, the `CompatibleModelStoreWrapper` class was introduced supporting the `IModelStore` interface taking a base store as a parameter in the constructor. This class "wraps" the base store and supports the SPDX 2 methods which take the document namespace parameters.
7780

78-
There is also a convenience static method to convert a namespace and ID to an Object URI.
81+
There is also a convenience static method to convert a namespace and ID to an Object URI.

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Spdx-Java-Library
2+
23
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.spdx/java-spdx-library/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.spdx/java-spdx-library)
34
![Java CI with Maven](https://github.com/spdx/Spdx-Java-Library/workflows/Java%20CI%20with%20Maven/badge.svg)
45

56
Java library which implements the Java object model for SPDX and provides useful helper functions.
67

7-
# Code quality badges
8+
## Code quality badges
89

910
| [![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) |
1011

@@ -17,17 +18,21 @@ The library does support the spec versions 2.X and 3.X.
1718
See the [README-V3-UPGRADE.md](README-V3-UPGRADE.md) file for information on how to upgrade from earlier versions of the library.
1819

1920
## Storage Interface
21+
2022
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.
2123

22-
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.
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.
2325

2426
## Multi-Threaded Considerations
27+
2528
The methods enterCriticalSection and leaveCritialSection 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.
2629

2730
## Getting Started
31+
2832
The library is available in [Maven Central org.spdx:java-spdx-library](https://search.maven.org/artifact/org.spdx/java-spdx-library).
2933

3034
If you are using Maven, you can add the following dependency in your POM file:
35+
3136
```xml
3237
<dependency>
3338
<groupId>org.spdx</groupId>
@@ -43,12 +48,12 @@ There are a couple of static classes that help common usage scenarios:
4348
- org.spdx.library.SpdxModelFactory supports the creation of specific model objects
4449
- org.spdx.library.model.license.LicenseInfoFactory supports the parsing of SPDX license expressions, creation, and comparison of SPDX licenses
4550

46-
4751
## Configuration options
4852

4953
`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`.
5054

5155
The library has these configuration options:
56+
5257
1. `org.spdx.useJARLicenseInfoOnly` - a boolean that controls whether the (potentially out of date) listed license information bundled inside the JAR is used (true), vs the library downloading the latest files from the SPDX website (false). Default is false (always download the latest files from the SPDX website).
5358
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`).
5459
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).
@@ -57,13 +62,15 @@ Note that these configuration options can only be modified prior to first use of
5762

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

60-
If you are programatically 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()`.
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()`.
6166

6267
The first object you create will depend on the major version:
68+
6369
- 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(...)`);
64-
- 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.
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.
6571

6672
## Update for new versions of the spec
73+
6774
To update Spdx-Java-Library, the following is a very brief checklist:
6875

6976
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.
@@ -72,4 +79,5 @@ To update Spdx-Java-Library, the following is a very brief checklist:
7279
4. Update SpdxModelFactory unit test for the highest version check
7380

7481
## Development Status
82+
7583
Note: This library is currently unstable, and under development. Reviews, suggestions are welcome. Please enter an issue with any suggestions.

0 commit comments

Comments
 (0)