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 15fe85c commit e50d40a
Show file tree
Hide file tree
Showing 31 changed files with 186 additions and 94 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/htmlunit/xpath/Expression.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ public DTMIterator asIterator(final XPathContext xctxt, final int contextNode)
xctxt.pushCurrentNodeAndExpression(contextNode);

return execute(xctxt).iter();
} finally {
}
finally {
xctxt.popCurrentNodeAndExpression();
}
}
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/org/htmlunit/xpath/compiler/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ protected Expression union(final int opPos) throws TransformerException {
locPathDepth++;
try {
return UnionPathIterator.createUnionIterator(this, opPos);
} finally {
}
finally {
locPathDepth--;
}
}
Expand Down Expand Up @@ -506,7 +507,8 @@ public Expression locationPath(final int opPos) throws TransformerException {
try {
final DTMIterator iter = WalkerFactory.newDTMIterator(this, opPos, locPathDepth == 0);
return (Expression) iter; // cast OK, I guess.
} finally {
}
finally {
locPathDepth--;
}
}
Expand Down Expand Up @@ -554,7 +556,8 @@ protected Expression matchPattern(int opPos) throws TransformerException {
up.setPatterns(patterns);

return up;
} finally {
}
finally {
locPathDepth--;
}
}
Expand Down Expand Up @@ -750,7 +753,8 @@ protected StepPattern stepPattern(
* pattern.getStaticScore(); pattern.setRelativePathPattern(selfPattern);
* pattern.setStaticScore(score); selfPattern.setStaticScore(score); }
*/
} else {
}
else {
// System.out.println("Setting "+ancestorPattern+" as relative to "+pattern);
pattern.setRelativePathPattern(ancestorPattern);
}
Expand Down Expand Up @@ -860,7 +864,8 @@ Expression compileFunction(int opPos) throws TransformerException {
}

