Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 49 additions & 13 deletions src/main/java/org/spdx/storage/listedlicense/CrossRefJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ public class CrossRefJson {
public Integer order;
private transient String id; // The ID is always transient and of anonymous type

/**
* Default constructor for GSON compatibility
*/
public CrossRefJson() {
// empty constructor so GSON will work
}

/**
* @param crossRef cross ref to copy values from
* Construct a {@code CrossRefJson} object by copying values
* from a {@link CrossRef} object
*
* @param crossRef The {@link CrossRef} object to copy values from.
* @throws InvalidSPDXAnalysisException on SPDX parsing errors
*/
public CrossRefJson(CrossRef crossRef) throws InvalidSPDXAnalysisException {
Expand All @@ -65,8 +71,10 @@ public CrossRefJson(CrossRef crossRef) throws InvalidSPDXAnalysisException {
crossRef.getTimestamp().ifPresent(s -> timestamp = s);
crossRef.getOrder().ifPresent(integer -> order = integer);
}

/**
* Retrieve all valid property descriptors for this object
*
* @return all valid property descriptors
*/
public List<PropertyDescriptor> getPropertyValueDescriptors() {
Expand Down Expand Up @@ -96,7 +104,8 @@ public List<PropertyDescriptor> getPropertyValueDescriptors() {
}

/**
* Sets the value to the property name
* Set the value to the property name
*
* @param propertyDescriptor descriptor for the property to set
* @param value Value to set
* @throws InvalidSpdxPropertyException on SPDX parsing errors
Expand Down Expand Up @@ -154,10 +163,20 @@ public boolean removePrimitiveValueToList(PropertyDescriptor propertyDescriptor,
throw new InvalidSpdxPropertyException(propertyDescriptor + " is not a list type.");
}

/**
* Get the crossRefId
*
* @return The crossRefId
*/
public @Nullable String getId() {
return this.id;
}

/**
* Set the crossRefId
*
* @param crossRefId
*/
public void setId(String crossRefId) {
this.id = crossRefId;
}
Expand All @@ -172,6 +191,8 @@ public List<?> getValueList(PropertyDescriptor propertyDescriptor) throws Invali
}

/**
* Retrieve the value associated with the given property descriptor
*
* @param propertyDescriptor descriptor for the property to set
* @return the value associated with the property - null if not assigned or not present
* @throws InvalidSpdxPropertyException on SPDX parsing errors
Expand All @@ -190,8 +211,9 @@ public List<?> getValueList(PropertyDescriptor propertyDescriptor) throws Invali
}

/**
* sets the property to null (no way to remove in this store)
* @param propertyDescriptor descriptor for the property to set
* Set the property to null (no way to remove in this store)
*
* @param propertyDescriptor Descriptor for the property to set
* @throws InvalidSpdxPropertyException on SPDX parsing errors
*/
public void removeProperty(PropertyDescriptor propertyDescriptor) throws InvalidSpdxPropertyException {
Expand All @@ -203,11 +225,16 @@ public void removeProperty(PropertyDescriptor propertyDescriptor) throws Invalid
case "timestamp": this.timestamp = null; break;
case "isWayBackLink": this.isWayBackLink = null; break;
case "order": this.order = null; break;
default: throw new InvalidSpdxPropertyException("Invalid property for CrossRef:"+propertyDescriptor);
default:
throw new InvalidSpdxPropertyException("Invalid property for CrossRef:" + propertyDescriptor);
}
}

/**
* Check whether the members of the collection can be assigned to the given class
* <p>
* Note: This is not implemented for this class and always returns false.
*
* @param propertyDescriptor descriptor for the property to set
* @param clazz target class
* @return true if the members can be assigned from clazz
Expand All @@ -217,6 +244,8 @@ public boolean isCollectionMembersAssignableTo(PropertyDescriptor propertyDescri
}

/**
* Check whether the property value can be assigned to the given class
*
* @param propertyDescriptor descriptor for the property to set
* @param clazz target class
* @return true if the property can be assigned from clazz
Expand All @@ -226,21 +255,28 @@ public boolean isPropertyValueAssignableTo(PropertyDescriptor propertyDescriptor
switch (propertyDescriptor.getName()) {
case "match":
case "url":
case "timestamp": return String.class.isAssignableFrom(clazz);
case "timestamp":
return String.class.isAssignableFrom(clazz);
case "isValid":
case "isLive":
case "isWayBackLink": return Boolean.class.isAssignableFrom(clazz);
case "order": return Integer.class.isAssignableFrom(clazz);
default: throw new InvalidSpdxPropertyException("Invalid property for CrossRef:"+propertyDescriptor);
}

case "isWayBackLink":
return Boolean.class.isAssignableFrom(clazz);
case "order":
return Integer.class.isAssignableFrom(clazz);
default:
throw new InvalidSpdxPropertyException("Invalid property for CrossRef:" + propertyDescriptor);
}
}

/**
* Check whether the property is a collection
* <p>
* Note: This is not implemented for this class and always returns false.
*
* @param propertyName Name of the property
* @return if the property is a collection
*/
public boolean isCollectionProperty(String propertyName) {
return false;
}
}
}
62 changes: 58 additions & 4 deletions src/main/java/org/spdx/storage/listedlicense/ExceptionJsonTOC.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,99 +43,141 @@ public static class ExceptionJson {
private String name;
private String licenseExceptionId;
private List<String> seeAlso;

/**
* Retrieve the license exception ID
*
* @return the licenseExceptionId
*/
public String getLicenseExceptionId() {
return licenseExceptionId;
}

/**
* Retrieve the reference
*
* @return the reference
*/
public String getReference() {
return reference;
}

/**
* Check whether this is a deprecated license ID
*
* @return the isDeprecatedLicenseId
*/
public boolean isDeprecatedLicenseId() {
return isDeprecatedLicenseId;
}

/**
* Retrieve the details URL
*
* @return the detailsUrl
*/
public String getDetailsUrl() {
return detailsUrl;
}

/**
* Retrieve the reference number
*
* @return the referenceNumber
*/
public int getReferenceNumber() {
return referenceNumber;
}

/**
* Retrieve the name
*
* @return the name
*/
public String getName() {
return name;
}

/**
* Retrieve the see-also list
*
* @return the seeAlso
*/
public List<String> getSeeAlso() {
return seeAlso;
}

/**
* Set the reference
*
* @param reference the reference to set
*/
public void setReference(String reference) {
this.reference = reference;
}

/**
* Set whether this is a deprecated license ID
*
* @param isDeprecatedLicenseId the isDeprecatedLicenseId to set
*/
public void setDeprecatedLicenseId(boolean isDeprecatedLicenseId) {
this.isDeprecatedLicenseId = isDeprecatedLicenseId;
}

/**
* Set the details URL
*
* @param detailsUrl the detailsUrl to set
*/
public void setDetailsUrl(String detailsUrl) {
this.detailsUrl = detailsUrl;
}

/**
* Set the reference number
*
* @param referenceNumber the referenceNumber to set
*/
public void setReferenceNumber(int referenceNumber) {
this.referenceNumber = referenceNumber;
}

/**
* Set the name
*
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}

/**
* Set the license exception ID
*
* @param licenseExceptionId the licenseExceptionId to set
*/
public void setLicenseExceptionId(String licenseExceptionId) {
this.licenseExceptionId = licenseExceptionId;
}

/**
* Set the see-also list
*
* @param seeAlso the seeAlso to set
*/
public void setSeeAlso(List<String> seeAlso) {
this.seeAlso = seeAlso;
}
}


