Skip to content

Commit 19433a8

Browse files
committed
code cleanup
1 parent fcdd473 commit 19433a8

File tree

7 files changed

+14
-24
lines changed

7 files changed

+14
-24
lines changed

src/main/java/org/htmlunit/html/DomNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ else if (previousSibling_ != null && previousSibling_.nextSibling_ == this) {
11731173

11741174
private void fireRemoval(final DomNode exParent) {
11751175
final SgmlPage page = getPage();
1176-
if (page != null && page instanceof HtmlPage) {
1176+
if (page instanceof HtmlPage) {
11771177
// some actions executed on removal need an intact parent relationship (e.g. for the
11781178
// DocumentPositionComparator) so we have to restore it temporarily
11791179
parent_ = exParent;

src/main/java/org/htmlunit/html/xpath/XPathAdapter.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ private enum STATE {
4545
}
4646

4747
private final Expression mainExp_;
48-
private FunctionTable funcTable_;
49-
50-
/**
51-
* Initiates the function table.
52-
*/
53-
private void initFunctionTable() {
54-
funcTable_ = new FunctionTable();
55-
}
5648

5749
/**
5850
* Constructor.
@@ -64,11 +56,9 @@ private void initFunctionTable() {
6456
public XPathAdapter(final String exprString, final PrefixResolver prefixResolver, final boolean caseSensitive)
6557
throws TransformerException {
6658

67-
initFunctionTable();
68-
6959
final ErrorListener errorHandler = new DefaultErrorHandler();
7060
final XPathParser parser = new XPathParser(errorHandler);
71-
final Compiler compiler = new Compiler(errorHandler, funcTable_);
61+
final Compiler compiler = new Compiler(errorHandler, new FunctionTable());
7262

7363
final String expression = preProcessXPath(exprString, caseSensitive);
7464
parser.initXPath(compiler, expression, prefixResolver);

src/main/java/org/htmlunit/javascript/host/dom/DOMException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public class DOMException extends HtmlUnitScriptable {
140140
@JsxConstant
141141
public static final int DATA_CLONE_ERR = 25;
142142

143-
private static final List<String> COMMON_ERROR_NAMES = Arrays.asList(new String[] {
143+
private static final List<String> COMMON_ERROR_NAMES = Arrays.asList(
144144
"IndexSizeError",
145145
null,
146146
"HierarchyRequestError",
@@ -165,7 +165,7 @@ public class DOMException extends HtmlUnitScriptable {
165165
"QuotaExceededError",
166166
"TimeoutError",
167167
"InvalidNodeTypeError",
168-
"DataCloneError"});
168+
"DataCloneError");
169169

170170
private int code_;
171171
private String name_;

src/main/java/org/htmlunit/javascript/host/file/FileList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public FileList(final java.io.File[] array) {
5959
super();
6060
files_ = new ArrayList<>();
6161

62-
for (int i = 0; i < array.length; i++) {
63-
files_.add(new File(array[i].getAbsolutePath()));
62+
for (final java.io.File f : array) {
63+
files_.add(new File(f.getAbsolutePath()));
6464
}
6565
}
6666

src/main/java/org/htmlunit/util/ArrayUtils.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,21 @@ private ArrayUtils() {
2929
}
3030

3131
/**
32-
* @param s the string[] to check
32+
* @param strings the string[] to check
3333
* @param expected the string that we expect
3434
* @return true if at least one element of the array equalsIgnoreCase to the expected string
3535
*/
36-
public static boolean containsIgnoreCase(final String[] s, final String expected) {
36+
public static boolean containsIgnoreCase(final String[] strings, final String expected) {
3737
if (expected == null) {
3838
throw new IllegalArgumentException("Expected string can't be null");
3939
}
4040

41-
if (s == null) {
41+
if (strings == null) {
4242
return false;
4343
}
4444

45-
for (int i = 0; i < s.length; i++) {
46-
final String string = s[i];
47-
if (expected.equalsIgnoreCase(string)) {
45+
for (final String s : strings) {
46+
if (expected.equalsIgnoreCase(s)) {
4847
return true;
4948
}
5049
}

src/main/java/org/htmlunit/util/EncodingSniffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ public static Charset sniffEncodingFromXmlDeclaration(final InputStream is) thro
475475
int start = declaration.indexOf("encoding");
476476
if (start != -1) {
477477
start += 8;
478-
char delimiter;
478+
final char delimiter;
479479
outer:
480480
while (true) {
481481
switch (declaration.charAt(start)) {

src/main/java/org/htmlunit/xml/XmlPage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public XmlPage(final WebResponse webResponse, final WebWindow enclosingWindow, f
127127
LOG.warn("Failed parsing XML document '" + webResponse.getWebRequest().getUrl() + "'", e);
128128
}
129129
if (!ignoreSAXException) {
130-
throw new IOException(e.getMessage());
130+
throw new IOException(
131+
"Failed parsing XML document '" + webResponse.getWebRequest().getUrl() + "'", e);
131132
}
132133
}
133134
}

0 commit comments

Comments
 (0)