Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Dec 10, 2023
1 parent e50d40a commit 5af22a4
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 58 deletions.
46 changes: 31 additions & 15 deletions src/main/java/org/htmlunit/xpath/XPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,25 @@ public XPath(
ErrorListener errorListener)
throws javax.xml.transform.TransformerException {
initFunctionTable();
if (null == errorListener)
if (null == errorListener) {
errorListener = new org.htmlunit.xpath.xml.utils.DefaultErrorHandler();
}

final XPathParser parser = new XPathParser(errorListener);
final Compiler compiler = new Compiler(errorListener, m_funcTable);

if (SELECT == type) parser.initXPath(compiler, exprString, prefixResolver);
else if (MATCH == type) parser.initMatchPattern(compiler, exprString, prefixResolver);
else
throw new RuntimeException(
XPATHMessages.createXPATHMessage(
XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE,
new Object[] {Integer.toString(type)}));
if (SELECT == type) {
parser.initXPath(compiler, exprString, prefixResolver);
}
else if (MATCH == type) {
parser.initMatchPattern(compiler, exprString, prefixResolver);
}
else {
throw new RuntimeException(
XPATHMessages.createXPATHMessage(
XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE,
new Object[] {Integer.toString(type)}));
}

m_mainExp = compiler.compile(0);
}
Expand All @@ -121,19 +127,25 @@ public XPath(
final FunctionTable aTable)
throws javax.xml.transform.TransformerException {
m_funcTable = aTable;
if (null == errorListener)
if (null == errorListener) {
errorListener = new org.htmlunit.xpath.xml.utils.DefaultErrorHandler();
}

final XPathParser parser = new XPathParser(errorListener);
final Compiler compiler = new Compiler(errorListener, m_funcTable);

if (SELECT == type) parser.initXPath(compiler, exprString, prefixResolver);
else if (MATCH == type) parser.initMatchPattern(compiler, exprString, prefixResolver);
else
if (SELECT == type) {
parser.initXPath(compiler, exprString, prefixResolver);
}
else if (MATCH == type) {
parser.initMatchPattern(compiler, exprString, prefixResolver);
}
else {
throw new RuntimeException(
XPATHMessages.createXPATHMessage(
XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE,
new Object[] {Integer.toString(type)}));
}

m_mainExp = compiler.compile(0);
}
Expand Down Expand Up @@ -210,10 +222,12 @@ public XObject execute(
catch (final TransformerException te) {
te.setLocator(this.getLocator());
final ErrorListener el = xctxt.getErrorListener();
if (null != el) {// defensive, should never happen.
if (null != el) { // defensive, should never happen.
el.error(te);
}
else throw te;
else {
throw te;
}
}
catch (Exception e) {
while (e instanceof org.htmlunit.xpath.xml.utils.WrappedRuntimeException) {
Expand All @@ -230,7 +244,9 @@ public XObject execute(
if (null != el) { // defensive, should never happen.
el.fatalError(te);
}
else throw te;
else {
throw te;
}
}
finally {
xctxt.popNamespaceContext();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/htmlunit/xpath/xml/dtm/DTM.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public interface DTM {
* @param axis One of Axes.ANCESTORORSELF, etc.
* @return A DTMAxisIterator, or null if the givin axis isn't supported.
*/
DTMAxisTraverser getAxisTraverser(final int axis);
DTMAxisTraverser getAxisTraverser(int axis);

/**
* This is a shortcut to the iterators that implement XPath axes. Returns a bare-bones iterator
Expand All @@ -133,7 +133,7 @@ public interface DTM {
* @param axis One of Axes.ANCESTORORSELF, etc.
* @return A DTMAxisIterator, or null if the givin axis isn't supported.
*/
DTMAxisIterator getAxisIterator(final int axis);
DTMAxisIterator getAxisIterator(int axis);

/**
* Given a node handle, get the handle of the node's first child.
Expand Down
Loading

0 comments on commit 5af22a4

Please sign in to comment.