Skip to content

Commit

Permalink
improved getCommentText for null value
Browse files Browse the repository at this point in the history
  • Loading branch information
rainer-prosi committed Jun 25, 2024
1 parent 098111d commit 9942501
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/org/cip4/jdflib/core/JDFElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -4070,7 +4070,7 @@ public VString getInvalidElements_JDFElement(final EnumValidationLevel level, fi
vBad.appendUnique(new VString(getDeprecatedElements(nMax)));
if (nMax <= 0 || vBad.size() < nMax)
{
VString prereleaseElements = getPrereleaseElements(nMax);
final VString prereleaseElements = getPrereleaseElements(nMax);
vBad.appendUnique(new VString(prereleaseElements));
}
}
Expand Down Expand Up @@ -6338,7 +6338,9 @@ public JDFComment getComment(final String _name, final int index)
*/
public String getCommentText(final String _name, final int index)
{
final JDFComment c = getComment(_name, index);
JDFComment c = getComment(_name, index);
if (c == null && StringUtil.isEmpty(_name))
c = getComment(index);
return c == null ? null : c.getText();
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/cip4/jdflib/node/JDFNodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,12 @@ void testComment()
final JDFNode n = JDFNode.createRoot();
n.setCommentText("foo");
assertEquals("foo", n.getComment(0).getText());
assertEquals("foo", n.getCommentText(null, 0));
n.setCommentText("next", "bar");
assertEquals("next", n.getCommentText("bar", 0));
assertEquals(null, n.getCommentText("foo", 0));
assertEquals(null, n.getCommentText("bar", 1));
assertEquals("next", n.getCommentText(null, 1));
}

/**
Expand Down

0 comments on commit 9942501

Please sign in to comment.