Skip to content

Commit 7ef32eb

Browse files
committed
More cleanup
Mostly removing extra parens Signed-off-by: Gary O'Neall <[email protected]>
1 parent 31957ae commit 7ef32eb

File tree

12 files changed

+82
-83
lines changed

12 files changed

+82
-83
lines changed

src/main/java/org/spdx/library/model/ExternalSpdxElement.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public ExternalSpdxElement(IModelStore modelStore, String documentUri, String id
6363
throws InvalidSPDXAnalysisException {
6464
super(modelStore, documentUri, id, copyManager, create);
6565
if (!SpdxConstants.EXTERNAL_ELEMENT_REF_PATTERN.matcher(id).matches()) {
66-
throw(new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:SPDXID"));
66+
throw new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:SPDXID");
6767
}
6868
getExternalSpdxElementURI(); //this will check to make sure the external document reference is available
6969
}
@@ -75,7 +75,7 @@ public ExternalSpdxElement(IModelStore modelStore, String documentUri, String id
7575
public String getExternalDocumentId() throws InvalidSPDXAnalysisException {
7676
Matcher matcher = SpdxConstants.EXTERNAL_ELEMENT_REF_PATTERN.matcher(this.getId());
7777
if (!matcher.matches()) {
78-
throw(new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:SPDXID"));
78+
throw new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:SPDXID");
7979
}
8080
return matcher.group(1);
8181
}
@@ -87,7 +87,7 @@ public String getExternalDocumentId() throws InvalidSPDXAnalysisException {
8787
public String getExternalElementId() throws InvalidSPDXAnalysisException {
8888
Matcher matcher = SpdxConstants.EXTERNAL_ELEMENT_REF_PATTERN.matcher(this.getId());
8989
if (!matcher.matches()) {
90-
throw(new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:SPDXID"));
90+
throw new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:SPDXID");
9191
}
9292
return matcher.group(2);
9393
}
@@ -198,7 +198,7 @@ public static String externalDocumentIdToNamespace(String externalDocumentId,
198198
Optional<Object> retval = getObjectPropertyValue(stModelStore, stDocumentUri,
199199
externalDocumentId, SpdxConstants.PROP_EXTERNAL_SPDX_DOCUMENT, copyManager);
200200
if (!retval.isPresent()) {
201-
throw(new InvalidSPDXAnalysisException("No external document reference exists for document ID "+externalDocumentId));
201+
throw new InvalidSPDXAnalysisException("No external document reference exists for document ID "+externalDocumentId);
202202
}
203203
if (!(retval.get() instanceof IndividualUriValue)) {
204204
logger.error("Invalid type returned for external document. Expected IndividualValue, actual "+retval.get().getClass().toString());

src/main/java/org/spdx/library/model/ModelStorageClassConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static Object modelObjectToStoredObject(Object value, String stDocumentUr
121121
return copyManager.copy(stModelStore, stDocumentUri,
122122
mValue.getModelStore(), mValue.getDocumentUri(), mValue.getId(), mValue.getType());
123123
} else {
124-
throw(new SpdxObjectNotInStoreException("Can not set a property value to a Model Object stored in a different model store"));
124+
throw new SpdxObjectNotInStoreException("Can not set a property value to a Model Object stored in a different model store");
125125
}
126126
} else {
127127
return mValue.toTypedValue();

src/main/java/org/spdx/library/model/license/ExternalExtractedLicenseInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public ExternalExtractedLicenseInfo(IModelStore modelStore, String documentUri,
6666
throws InvalidSPDXAnalysisException {
6767
super(modelStore, documentUri, id, copyManager, create);
6868
if (!SpdxConstants.EXTERNAL_EXTRACTED_LICENSE_PATTERN.matcher(id).matches()) {
69-
throw(new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:LicenseRef-XXX"));
69+
throw new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:LicenseRef-XXX");
7070
}
7171
getExternalExtractedLicenseURI(); //this will check to make sure the external document reference is available
7272
}
@@ -78,7 +78,7 @@ public ExternalExtractedLicenseInfo(IModelStore modelStore, String documentUri,
7878
public String getExternalDocumentId() throws InvalidSPDXAnalysisException {
7979
Matcher matcher = SpdxConstants.EXTERNAL_EXTRACTED_LICENSE_PATTERN.matcher(this.getId());
8080
if (!matcher.matches()) {
81-
throw(new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:LicenseRef-XXX"));
81+
throw new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:LicenseRef-XXX");
8282
}
8383
return matcher.group(1);
8484
}
@@ -90,7 +90,7 @@ public String getExternalDocumentId() throws InvalidSPDXAnalysisException {
9090
public String getExternalLicenseRef() throws InvalidSPDXAnalysisException {
9191
Matcher matcher = SpdxConstants.EXTERNAL_EXTRACTED_LICENSE_PATTERN.matcher(this.getId());
9292
if (!matcher.matches()) {
93-
throw(new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:LicenseRef-XXX"));
93+
throw new InvalidSPDXAnalysisException("Invalid id format for an external document reference. Must be of the form ExternalSPDXRef:LicenseRef-XXX");
9494
}
9595
return matcher.group(2);
9696
}

src/main/java/org/spdx/library/model/license/LicenseExpressionParser.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ enum Operator {
7676
static AnyLicenseInfo parseLicenseExpression(String expression, IModelStore store,
7777
String documentUri, ModelCopyManager copyManager) throws InvalidSPDXAnalysisException {
7878
if (expression == null || expression.trim().isEmpty()) {
79-
throw(new LicenseParserException("Empty license expression"));
79+
throw new LicenseParserException("Empty license expression");
8080
}
8181
Objects.requireNonNull(store, "Model store can not be null");
8282
Objects.requireNonNull(documentUri, "Document URI can not be null");
@@ -90,9 +90,9 @@ static AnyLicenseInfo parseLicenseExpression(String expression, IModelStore stor
9090
return parseLicenseExpression(tokens, store, documentUri, copyManager);
9191
} catch (LicenseParserException ex) {
9292
// Add the expression to the error message to provide additional information to the user
93-
throw(new LicenseParserException(ex.getMessage()+" License expression: '"+expression+"'", ex));
93+
throw new LicenseParserException(ex.getMessage()+" License expression: '"+expression+"'", ex);
9494
} catch (EmptyStackException ex) {
95-
throw(new LicenseParserException("Invalid license expression: '"+expression+"' - check that every operator (e.g. AND and OR) has operators and that parenthesis are matched"));
95+
throw new LicenseParserException("Invalid license expression: '"+expression+"' - check that every operator (e.g. AND and OR) has operators and that parenthesis are matched");
9696
}
9797
}
9898
}
@@ -145,7 +145,7 @@ private static void processPreToken(String preToken,
145145
private static AnyLicenseInfo parseLicenseExpression(String[] tokens, IModelStore store,
146146
String documentUri, ModelCopyManager copyManager) throws InvalidSPDXAnalysisException {
147147
if (tokens == null || tokens.length == 0) {
148-
throw(new LicenseParserException("Expected license expression"));
148+
throw new LicenseParserException("Expected license expression");
149149
}
150150
Stack<AnyLicenseInfo> operandStack = new Stack<AnyLicenseInfo>();
151151
Stack<Operator> operatorStack = new Stack<Operator>();
@@ -157,7 +157,7 @@ private static AnyLicenseInfo parseLicenseExpression(String[] tokens, IModelStor
157157
if (LEFT_PAREN.equals(token)) {
158158
int rightParenIndex = findMatchingParen(tokens, tokenIndex);
159159
if (rightParenIndex < 0) {
160-
throw(new LicenseParserException("Missing right parenthesis"));
160+
throw new LicenseParserException("Missing right parenthesis");
161161
}
162162
String[] nestedTokens = Arrays.copyOfRange(tokens, tokenIndex, rightParenIndex);
163163
operandStack.push(parseLicenseExpression(nestedTokens, store, documentUri, copyManager));
@@ -173,7 +173,7 @@ private static AnyLicenseInfo parseLicenseExpression(String[] tokens, IModelStor
173173
evaluateExpression(tosOperator, operandStack, store, documentUri, copyManager);
174174
}
175175
if (tokenIndex >= tokens.length) {
176-
throw(new LicenseParserException("Missing exception clause"));
176+
throw new LicenseParserException("Missing exception clause");
177177
}
178178
token = tokens[tokenIndex++];
179179
LicenseException licenseException = null;
@@ -189,10 +189,10 @@ private static AnyLicenseInfo parseLicenseExpression(String[] tokens, IModelStor
189189
}
190190
AnyLicenseInfo operand = operandStack.pop();
191191
if (operand == null) {
192-
throw(new LicenseParserException("Missing license for with clause"));
192+
throw new LicenseParserException("Missing license for with clause");
193193
}
194194
if (!((operand instanceof SimpleLicensingInfo) || (operand instanceof OrLaterOperator))) {
195-
throw(new LicenseParserException("License with exception is not of type SimpleLicensingInfo or OrLaterOperator"));
195+
throw new LicenseParserException("License with exception is not of type SimpleLicensingInfo or OrLaterOperator");
196196
}
197197
WithExceptionOperator weo = new WithExceptionOperator(store, documentUri, store.getNextId(IdType.Anonymous, documentUri), copyManager, true);
198198
weo.setLicense(operand);
@@ -216,7 +216,7 @@ private static AnyLicenseInfo parseLicenseExpression(String[] tokens, IModelStor
216216
}
217217
AnyLicenseInfo retval = operandStack.pop();
218218
if (!operandStack.isEmpty()) {
219-
throw(new LicenseParserException("Invalid license expression. Expecting more operands."));
219+
throw new LicenseParserException("Invalid license expression. Expecting more operands.");
220220
}
221221
return retval;
222222
}
@@ -311,7 +311,7 @@ private static void evaluateExpression(Operator operator,
311311
// unary operator
312312
AnyLicenseInfo license = operandStack.pop();
313313
if (!(license instanceof SimpleLicensingInfo)) {
314-
throw(new LicenseParserException("Missing license for the '+' or later operator"));
314+
throw new LicenseParserException("Missing license for the '+' or later operator");
315315
}
316316
OrLaterOperator olo = new OrLaterOperator(store, documentUri, store.getNextId(IdType.Anonymous, documentUri), copyManager, true);
317317
olo.setLicense((SimpleLicensingInfo)license);
@@ -321,7 +321,7 @@ private static void evaluateExpression(Operator operator,
321321
AnyLicenseInfo operand2 = operandStack.pop();
322322
AnyLicenseInfo operand1 = operandStack.pop();
323323
if (operand1 == null || operand2 == null) {
324-
throw(new LicenseParserException("Missing operands for the "+operator.toString()+" operator"));
324+
throw new LicenseParserException("Missing operands for the "+operator.toString()+" operator");
325325
}
326326
operandStack.push(evaluateBinary(operator, operand1, operand2, store, documentUri, copyManager));
327327
}
@@ -364,7 +364,7 @@ private static AnyLicenseInfo evaluateBinary(Operator tosOperator,
364364
return retval;
365365
}
366366
} else {
367-
throw(new LicenseParserException("Unknown operator "+tosOperator.toString()));
367+
throw new LicenseParserException("Unknown operator "+tosOperator.toString());
368368
}
369369
}
370370
}

src/main/java/org/spdx/library/referencetype/ListedReferenceTypes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private void loadReferenceTypeNames() {
9999
listedReferenceTypesModificationLock.readLock().lock();
100100
try {
101101
String referenceTypeNamesStr = this.listedReferenceTypeProperties.getProperty(PROPERTY_LISTED_REFERENCE_TYPES);
102-
String[] referenceTypeNamesAr = referenceTypeNamesStr.split(",");
102+
String[] referenceTypeNamesAr = referenceTypeNamesStr.split(",", -1);
103103
for (String name:referenceTypeNamesAr) {
104104
this.listedReferenceNames.add(name.trim());
105105
}
@@ -165,10 +165,10 @@ public URI getListedReferenceUri(String listedReferenceName) throws InvalidSPDXA
165165
retval = new URI(SpdxConstants.SPDX_LISTED_REFERENCE_TYPES_PREFIX + listedReferenceName);
166166
} catch (URISyntaxException e) {
167167
logger.error("Error forming listed license URI",e);
168-
throw(new InvalidSPDXAnalysisException(listedReferenceName + " is not a valid SPDX listed reference type syntax."));
168+
throw new InvalidSPDXAnalysisException(listedReferenceName + " is not a valid SPDX listed reference type syntax.");
169169
}
170170
if (!isListedReferenceType(retval)) {
171-
throw(new InvalidSPDXAnalysisException(listedReferenceName + " is not a valid SPDX listed reference type."));
171+
throw new InvalidSPDXAnalysisException(listedReferenceName + " is not a valid SPDX listed reference type.");
172172
}
173173
return retval;
174174
}
@@ -194,7 +194,7 @@ public ReferenceType getListedReferenceTypeByName(String listedReferenceName) th
194194
*/
195195
public String getListedReferenceName(URI uri) throws InvalidSPDXAnalysisException {
196196
if (!this.isListedReferenceType(uri)) {
197-
throw(new InvalidSPDXAnalysisException(uri.toString() + " is not a valid URI for an SPDX listed reference type."));
197+
throw new InvalidSPDXAnalysisException(uri.toString() + " is not a valid URI for an SPDX listed reference type.");
198198
}
199199
return uri.toString().substring(SpdxConstants.SPDX_LISTED_REFERENCE_TYPES_PREFIX.length());
200200
}

src/main/java/org/spdx/licenseTemplate/LicenseTemplateRule.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ public String toString() {
8585
*/
8686
public void validate() throws LicenseTemplateRuleException {
8787
if (this.type == null) {
88-
throw(new LicenseTemplateRuleException("Rule type can not be null."));
88+
throw new LicenseTemplateRuleException("Rule type can not be null.");
8989
}
9090
if (this.type == RuleType.VARIABLE && this.name == null) {
91-
throw(new LicenseTemplateRuleException("Rule name can not be null for a variable or alt rule."));
91+
throw new LicenseTemplateRuleException("Rule name can not be null for a variable or alt rule.");
9292
}
9393
if (this.type == RuleType.VARIABLE && this.original == null) {
94-
throw(new LicenseTemplateRuleException("Rule original text can not be null."));
94+
throw new LicenseTemplateRuleException("Rule original text can not be null.");
9595
}
9696
if (this.type == RuleType.VARIABLE && this.match == null) {
97-
throw(new LicenseTemplateRuleException("Rule match regular expression can not be null."));
97+
throw new LicenseTemplateRuleException("Rule match regular expression can not be null.");
9898
}
9999
}
100100

@@ -172,7 +172,7 @@ private RuleType typeStringToType(String typeStr) throws LicenseTemplateRuleExce
172172
} else if (typeStr.equals(END_OPTIONAL_TYPE_STR)) {
173173
return RuleType.END_OPTIONAL;
174174
} else {
175-
throw(new LicenseTemplateRuleException("Unknown rule type: "+typeStr));
175+
throw new LicenseTemplateRuleException("Unknown rule type: "+typeStr);
176176
}
177177
}
178178

@@ -260,7 +260,7 @@ private void parseRulePart(String rulePart) throws LicenseTemplateRuleException
260260
} else if (rulePart.startsWith(MATCH_KEYWORD)) {
261261
this.match = getValue(rulePart, MATCH_KEYWORD);
262262
} else {
263-
throw(new LicenseTemplateRuleException("Unknown rule keyword: "+rulePart));
263+
throw new LicenseTemplateRuleException("Unknown rule keyword: "+rulePart);
264264
}
265265
}
266266

@@ -286,7 +286,7 @@ private String getValue(String rulePart, String keyword) throws LicenseTemplateR
286286
String retval = rulePart.substring(keyword.length());
287287
retval = retval.trim();
288288
if (!retval.startsWith(VALUE_SEPARATOR)) {
289-
throw(new LicenseTemplateRuleException("Missing "+VALUE_SEPARATOR+" for "+keyword));
289+
throw new LicenseTemplateRuleException("Missing "+VALUE_SEPARATOR+" for "+keyword);
290290
}
291291
retval = retval.substring(1).trim();
292292
if (retval.startsWith("\"")) {

src/main/java/org/spdx/utility/compare/LicenseCompareHelper.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -629,9 +629,9 @@ public static List<String> getNonOptionalLicenseText(String licenseTemplate, boo
629629
try {
630630
SpdxLicenseTemplateHelper.parseTemplate(licenseTemplate, filteredOutput);
631631
} catch (LicenseTemplateRuleException e) {
632-
throw(new SpdxCompareException("Invalid template rule found during filter: "+e.getMessage(),e));
632+
throw new SpdxCompareException("Invalid template rule found during filter: "+e.getMessage(),e);
633633
} catch (LicenseParserException e) {
634-
throw(new SpdxCompareException("Invalid template found during filter: "+e.getMessage(),e));
634+
throw new SpdxCompareException("Invalid template found during filter: "+e.getMessage(),e);
635635
}
636636
return filteredOutput.getFilteredText();
637637
}
@@ -720,15 +720,15 @@ public static DifferenceDescription isTextStandardLicense(License license, Strin
720720
try {
721721
compareTemplateOutputHandler = new CompareTemplateOutputHandler(removeCommentChars(compareText));
722722
} catch (IOException e1) {
723-
throw(new SpdxCompareException("IO Error reading the compare text: "+e1.getMessage(),e1));
723+
throw new SpdxCompareException("IO Error reading the compare text: "+e1.getMessage(),e1);
724724
}
725725
try {
726726
//TODO: The remove comment chars will not be removed for lines beginning with a template << or ending with >>
727727
SpdxLicenseTemplateHelper.parseTemplate(removeCommentChars(licenseTemplate), compareTemplateOutputHandler);
728728
} catch (LicenseTemplateRuleException e) {
729-
throw(new SpdxCompareException("Invalid template rule found during compare: "+e.getMessage(),e));
729+
throw new SpdxCompareException("Invalid template rule found during compare: "+e.getMessage(),e);
730730
} catch (LicenseParserException e) {
731-
throw(new SpdxCompareException("Invalid template found during compare: "+e.getMessage(),e));
731+
throw new SpdxCompareException("Invalid template found during compare: "+e.getMessage(),e);
732732
}
733733
return compareTemplateOutputHandler.getDifferences();
734734
}
@@ -750,15 +750,15 @@ public static DifferenceDescription isTextStandardException(LicenseException exc
750750
try {
751751
compareTemplateOutputHandler = new CompareTemplateOutputHandler(removeCommentChars(compareText));
752752
} catch (IOException e1) {
753-
throw(new SpdxCompareException("IO Error reading the compare text: "+e1.getMessage(),e1));
753+
throw new SpdxCompareException("IO Error reading the compare text: "+e1.getMessage(),e1);
754754
}
755755
try {
756756
//TODO: The remove comment chars will not be removed for lines beginning with a template << or ending with >>
757757
SpdxLicenseTemplateHelper.parseTemplate(removeCommentChars(exceptionTemplate), compareTemplateOutputHandler);
758758
} catch (LicenseTemplateRuleException e) {
759-
throw(new SpdxCompareException("Invalid template rule found during compare: "+e.getMessage(),e));
759+
throw new SpdxCompareException("Invalid template rule found during compare: "+e.getMessage(),e);
760760
} catch (LicenseParserException e) {
761-
throw(new SpdxCompareException("Invalid template found during compare: "+e.getMessage(),e));
761+
throw new SpdxCompareException("Invalid template found during compare: "+e.getMessage(),e);
762762
}
763763
return compareTemplateOutputHandler.getDifferences();
764764
}

0 commit comments

Comments
 (0)