func.checkNumberArgs(i);
} catch (final WrongNumberArgsException wnae) {
}
catch (final WrongNumberArgsException wnae) {
final String name = m_functionTable.getFunctionName(funcID);

error(XPATHErrorResources.ER_ONLY_ALLOWS, new Object[] {name, wnae.getMessage()});
Expand All @@ -879,7 +884,8 @@ public void error(final String msg, final Object[] args) throws TransformerExcep

if (null != m_errorHandler) {
m_errorHandler.fatalError(new TransformerException(fmsg));
} else {
}
else {
throw new TransformerException(fmsg);
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/htmlunit/xpath/compiler/FunctionTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ public class FunctionTable {
Keywords.FUNC_STRING_LENGTH_STRING, Integer.valueOf(FunctionTable.FUNC_STRING_LENGTH));
}

public FunctionTable() {}
public FunctionTable() {
}

/**
* Return the name of the a function in the static table. Needed to avoid making the table
Expand All @@ -225,7 +226,8 @@ Function getFunction(final int which) throws javax.xml.transform.TransformerExce
try {
if (which < NUM_BUILT_IN_FUNCS) return (Function) m_functions[which].newInstance();
return (Function) m_functions_customer[which - NUM_BUILT_IN_FUNCS].newInstance();
} catch (IllegalAccessException | InstantiationException ex) {
}
catch (IllegalAccessException | InstantiationException ex) {
throw new TransformerException(ex.getMessage());
}
}
Expand Down Expand Up @@ -264,7 +266,8 @@ public int installFunction(final String name, final Class<?> func) {
m_functionID_customer.put(name, Integer.valueOf(funcIndex));
}
m_functions_customer[funcIndex - NUM_BUILT_IN_FUNCS] = func;
} else {
}
else {
funcIndex = m_funcNextFreeIndex++;

m_functions_customer[funcIndex - NUM_BUILT_IN_FUNCS] = func;
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/org/htmlunit/xpath/compiler/OpMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public int getNextStepPos(final int opPos) {

if ((stepType >= OpCodes.AXES_START_TYPES) && (stepType <= OpCodes.AXES_END_TYPES)) {
return getNextOpPos(opPos);
} else if ((stepType >= OpCodes.FIRST_NODESET_OP) && (stepType <= OpCodes.LAST_NODESET_OP)) {
}
else if ((stepType >= OpCodes.FIRST_NODESET_OP) && (stepType <= OpCodes.LAST_NODESET_OP)) {
int newOpPos = getNextOpPos(opPos);

while (OpCodes.OP_PREDICATE == getOp(newOpPos)) {
Expand All @@ -162,7 +163,8 @@ public int getNextStepPos(final int opPos) {
}

return newOpPos;
} else {
}
else {
throw new RuntimeException(
XPATHMessages.createXPATHMessage(
XPATHErrorResources.ER_UNKNOWN_STEP, new Object[] {String.valueOf(stepType)}));
Expand All @@ -185,11 +187,14 @@ public int getFirstPredicateOpPos(final int opPos)

if ((stepType >= OpCodes.AXES_START_TYPES) && (stepType <= OpCodes.AXES_END_TYPES)) {
return opPos + m_opMap.elementAt(opPos + 2);
} else if ((stepType >= OpCodes.FIRST_NODESET_OP) && (stepType <= OpCodes.LAST_NODESET_OP)) {
}
else if ((stepType >= OpCodes.FIRST_NODESET_OP) && (stepType <= OpCodes.LAST_NODESET_OP)) {
return opPos + m_opMap.elementAt(opPos + 1);
} else if (-2 == stepType) {
}
else if (-2 == stepType) {
return -2;
} else {
}
else {
error(
org.htmlunit.xpath.res.XPATHErrorResources.ER_UNKNOWN_OPCODE,
new Object[] {String.valueOf(stepType)});
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/htmlunit/xpath/functions/FuncId.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ public XObject execute(final XPathContext xctxt) throws javax.xml.transform.Tran
usedrefs = getNodesByID(xctxt, docContext, refval, usedrefs, nodeSet, DTM.NULL != pos);
}
// ni.detach();
} else if (XObject.CLASS_NULL == argType) {
}
else if (XObject.CLASS_NULL == argType) {
return nodes;
} else {
}
else {
final String refval = arg.str();

getNodesByID(xctxt, docContext, refval, null, nodeSet, false);
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/htmlunit/xpath/functions/FuncNamespace.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public XObject execute(final XPathContext xctxt) throws javax.xml.transform.Tran
final int t = dtm.getNodeType(context);
if (t == DTM.ELEMENT_NODE) {
s = dtm.getNamespaceURI(context);
} else if (t == DTM.ATTRIBUTE_NODE) {
}
else if (t == DTM.ATTRIBUTE_NODE) {

// This function always returns an empty string for namespace nodes.
// We check for those here. Fix inspired by Davanum Srinivas.
Expand All @@ -46,8 +47,10 @@ public XObject execute(final XPathContext xctxt) throws javax.xml.transform.Tran
if (s.startsWith("xmlns:") || s.equals("xmlns")) return XString.EMPTYSTRING;

s = dtm.getNamespaceURI(context);
} else return XString.EMPTYSTRING;
} else return XString.EMPTYSTRING;
}
else return XString.EMPTYSTRING;
}
else return XString.EMPTYSTRING;

return (null == s) ? XString.EMPTYSTRING : new XString(s);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/htmlunit/xpath/functions/FuncQname.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public XObject execute(final XPathContext xctxt) throws javax.xml.transform.Tran
final DTM dtm = xctxt.getDTM(context);
final String qname = dtm.getNodeNameX(context);
val = (null == qname) ? XString.EMPTYSTRING : new XString(qname);
} else {
}
else {
val = XString.EMPTYSTRING;
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/htmlunit/xpath/functions/FuncSubstring.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public XObject execute(final XPathContext xctxt) throws javax.xml.transform.Tran
// so just use a big number and hope I never get caught.
start = -1000000;
startIndex = 0;
} else {
}
else {
start = Math.round(start);
startIndex = (start > 0) ? (int) start - 1 : 0;
}
Expand All @@ -67,7 +68,8 @@ public XObject execute(final XPathContext xctxt) throws javax.xml.transform.Tran
if (startIndex > lenOfS1) startIndex = lenOfS1;

substr = s1.substring(startIndex, end);
} else {
}
else {
if (startIndex > lenOfS1) startIndex = lenOfS1;
substr = s1.substring(startIndex);
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/htmlunit/xpath/functions/FuncTranslate.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ public XObject execute(final XPathContext xctxt) throws javax.xml.transform.Tran
// Didn't find the character in the second string, so it
// is not translated.
sbuffer.append(theCurrentChar);
} else if (theIndex < theThirdStringLength) {
}
else if (theIndex < theThirdStringLength) {

// OK, there's a corresponding character in the
// third string, so do the translation...
sbuffer.append(theThirdString.charAt(theIndex));
} else {
}
else {

// There's no corresponding character in the
// third string, since it's shorter than the
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/htmlunit/xpath/functions/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public XObject execute(final XPathContext xctxt) throws javax.xml.transform.Tran
}

/** Call the visitors for the function arguments. */
public void callArgVisitors(final XPathVisitor visitor) {}
public void callArgVisitors(final XPathVisitor visitor) {
}

/** {@inheritDoc} */
@Override
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/htmlunit/xpath/functions/Function2Args.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public void setArg(final Expression arg, final int argNum) throws WrongNumberArg
else if (1 == argNum) {
m_arg1 = arg;
arg.exprSetParent(this);
} else reportWrongNumberArgs();
}
else reportWrongNumberArgs();
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -76,7 +77,8 @@ public boolean deepEquals(final Expression expr) {
if (null != m_arg1) {
if ((null == ((Function2Args) expr).m_arg1)
|| !m_arg1.deepEquals(((Function2Args) expr).m_arg1)) return false;
} else if (null != ((Function2Args) expr).m_arg1) return false;
}
else if (null != ((Function2Args) expr).m_arg1) return false;

