Skip to content

Commit

Permalink
add final
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Dec 8, 2023
1 parent b9531b4 commit 0c39261
Show file tree
Hide file tree
Showing 20 changed files with 146 additions and 115 deletions.
33 changes: 17 additions & 16 deletions src/main/java/org/htmlunit/xpath/Expression.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public boolean canTraverseOutsideSubtree() {
* @return The result of the expression in the form of a <code>XObject</code>.
* @throws javax.xml.transform.TransformerException if a runtime exception occurs.
*/
public XObject execute(XPathContext xctxt, int currentNode)
public XObject execute(final XPathContext xctxt, final int currentNode)
throws javax.xml.transform.TransformerException {

// For now, the current node is already pushed.
Expand All @@ -75,7 +75,8 @@ public XObject execute(XPathContext xctxt, int currentNode)
* @return The result of the expression in the form of a <code>XObject</code>.
* @throws javax.xml.transform.TransformerException if a runtime exception occurs.
*/
public XObject execute(XPathContext xctxt, int currentNode, DTM dtm, int expType)
public XObject execute(
final XPathContext xctxt, final int currentNode, final DTM dtm, final int expType)
throws javax.xml.transform.TransformerException {

// For now, the current node is already pushed.
Expand All @@ -102,7 +103,7 @@ public abstract XObject execute(XPathContext xctxt)
* @return The result of the expression in the form of a <code>XObject</code>.
* @throws javax.xml.transform.TransformerException if a runtime exception occurs.
*/
public XObject execute(XPathContext xctxt, boolean destructiveOK)
public XObject execute(final XPathContext xctxt, final boolean destructiveOK)
throws javax.xml.transform.TransformerException {
return execute(xctxt);
}
Expand All @@ -114,7 +115,7 @@ public XObject execute(XPathContext xctxt, boolean destructiveOK)
* @return The expression evaluated as a double.
* @throws javax.xml.transform.TransformerException if any
*/
public double num(XPathContext xctxt) throws javax.xml.transform.TransformerException {
public double num(final XPathContext xctxt) throws javax.xml.transform.TransformerException {
return execute(xctxt).num();
}

Expand All @@ -125,7 +126,7 @@ public double num(XPathContext xctxt) throws javax.xml.transform.TransformerExce
* @return false
* @throws javax.xml.transform.TransformerException if any
*/
public boolean bool(XPathContext xctxt) throws javax.xml.transform.TransformerException {
public boolean bool(final XPathContext xctxt) throws javax.xml.transform.TransformerException {
return execute(xctxt).bool();
}

Expand All @@ -136,8 +137,8 @@ public boolean bool(XPathContext xctxt) throws javax.xml.transform.TransformerEx
* @return the first node out of the nodeset, or DTM.NULL.
* @throws javax.xml.transform.TransformerException if any
*/
public int asNode(XPathContext xctxt) throws javax.xml.transform.TransformerException {
DTMIterator iter = execute(xctxt).iter();
public int asNode(final XPathContext xctxt) throws javax.xml.transform.TransformerException {
final DTMIterator iter = execute(xctxt).iter();
return iter.nextNode();
}

Expand All @@ -151,7 +152,7 @@ public int asNode(XPathContext xctxt) throws javax.xml.transform.TransformerExce
* is severe enough to halt processing.
* @throws javax.xml.transform.TransformerException if any
*/
public DTMIterator asIterator(XPathContext xctxt, int contextNode)
public DTMIterator asIterator(final XPathContext xctxt, final int contextNode)
throws javax.xml.transform.TransformerException {

try {
Expand Down Expand Up @@ -190,7 +191,7 @@ public boolean isStableNumber() {
*
* @return true of the passed in class is the exact same class as this class.
*/
protected final boolean isSameClass(Expression expr) {
protected final boolean isSameClass(final Expression expr) {
if (null == expr) return false;

return getClass() == expr.getClass();
Expand All @@ -203,10 +204,10 @@ protected final boolean isSameClass(Expression expr) {
* @param msg The assertion message, which should be informative.
* @throws RuntimeException if the b argument is false.
*/
public void assertion(boolean b, java.lang.String msg) {
public void assertion(final boolean b, final String msg) {

if (!b) {
java.lang.String fMsg =
final String fMsg =
XPATHMessages.createXPATHMessage(
XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION, new Object[] {msg});

Expand All @@ -224,14 +225,14 @@ public void assertion(boolean b, java.lang.String msg) {
* @throws TransformerException if the current ErrorListoner determines to throw an exception.
* @throws javax.xml.transform.TransformerException if any
*/
public void error(XPathContext xctxt, String msg, Object[] args)
public void error(final XPathContext xctxt, final String msg, final Object[] args)
throws javax.xml.transform.TransformerException {

java.lang.String fmsg = XPATHMessages.createXPATHMessage(msg, args);
final String fmsg = XPATHMessages.createXPATHMessage(msg, args);

if (null != xctxt) {
ErrorListener eh = xctxt.getErrorListener();
TransformerException te = new TransformerException(fmsg, this);
final ErrorListener eh = xctxt.getErrorListener();
final TransformerException te = new TransformerException(fmsg, this);

eh.fatalError(te);
}
Expand All @@ -252,7 +253,7 @@ public ExpressionNode getExpressionOwner() {

/** {@inheritDoc} */
@Override
public void exprSetParent(ExpressionNode n) {
public void exprSetParent(final ExpressionNode n) {
assertion(n != this, "Can not parent an expression to itself!");
m_parent = n;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/htmlunit/xpath/NodeSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public class NodeSet implements NodeList {
private final ArrayList<Node> nodes;

/** Create an empty, using the given block size. */
public NodeSet(List<Node> nodes) {
public NodeSet(final List<Node> nodes) {
this.nodes = new ArrayList<>(nodes);
}

/** {@inheritDoc} */
@Override
public Node item(int index) {
public Node item(final int index) {
return nodes.get(index);
}

Expand Down
52 changes: 26 additions & 26 deletions src/main/java/org/htmlunit/xpath/NodeSetDTM.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
public class NodeSetDTM extends NodeVector implements DTMIterator, Cloneable {

/** Create an empty nodelist. */
public NodeSetDTM(DTMManager dtmManager) {
public NodeSetDTM(final DTMManager dtmManager) {
super();
m_manager = dtmManager;
}
Expand All @@ -55,7 +55,7 @@ public NodeSetDTM(DTMManager dtmManager) {
*
* @param ni Iterator which yields Nodes to be made members of the new set.
*/
public NodeSetDTM(DTMIterator ni) {
public NodeSetDTM(final DTMIterator ni) {

super();

Expand All @@ -78,7 +78,7 @@ public int getRoot() {

/** {@inheritDoc} */
@Override
public void setRoot(int context, Object environment) {
public void setRoot(final int context, final Object environment) {
// no-op, I guess... (-sb)
}

Expand All @@ -93,7 +93,7 @@ public Object clone() throws CloneNotSupportedException {
@Override
public DTMIterator cloneWithReset() throws CloneNotSupportedException {

NodeSetDTM clone = (NodeSetDTM) clone();
final NodeSetDTM clone = (NodeSetDTM) clone();

clone.reset();

Expand All @@ -120,7 +120,7 @@ public boolean getExpandEntityReferences() {

/** {@inheritDoc} */
@Override
public DTM getDTM(int nodeHandle) {
public DTM getDTM(final int nodeHandle) {

return m_manager.getDTM(nodeHandle);
}
Expand All @@ -140,7 +140,7 @@ public DTMManager getDTMManager() {
public int nextNode() {

if (m_next < this.size()) {
int next = this.elementAt(m_next);
final int next = this.elementAt(m_next);

m_next++;

Expand Down Expand Up @@ -176,7 +176,7 @@ public boolean isFresh() {

/** {@inheritDoc} */
@Override
public void runTo(int index) {
public void runTo(final int index) {

if (!m_cacheNodes)
throw new RuntimeException(
Expand All @@ -188,7 +188,7 @@ public void runTo(int index) {

/** {@inheritDoc} */
@Override
public int item(int index) {
public int item(final int index) {

runTo(index);

Expand All @@ -210,7 +210,7 @@ public int getLength() {
* @param n Node to be added
* @throws RuntimeException thrown if this NodeSetDTM is not of a mutable type.
*/
public void addNode(int n) {
public void addNode(final int n) {
this.addElement(n);
}

Expand All @@ -221,7 +221,7 @@ public void addNode(int n) {
* @param iterator DTMIterator which yields the nodes to be added.
* @throws RuntimeException thrown if this NodeSetDTM is not of a mutable type.
*/
public void addNodes(DTMIterator iterator) {
public void addNodes(final DTMIterator iterator) {
if (null != iterator) // defensive to fix a bug that Sanjiva reported.
{
int obj;
Expand All @@ -242,24 +242,24 @@ public void addNodes(DTMIterator iterator) {
* @param support The XPath runtime context.
* @throws RuntimeException thrown if this NodeSetDTM is not of a mutable type.
*/
public void addNodeInDocOrder(int node, boolean test, XPathContext support) {
public void addNodeInDocOrder(final int node, final boolean test, final XPathContext support) {
if (test) {

// This needs to do a binary search, but a binary search
// is somewhat tough because the sequence test involves
// two nodes.
int size = size(), i;

final int size = size();
int i;
for (i = size - 1; i >= 0; i--) {
int child = elementAt(i);
final int child = elementAt(i);

if (child == node) {
i = -2; // Duplicate, suppress insert

break;
}

DTM dtm = support.getDTM(node);
final DTM dtm = support.getDTM(node);
if (!dtm.isNodeAfter(node, child)) {
break;
}
Expand All @@ -269,7 +269,7 @@ public void addNodeInDocOrder(int node, boolean test, XPathContext support) {
insertElementAt(node, i + 1);
}
} else {
int insertIndex = this.size();
final int insertIndex = this.size();

boolean foundit = false;

Expand All @@ -294,13 +294,13 @@ public void addNodeInDocOrder(int node, boolean test, XPathContext support) {
* @param support The XPath runtime context.
* @throws RuntimeException thrown if this NodeSetDTM is not of a mutable type.
*/
public void addNodeInDocOrder(int node, XPathContext support) {
public void addNodeInDocOrder(final int node, final XPathContext support) {
addNodeInDocOrder(node, true, support);
} // end addNodeInDocOrder(Vector v, Object obj)

/** {@inheritDoc} */
@Override
public int elementAt(int i) {
public int elementAt(final int i) {

runTo(i);

Expand All @@ -309,7 +309,7 @@ public int elementAt(int i) {

/** {@inheritDoc} */
@Override
public boolean contains(int s) {
public boolean contains(final int s) {

runTo(-1);

Expand All @@ -318,7 +318,7 @@ public boolean contains(int s) {

/** {@inheritDoc} */
@Override
public int indexOf(int elem, int index) {
public int indexOf(final int elem, final int index) {

runTo(-1);

Expand All @@ -327,7 +327,7 @@ public int indexOf(int elem, int index) {

/** {@inheritDoc} */
@Override
public int indexOf(int elem) {
public int indexOf(final int elem) {

runTo(-1);

Expand All @@ -345,7 +345,7 @@ public int getCurrentPos() {

/** {@inheritDoc} */
@Override
public void setCurrentPos(int i) {
public void setCurrentPos(final int i) {

if (!m_cacheNodes)
throw new RuntimeException(
Expand All @@ -361,12 +361,12 @@ public int getCurrentNode() {
if (!m_cacheNodes)
throw new RuntimeException("This NodeSetDTM can not do indexing or counting functions!");

int saved = m_next;
final int saved = m_next;
// because nextNode always increments
// But watch out for copy29, where the root iterator didn't
// have nextNode called on it.
int current = (m_next > 0) ? m_next - 1 : m_next;
int n = (current < m_firstFree) ? elementAt(current) : DTM.NULL;
final int current = (m_next > 0) ? m_next - 1 : m_next;
final int n = (current < m_firstFree) ? elementAt(current) : DTM.NULL;
m_next = saved; // HACK: I think this is a bit of a hack. -sb
return n;
}
Expand All @@ -383,7 +383,7 @@ public int getCurrentNode() {

/** {@inheritDoc} */
@Override
public void setShouldCacheNodes(boolean b) {
public void setShouldCacheNodes(final boolean b) {

if (!isFresh())
throw new RuntimeException(
Expand Down
Loading

0 comments on commit 0c39261

Please sign in to comment.