private String licenseListVersion;
private final List<ExceptionJson> exceptions;
private String releaseDate;

/**
* Create an ExceptionJsonTOC
*
* @param version license list version
* @param releaseDate release date of the license list
*/
Expand All @@ -155,21 +197,27 @@ public ExceptionJsonTOC() {
}

/**
* Retrieve the license list version
*
* @return the licenseListVersion
*/
public @Nullable String getLicenseListVersion() {
return licenseListVersion;
}

/**
* Retrieve the list of exceptions
*
* @return the exceptions
*/
public List<ExceptionJson> getExceptions() {
return exceptions;
}

/**
* @return map of lower case to correct case exception IDs
* Retrieve a map of lower case to correct case exception IDs
*
* @return A map of lower case to correct case exception IDs
*/
public Map<String, String> getExceptionIds() {
Map<String, String> retval = new HashMap<>();
Expand All @@ -180,6 +228,8 @@ public Map<String, String> getExceptionIds() {
}

/**
* Retrieve the release date
*
* @return the releaseDate
*/
public @Nullable String getReleaseDate() {
Expand All @@ -188,6 +238,7 @@ public Map<String, String> getExceptionIds() {

/**
* Add a new exception to the list of exceptions
*
* @param exception exception to be added
* @param exceptionHTMLReference URL of the exception HTML
* @param exceptionJSONReference URL of the JSON
Expand Down Expand Up @@ -215,18 +266,21 @@ public void addException(ListedLicenseException exception, String exceptionHTMLR
}

/**
* Set the license list version
*
* @param licenseListVersion the licenseListVersion to set
*/
public void setLicenseListVersion(String licenseListVersion) {
this.licenseListVersion = licenseListVersion;
}

/**
* Set the release date
*
* @param releaseDate the releaseDate to set
*/
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ public boolean isSkipFirstTextToken() {
}

/**
* Information obout any difference found
* Information about any difference found
*/
public static class DifferenceDescription {
private static final int MAX_DIFF_TEXT_LENGTH = 100;
Expand Down