return true;
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/htmlunit/xpath/functions/Function3Args.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ public void setArg(final Expression arg, final int argNum) throws WrongNumberArg

if (argNum < 2) {
super.setArg(arg, argNum);
} else if (2 == argNum) {
}
else if (2 == argNum) {
arg2_ = arg;
arg.exprSetParent(this);
} else {
}
else {
reportWrongNumberArgs();
}
}
Expand Down Expand Up @@ -78,7 +80,8 @@ public boolean deepEquals(final Expression expr) {
if (null != arg2_) {
if ((null == ((Function3Args) expr).arg2_) || !arg2_.deepEquals(((Function3Args) expr).arg2_))
return false;
} else if (null != ((Function3Args) expr).arg2_) return false;
}
else if (null != ((Function3Args) expr).arg2_) return false;

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public void setArg(final Expression arg, final int argNum) throws WrongNumberArg
if (null == args_) {
args_ = new Expression[1];
args_[0] = arg;
} else {

}
else {
// Slow but space conservative.
final Expression[] args = new Expression[args_.length + 1];

Expand All @@ -57,7 +57,8 @@ public void setArg(final Expression arg, final int argNum) throws WrongNumberArg

/** {@inheritDoc} */
@Override
public void checkNumberArgs(final int argNum) throws WrongNumberArgsException {}
public void checkNumberArgs(final int argNum) throws WrongNumberArgsException {
}

/** {@inheritDoc} */
@Override
Expand Down Expand Up @@ -114,7 +115,8 @@ public boolean deepEquals(final Expression expr) {
if (!args_[i].deepEquals(fma.args_[i])) return false;
}

} else if (null != fma.args_) {
}
else if (null != fma.args_) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public void setArg(final Expression arg, final int argNum) throws WrongNumberArg
if (0 == argNum) {
m_arg0 = arg;
arg.exprSetParent(this);
} else reportWrongNumberArgs();
}
else reportWrongNumberArgs();
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -73,7 +74,8 @@ public boolean deepEquals(final Expression expr) {
if (null != m_arg0) {
if ((null == ((FunctionOneArg) expr).m_arg0)
|| !m_arg0.deepEquals(((FunctionOneArg) expr).m_arg0)) return false;
} else if (null != ((FunctionOneArg) expr).m_arg0) return false;
}
else if (null != ((FunctionOneArg) expr).m_arg0) return false;

return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/htmlunit/xpath/objects/XBoolean.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public boolean equals(final XObject obj2) {

try {
return m_val == obj2.bool();
} catch (final javax.xml.transform.TransformerException te) {
}
catch (final javax.xml.transform.TransformerException te) {
throw new org.htmlunit.xpath.xml.utils.WrappedRuntimeException(te);
}
}
Expand Down
Loading

0 comments on commit e50d40a

Please sign in to comment.