Skip to content

Commit 5170f6b

Browse files
committed
cleanup
1 parent 0543c67 commit 5170f6b

8 files changed

Lines changed: 17 additions & 27 deletions

File tree

src/main/java/org/htmlunit/cyberneko/HTMLNamedEntitiesParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,12 @@ private HTMLNamedEntitiesParser() {
8686

8787
props.forEach((k, v) -> {
8888
String key = (String) k;
89-
final String value = (String) v;
90-
9189
// we might have an empty line in it
9290
if (key.trim().isEmpty()) {
9391
return;
9492
}
9593

94+
final String value = (String) v;
9695
rootLevel_.add(key, value);
9796

9897
key = "&" + key;

src/main/java/org/htmlunit/cyberneko/filters/HTMLWriterFilter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.UnsupportedEncodingException;
2222
import java.io.Writer;
2323
import java.nio.charset.StandardCharsets;
24+
import java.util.Locale;
2425

2526
import org.htmlunit.cyberneko.HTMLElements;
2627
import org.htmlunit.cyberneko.HTMLNamedEntitiesParser;
@@ -238,7 +239,7 @@ protected void printStartElement(final QName element, final XMLAttributes attrib
238239
String httpEquiv = null;
239240
final int length = attributes.getLength();
240241
for (int i = 0; i < length; i++) {
241-
final String aname = attributes.getQName(i).toLowerCase();
242+
final String aname = attributes.getQName(i).toLowerCase(Locale.ROOT);
242243
if ("http-equiv".equals(aname)) {
243244
httpEquiv = attributes.getValue(i);
244245
}
@@ -250,7 +251,7 @@ else if ("content".equals(aname)) {
250251
String content = null;
251252
if (contentIndex != -1) {
252253
originalContent = attributes.getValue(contentIndex);
253-
content = originalContent.toLowerCase();
254+
content = originalContent.toLowerCase(Locale.ROOT);
254255
}
255256
if (content != null) {
256257
final int charsetIndex = content.indexOf("charset=");

src/main/java/org/htmlunit/cyberneko/html/dom/HTMLDOMImplementationImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ private HTMLDOMImplementationImpl() {
5454
*/
5555
@Override
5656
public HTMLDocument createHTMLDocument(final String title) throws DOMException {
57-
final HTMLDocument doc;
58-
5957
if (title == null) {
6058
throw new NullPointerException("HTM014 Argument 'title' is null.");
6159
}
62-
doc = new HTMLDocumentImpl();
60+
61+
final HTMLDocument doc = new HTMLDocumentImpl();
6362
doc.setTitle(title);
6463
return doc;
6564
}

src/main/java/org/htmlunit/cyberneko/html/dom/HTMLDocumentImpl.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,11 @@ public HTMLDocumentImpl() {
252252

253253
@Override
254254
public synchronized Element getDocumentElement() {
255-
Node html;
256-
Node child;
257-
Node next;
258-
259255
// The document element is the top-level HTML element of the HTML
260256
// document. Only this element should exist at the top level.
261257
// If the HTML element is found, all other elements that might
262258
// precede it are placed inside the HTML element.
263-
html = getFirstChild();
259+
Node html = getFirstChild();
264260
while (html != null) {
265261
if (html instanceof HTMLHtmlElement) {
266262
return (HTMLElement) html;
@@ -272,9 +268,9 @@ public synchronized Element getDocumentElement() {
272268
// entire contents of the document into it in the same order as
273269
// they appear now.
274270
html = new HTMLHtmlElementImpl(this, "HTML");
275-
child = getFirstChild();
271+
Node child = getFirstChild();
276272
while (child != null) {
277-
next = child.getNextSibling();
273+
final Node next = child.getNextSibling();
278274
html.appendChild(child);
279275
child = next;
280276
}

src/main/java/org/htmlunit/cyberneko/xerces/dom/DeepNodeListImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ public int getLength() {
112112
*/
113113
@Override
114114
public Node item(final int index) {
115-
Node thisNode;
116-
117115
// Tree changed. Do it all from scratch!
118116
if (rootNode_.changes() != changes_) {
119117
nodes_ = new ArrayList<>();
@@ -129,6 +127,7 @@ public Node item(final int index) {
129127
// Not yet seen
130128

131129
// Pick up where we left off (Which may be the beginning)
130+
Node thisNode;
132131
if (currentSize == 0) {
133132
thisNode = rootNode_;
134133
}

src/main/java/org/htmlunit/cyberneko/xerces/dom/ElementNSImpl.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,13 @@ protected ElementNSImpl(final CoreDocumentImpl ownerDocument, final String names
4848
}
4949

5050
private void setName(final String namespaceURI, final String qname) {
51-
final String prefix;
5251
// DOM Level 3: namespace URI is never empty string.
5352
this.namespaceURI = namespaceURI;
5453
if (namespaceURI != null) {
5554
// convert the empty string to 'null'
5655
this.namespaceURI = (namespaceURI.length() == 0) ? null : namespaceURI;
5756
}
5857

59-
final int colon1;
60-
final int colon2;
61-
6258
// NAMESPACE_ERR:
6359
// 1. if the qualified name is 'null' it is malformed.
6460
// 2. or if the qualifiedName is null and the namespaceURI is different from
@@ -70,8 +66,8 @@ private void setName(final String namespaceURI, final String qname) {
7066
throw new DOMException(DOMException.NAMESPACE_ERR, msg);
7167
}
7268

73-
colon1 = qname.indexOf(':');
74-
colon2 = qname.lastIndexOf(':');
69+
final int colon1 = qname.indexOf(':');
70+
final int colon2 = qname.lastIndexOf(':');
7571

7672
ownerDocument.checkNamespaceWF(qname, colon1, colon2);
7773
if (colon1 < 0) {
@@ -88,7 +84,7 @@ private void setName(final String namespaceURI, final String qname) {
8884
}
8985
}
9086
else {
91-
prefix = qname.substring(0, colon1);
87+
final String prefix = qname.substring(0, colon1);
9288
localName = qname.substring(colon2 + 1);
9389

9490
// NAMESPACE_ERR:

src/main/java/org/htmlunit/cyberneko/xerces/dom/NodeImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,8 @@ public short compareDocumentPosition(final Node other) throws DOMException {
725725

726726
Node node;
727727
Node thisAncestor = this;
728-
Node otherAncestor = other;
729728

730729
int thisDepth = 0;
731-
int otherDepth = 0;
732730
for (node = this; node != null; node = node.getParentNode()) {
733731
thisDepth += 1;
734732
if (node == other) {
@@ -738,6 +736,8 @@ public short compareDocumentPosition(final Node other) throws DOMException {
738736
thisAncestor = node;
739737
}
740738

739+
int otherDepth = 0;
740+
Node otherAncestor = other;
741741
for (node = other; node != null; node = node.getParentNode()) {
742742
otherDepth += 1;
743743
if (node == this) {

src/test/java/org/htmlunit/cyberneko/xerces/xni/XMLStringTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,8 +1353,8 @@ public void equalsIgnoreCase_Difference() {
13531353
@ParameterizedTest
13541354
@ValueSource(strings = { "éäöü€", "Ganyu (贛語 / 赣语)", "duże i małe litery", "большой и нижний регистр" })
13551355
public void equalsIgnoreCase_MoreChallengingLocales(final String s) {
1356-
final String upper = s.toUpperCase();
1357-
final String lower = s.toLowerCase();
1356+
final String upper = s.toUpperCase(Locale.ROOT);
1357+
final String lower = s.toLowerCase(Locale.ROOT);
13581358

13591359
final XMLString a = new XMLString(s);
13601360
final XMLString l = new XMLString(upper);

0 commit comments

Comments
 (0)