diff --git a/pom.xml b/pom.xml
index 9d1d826..7842703 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
org.htmlunit
htmlunit-xpath
- 4.1.0
+ 4.2.0-SNAPSHOT
HtmlUnit-XPath
HtmlUnit
@@ -183,6 +183,7 @@
${dependencycheck.version}
0
+ false
diff --git a/src/main/java/org/htmlunit/xpath/objects/XObject.java b/src/main/java/org/htmlunit/xpath/objects/XObject.java
index 1b945fb..8ed0645 100644
--- a/src/main/java/org/htmlunit/xpath/objects/XObject.java
+++ b/src/main/java/org/htmlunit/xpath/objects/XObject.java
@@ -260,7 +260,9 @@ public boolean lessThan(final XObject obj2) throws javax.xml.transform.Transform
// nodeset function. Because the arguments
// are backwards, we call the opposite comparison
// function.
- if (obj2.getType() == XObject.CLASS_NODESET) return obj2.greaterThan(this);
+ if (obj2.getType() == XObject.CLASS_NODESET) {
+ return obj2.greaterThan(this);
+ }
return this.num() < obj2.num();
}
@@ -280,7 +282,9 @@ public boolean lessThanOrEqual(final XObject obj2)
// nodeset function. Because the arguments
// are backwards, we call the opposite comparison
// function.
- if (obj2.getType() == XObject.CLASS_NODESET) return obj2.greaterThanOrEqual(this);
+ if (obj2.getType() == XObject.CLASS_NODESET) {
+ return obj2.greaterThanOrEqual(this);
+ }
return this.num() <= obj2.num();
}
@@ -299,7 +303,9 @@ public boolean greaterThan(final XObject obj2) throws javax.xml.transform.Transf
// nodeset function. Because the arguments
// are backwards, we call the opposite comparison
// function.
- if (obj2.getType() == XObject.CLASS_NODESET) return obj2.lessThan(this);
+ if (obj2.getType() == XObject.CLASS_NODESET) {
+ return obj2.lessThan(this);
+ }
return this.num() > obj2.num();
}
@@ -319,7 +325,9 @@ public boolean greaterThanOrEqual(final XObject obj2)
// nodeset function. Because the arguments
// are backwards, we call the opposite comparison
// function.
- if (obj2.getType() == XObject.CLASS_NODESET) return obj2.lessThanOrEqual(this);
+ if (obj2.getType() == XObject.CLASS_NODESET) {
+ return obj2.lessThanOrEqual(this);
+ }
return this.num() >= obj2.num();
}
@@ -335,7 +343,9 @@ public boolean equals(final XObject obj2) {
// In order to handle the 'all' semantics of
// nodeset comparisons, we always call the
// nodeset function.
- if (obj2.getType() == XObject.CLASS_NODESET) return obj2.equals(this);
+ if (obj2.getType() == XObject.CLASS_NODESET) {
+ return obj2.equals(this);
+ }
if (null != m_obj) {
return m_obj.equals(obj2.m_obj);
@@ -355,7 +365,9 @@ public boolean notEquals(final XObject obj2) throws javax.xml.transform.Transfor
// In order to handle the 'all' semantics of
// nodeset comparisons, we always call the
// nodeset function.
- if (obj2.getType() == XObject.CLASS_NODESET) return obj2.notEquals(this);
+ if (obj2.getType() == XObject.CLASS_NODESET) {
+ return obj2.notEquals(this);
+ }
return !equals(obj2);
}
@@ -396,7 +408,9 @@ public boolean deepEquals(final Expression expr) {
// If equals at the expression level calls deepEquals, I think we're
// still safe from infinite recursion since this object overrides
// equals. I hope.
- if (!isSameClass(expr) || !this.equals((XObject) expr)) return false;
+ if (!isSameClass(expr) || !this.equals((XObject) expr)) {
+ return false;
+ }
return true;
}
diff --git a/src/main/java/org/htmlunit/xpath/objects/XString.java b/src/main/java/org/htmlunit/xpath/objects/XString.java
index e2d4260..1fd24e5 100644
--- a/src/main/java/org/htmlunit/xpath/objects/XString.java
+++ b/src/main/java/org/htmlunit/xpath/objects/XString.java
@@ -428,7 +428,7 @@ public XString fixWhiteSpace(
int d = s;
boolean pres = false;
- for (; s < len; s++) {
+ for ( ; s < len; s++) {
final char c = buf[s];
if (isSpace(c)) {
diff --git a/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMDefaultBaseIterators.java b/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMDefaultBaseIterators.java
index dfe1b15..883890e 100644
--- a/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMDefaultBaseIterators.java
+++ b/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMDefaultBaseIterators.java
@@ -130,7 +130,9 @@ public final class ChildrenIterator extends InternalAxisIteratorBase {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isRestartable) {
_startNode = node;
_currentNode = (node == DTM.NULL) ? DTM.NULL : _firstch(makeNodeIdentity(node));
@@ -162,7 +164,9 @@ public final class ParentIterator extends InternalAxisIteratorBase {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isRestartable) {
_startNode = node;
_currentNode = getParent(node);
@@ -199,7 +203,9 @@ public NamespaceIterator() {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isRestartable) {
_startNode = node;
_currentNode = getFirstNamespaceNode(node, true);
@@ -214,7 +220,9 @@ public int next() {
final int node = _currentNode;
- if (DTM.NULL != node) _currentNode = getNextNamespaceNode(_startNode, node, true);
+ if (DTM.NULL != node) {
+ _currentNode = getNextNamespaceNode(_startNode, node, true);
+ }
return returnNode(node);
}
@@ -244,7 +252,9 @@ public void setStartNode(final int node) {
/** {@inheritDoc} */
@Override
public int next() {
- if (_startNode == _currentNode) return NULL;
+ if (_startNode == _currentNode) {
+ return NULL;
+ }
_currentNode = _startNode;
@@ -259,7 +269,9 @@ public class FollowingSiblingIterator extends InternalAxisIteratorBase {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isRestartable) {
_startNode = node;
_currentNode = makeNodeIdentity(node);
@@ -285,7 +297,9 @@ public final class AttributeIterator extends InternalAxisIteratorBase {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isRestartable) {
_startNode = node;
_currentNode = getFirstAttributeIdentity(makeNodeIdentity(node));
@@ -325,7 +339,9 @@ public boolean isReverse() {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isRestartable) {
_startNode = node;
node = _startNodeID = makeNodeIdentity(node);
@@ -343,8 +359,12 @@ public void setStartNode(int node) {
else {
// Be careful to handle the Document node properly
_currentNode = _parent(node);
- if (NULL != _currentNode) _currentNode = _firstch(_currentNode);
- else _currentNode = node;
+ if (NULL != _currentNode) {
+ _currentNode = _firstch(_currentNode);
+ }
+ else {
+ _currentNode = node;
+ }
}
resetPosition();
@@ -413,14 +433,18 @@ public DTMAxisIterator cloneIterator() {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isRestartable) {
node = makeNodeIdentity(node);
// iterator is not a clone
int parent, index;
- if (_type(node) == DTM.ATTRIBUTE_NODE) node = _parent(node);
+ if (_type(node) == DTM.ATTRIBUTE_NODE) {
+ node = _parent(node);
+ }
_startNode = node;
_stack[index = 0] = node;
@@ -434,7 +458,9 @@ public void setStartNode(int node) {
}
_stack[index] = parent;
}
- if (index > 0) --index; // Pop actual root node (if not start) back off the stack
+ if (index > 0) {
+ --index; // Pop actual root node (if not start) back off the stack
+ }
_currentNode = _stack[index]; // Last parent before root node
@@ -452,10 +478,13 @@ public int next() {
// the tail-recursion.
for (++_currentNode; _sp >= 0; ++_currentNode) {
if (_currentNode < _stack[_sp]) {
- if (_type(_currentNode) != ATTRIBUTE_NODE && _type(_currentNode) != NAMESPACE_NODE)
+ if (_type(_currentNode) != ATTRIBUTE_NODE && _type(_currentNode) != NAMESPACE_NODE) {
return returnNode(makeNodeHandle(_currentNode));
+ }
+ }
+ else {
+ --_sp;
}
- else --_sp;
}
return NULL;
}
@@ -484,7 +513,9 @@ public FollowingIterator() {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isRestartable) {
_startNode = node;
_currentNode = m_traverser.first(node);
@@ -545,7 +576,9 @@ public DTMAxisIterator cloneIterator() {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isRestartable) {
int nodeID = makeNodeIdentity(node);
@@ -602,12 +635,16 @@ public class DescendantIterator extends InternalAxisIteratorBase {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isRestartable) {
node = makeNodeIdentity(node);
_startNode = node;
- if (_includeSelf) node--;
+ if (_includeSelf) {
+ node--;
+ }
_currentNode = node;
@@ -638,8 +675,9 @@ public int next() {
return NULL;
}
- if (_includeSelf && (_currentNode + 1) == _startNode)
+ if (_includeSelf && (_currentNode + 1) == _startNode) {
return returnNode(makeNodeHandle(++_currentNode)); // | m_dtmIdent);
+ }
int node = _currentNode;
int type;
@@ -699,7 +737,9 @@ public SingletonIterator(final int node, final boolean constant) {
@Override
public void setStartNode(int node) {
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
- if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
+ if (node == DTMDefaultBase.ROOTNODE) {
+ node = getDocument();
+ }
if (_isConstant) {
_currentNode = _startNode;
diff --git a/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMDefaultBaseTraversers.java b/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMDefaultBaseTraversers.java
index a74c59e..6dc73b5 100644
--- a/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMDefaultBaseTraversers.java
+++ b/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMDefaultBaseTraversers.java
@@ -59,7 +59,9 @@ public DTMAxisTraverser getAxisTraverser(final int axis) {
else {
traverser = m_traversers[axis]; // Share/reuse existing traverser
- if (traverser != null) return traverser;
+ if (traverser != null) {
+ return traverser;
+ }
}
switch (axis) { // Generate new traverser
@@ -151,7 +153,9 @@ public int next(final int context, int current, final int expandedTypeID) {
current = makeNodeIdentity(current);
while (DTM.NULL != (current = m_parent.elementAt(current))) {
- if (m_exptype.elementAt(current) == expandedTypeID) return makeNodeHandle(current);
+ if (m_exptype.elementAt(current) == expandedTypeID) {
+ return makeNodeHandle(current);
+ }
}
return NULL;
@@ -192,7 +196,9 @@ public int next(final int context, int current, final int expandedTypeID) {
current = (context == current) ? getFirstAttribute(context) : getNextAttribute(current);
do {
- if (getExpandedTypeID(current) == expandedTypeID) return current;
+ if (getExpandedTypeID(current) == expandedTypeID) {
+ return current;
+ }
}
while (DTM.NULL != (current = getNextAttribute(current)));
@@ -218,18 +224,22 @@ protected int getNextIndexed(final int axisRoot, int nextPotential, final int ex
final int nsIndex = m_expandedNameTable.getNamespaceID(expandedTypeID);
final int lnIndex = m_expandedNameTable.getLocalNameID(expandedTypeID);
- for (; ; ) {
+ for ( ;;) {
final int nextID = findElementFromIndex(nsIndex, lnIndex, nextPotential);
if (NOTPROCESSED != nextID) {
int parentID = m_parent.elementAt(nextID);
// Is it a child?
- if (parentID == axisRoot) return nextID;
+ if (parentID == axisRoot) {
+ return nextID;
+ }
// If the parent occured before the subtree root, then
// we know it is past the child axis.
- if (parentID < axisRoot) return NULL;
+ if (parentID < axisRoot) {
+ return NULL;
+ }
// Otherwise, it could be a descendant below the subtree root
// children, or it could be after the subtree root. So we have
@@ -238,7 +248,9 @@ protected int getNextIndexed(final int axisRoot, int nextPotential, final int ex
// root, in which case we continue to look.
do {
parentID = m_parent.elementAt(parentID);
- if (parentID < axisRoot) return NULL;
+ if (parentID < axisRoot) {
+ return NULL;
+ }
}
while (parentID > axisRoot);
@@ -249,7 +261,9 @@ protected int getNextIndexed(final int axisRoot, int nextPotential, final int ex
nextNode();
- if (!(m_nextsib.elementAt(axisRoot) == NOTPROCESSED)) break;
+ if (!(m_nextsib.elementAt(axisRoot) == NOTPROCESSED)) {
+ break;
+ }
}
return DTM.NULL;
@@ -284,7 +298,9 @@ public int next(final int context, int current, final int expandedTypeID) {
for (current = _nextsib(makeNodeIdentity(current));
DTM.NULL != current;
current = _nextsib(current)) {
- if (m_exptype.elementAt(current) == expandedTypeID) return makeNodeHandle(current);
+ if (m_exptype.elementAt(current) == expandedTypeID) {
+ return makeNodeHandle(current);
+ }
}
return NULL;
@@ -349,12 +365,16 @@ protected int getNextIndexed(
final int next = findElementFromIndex(nsIndex, lnIndex, nextPotential);
if (NOTPROCESSED != next) {
- if (isAfterAxis(axisRoot, next)) return NULL;
+ if (isAfterAxis(axisRoot, next)) {
+ return NULL;
+ }
// System.out.println("Found node via index: "+first);
return next;
}
- else if (axisHasBeenProcessed(axisRoot)) break;
+ else if (axisHasBeenProcessed(axisRoot)) {
+ break;
+ }
nextNode();
}
@@ -415,7 +435,9 @@ protected boolean isAfterAxis(final int axisRoot, int identity) {
// Yes. In ID space, compare to axisRoot's successor
// (next-sib or ancestor's-next-sib). Probably shallower search.
do {
- if (identity == axisRoot) return false;
+ if (identity == axisRoot) {
+ return false;
+ }
identity = m_parent.elementAt(identity);
}
while (identity >= axisRoot);
@@ -446,9 +468,13 @@ public int next(final int context, int current) {
for (current = makeNodeIdentity(current) + 1; ; current++) {
final int type = _type(current); // may call nextNode()
- if (!isDescendant(subtreeRootIdent, current)) return NULL;
+ if (!isDescendant(subtreeRootIdent, current)) {
+ return NULL;
+ }
- if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type) continue;
+ if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type) {
+ continue;
+ }
return makeNodeHandle(current); // make handle.
}
@@ -466,12 +492,16 @@ public int next(final int context, int current, final int expandedTypeID) {
return makeNodeHandle(getNextIndexed(subtreeRootIdent, current, expandedTypeID));
}
- for (; ; current++) {
+ for ( ; ; current++) {
final int exptype = _exptype(current); // may call nextNode()
- if (!isDescendant(subtreeRootIdent, current)) return NULL;
+ if (!isDescendant(subtreeRootIdent, current)) {
+ return NULL;
+ }
- if (exptype != expandedTypeID) continue;
+ if (exptype != expandedTypeID) {
+ continue;
+ }
return makeNodeHandle(current); // make handle.
}
@@ -511,7 +541,9 @@ public int next(final int context, int current) {
// is quite a kluge...
_exptype(current); // make sure it's here.
- if (!isDescendant(subtreeRootIdent, current)) return NULL;
+ if (!isDescendant(subtreeRootIdent, current)) {
+ return NULL;
+ }
return makeNodeHandle(current); // make handle.
}
@@ -534,13 +566,17 @@ public int first(int context) {
context = _parent(context);
first = _firstch(context);
- if (NULL != first) return makeNodeHandle(first);
+ if (NULL != first) {
+ return makeNodeHandle(first);
+ }
}
do {
first = _nextsib(context);
- if (NULL == first) context = _parent(context);
+ if (NULL == first) {
+ context = _parent(context);
+ }
}
while (NULL == first && NULL != context);
@@ -560,7 +596,9 @@ public int first(int context, final int expandedTypeID) {
first = getFirstChild(context);
if (NULL != first) {
- if (getExpandedTypeID(first) == expandedTypeID) return first;
+ if (getExpandedTypeID(first) == expandedTypeID) {
+ return first;
+ }
return next(context, first, expandedTypeID);
}
}
@@ -568,9 +606,13 @@ public int first(int context, final int expandedTypeID) {
do {
first = getNextSibling(context);
- if (NULL == first) context = getParent(context);
+ if (NULL == first) {
+ context = getParent(context);
+ }
else {
- if (getExpandedTypeID(first) == expandedTypeID) return first;
+ if (getExpandedTypeID(first) == expandedTypeID) {
+ return first;
+ }
return next(context, first, expandedTypeID);
}
}
@@ -591,9 +633,13 @@ public int next(final int context, int current) {
// %REVIEW% Are we using handles or indexes?
final int type = _type(current); // may call nextNode()
- if (NULL == type) return NULL;
+ if (NULL == type) {
+ return NULL;
+ }
- if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type) continue;
+ if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type) {
+ continue;
+ }
return makeNodeHandle(current); // make handle.
}
@@ -610,9 +656,13 @@ public int next(final int context, int current, final int expandedTypeID) {
final int etype = _exptype(current); // may call nextNode()
- if (NULL == etype) return NULL;
+ if (NULL == etype) {
+ return NULL;
+ }
- if (etype != expandedTypeID) continue;
+ if (etype != expandedTypeID) {
+ continue;
+ }
return makeNodeHandle(current); // make handle.
}
@@ -633,7 +683,9 @@ public int next(final int context, final int current) {
public int next(final int context, int current, final int expandedTypeID) {
while (DTM.NULL != (current = getNextSibling(current))) {
- if (getExpandedTypeID(current) == expandedTypeID) return current;
+ if (getExpandedTypeID(current) == expandedTypeID) {
+ return current;
+ }
}
return NULL;
@@ -662,7 +714,9 @@ public int next(final int context, int current, final int expandedTypeID) {
: getNextNamespaceNode(context, current, false);
do {
- if (getExpandedTypeID(current) == expandedTypeID) return current;
+ if (getExpandedTypeID(current) == expandedTypeID) {
+ return current;
+ }
}
while (DTM.NULL != (current = getNextNamespaceNode(context, current, false)));
@@ -692,7 +746,9 @@ public int next(final int context, int current, final int expandedTypeID) {
: getNextNamespaceNode(context, current, true);
do {
- if (getExpandedTypeID(current) == expandedTypeID) return current;
+ if (getExpandedTypeID(current) == expandedTypeID) {
+ return current;
+ }
}
while (DTM.NULL != (current = getNextNamespaceNode(context, current, true)));
@@ -715,7 +771,9 @@ public int first(int current, final int expandedTypeID) {
current = makeNodeIdentity(current);
while (NULL != (current = m_parent.elementAt(current))) {
- if (m_exptype.elementAt(current) == expandedTypeID) return makeNodeHandle(current);
+ if (m_exptype.elementAt(current) == expandedTypeID) {
+ return makeNodeHandle(current);
+ }
}
return NULL;
@@ -754,7 +812,9 @@ protected boolean isAncestor(int contextIdent, final int currentIdent) {
for (contextIdent = m_parent.elementAt(contextIdent);
DTM.NULL != contextIdent;
contextIdent = m_parent.elementAt(contextIdent)) {
- if (contextIdent == currentIdent) return true;
+ if (contextIdent == currentIdent) {
+ return true;
+ }
}
return false;
@@ -771,7 +831,9 @@ public int next(final int context, int current) {
if (ATTRIBUTE_NODE == type
|| NAMESPACE_NODE == type
- || isAncestor(subtreeRootIdent, current)) continue;
+ || isAncestor(subtreeRootIdent, current)) {
+ continue;
+ }
return makeNodeHandle(current); // make handle.
}
@@ -788,7 +850,9 @@ public int next(final int context, int current, final int expandedTypeID) {
for (current = makeNodeIdentity(current) - 1; current >= 0; current--) {
final int exptype = m_exptype.elementAt(current);
- if (exptype != expandedTypeID || isAncestor(subtreeRootIdent, current)) continue;
+ if (exptype != expandedTypeID || isAncestor(subtreeRootIdent, current)) {
+ continue;
+ }
return makeNodeHandle(current); // make handle.
}
@@ -809,7 +873,9 @@ public int next(final int context, int current) {
for (current = makeNodeIdentity(current) - 1; current >= 0; current--) {
final short type = _type(current);
- if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type) continue;
+ if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type) {
+ continue;
+ }
return makeNodeHandle(current); // make handle.
}
@@ -826,7 +892,9 @@ public int next(final int context, int current, final int expandedTypeID) {
for (current = makeNodeIdentity(current) - 1; current >= 0; current--) {
final int exptype = m_exptype.elementAt(current);
- if (exptype != expandedTypeID) continue;
+ if (exptype != expandedTypeID) {
+ continue;
+ }
return makeNodeHandle(current); // make handle.
}
@@ -849,7 +917,9 @@ public int next(final int context, final int current) {
public int next(final int context, int current, final int expandedTypeID) {
while (DTM.NULL != (current = getPreviousSibling(current))) {
- if (getExpandedTypeID(current) == expandedTypeID) return current;
+ if (getExpandedTypeID(current) == expandedTypeID) {
+ return current;
+ }
}
return NULL;
@@ -910,7 +980,9 @@ public int next(final int context, int current) {
for (current = makeNodeIdentity(current) + 1; ; current++) {
// Kluge test: Just make sure +1 yielded a real node
final int type = _type(current); // may call nextNode()
- if (type == NULL) return NULL;
+ if (type == NULL) {
+ return NULL;
+ }
return makeNodeHandle(current); // make handle.
}
@@ -925,9 +997,13 @@ public int next(final int context, int current, final int expandedTypeID) {
for (current = makeNodeIdentity(current) + 1; ; current++) {
final int exptype = _exptype(current); // may call nextNode()
- if (exptype == NULL) return NULL;
+ if (exptype == NULL) {
+ return NULL;
+ }
- if (exptype != expandedTypeID) continue;
+ if (exptype != expandedTypeID) {
+ continue;
+ }
return makeNodeHandle(current); // make handle.
}
diff --git a/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMManagerDefault.java b/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMManagerDefault.java
index 9db5939..147618c 100644
--- a/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMManagerDefault.java
+++ b/src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMManagerDefault.java
@@ -143,9 +143,10 @@ public synchronized DTM getDTM(
final boolean incremental,
final boolean doIndexing) {
- if (DEBUG && null != source)
+ if (DEBUG && null != source) {
System.out.println(
"Starting " + (unique ? "UNIQUE" : "shared") + " source: " + source.getSystemId());
+ }
final int dtmPos = getFirstFreeDTMID();
final int documentID = dtmPos << IDENT_DTM_NODE_BITS;
@@ -167,9 +168,10 @@ public synchronized DTM getDTM(
/** {@inheritDoc} */
@Override
public synchronized int getDTMHandleFromNode(final org.w3c.dom.Node node) {
- if (null == node)
+ if (null == node) {
throw new IllegalArgumentException(
XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NODE_NON_NULL, null));
+ }
if (node instanceof org.htmlunit.xpath.xml.dtm.ref.DTMNodeProxy) {
return ((org.htmlunit.xpath.xml.dtm.ref.DTMNodeProxy) node).getDTMNodeNumber();
@@ -199,7 +201,9 @@ public synchronized int getDTMHandleFromNode(final org.w3c.dom.Node node) {
for (final DTM thisDTM : m_dtms) {
if ((null != thisDTM) && thisDTM instanceof DOM2DTM) {
final int handle = ((DOM2DTM) thisDTM).getHandleOfNode(node);
- if (handle != DTM.NULL) return handle;
+ if (handle != DTM.NULL) {
+ return handle;
+ }
}
}
@@ -227,7 +231,7 @@ public synchronized int getDTMHandleFromNode(final org.w3c.dom.Node node) {
(root.getNodeType() == Node.ATTRIBUTE_NODE)
? ((org.w3c.dom.Attr) root).getOwnerElement()
: root.getParentNode();
- for (; p != null; p = p.getParentNode()) {
+ for ( ; p != null; p = p.getParentNode()) {
root = p;
}
@@ -244,12 +248,14 @@ public synchronized int getDTMHandleFromNode(final org.w3c.dom.Node node) {
handle = dtm.getHandleOfNode(((org.w3c.dom.Attr) node).getOwnerElement());
handle = dtm.getAttributeNode(handle, node.getNamespaceURI(), node.getLocalName());
}
- else handle = dtm.getHandleOfNode(node);
+ else {
+ handle = dtm.getHandleOfNode(node);
+ }
- if (DTM.NULL == handle)
+ if (DTM.NULL == handle) {
throw new RuntimeException(
XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_COULD_NOT_RESOLVE_NODE, null));
-
+ }
return handle;
}
@@ -261,7 +267,9 @@ public synchronized DTM getDTM(final int nodeHandle) {
return m_dtms[nodeHandle >>> IDENT_DTM_NODE_BITS];
}
catch (final java.lang.ArrayIndexOutOfBoundsException e) {
- if (nodeHandle == DTM.NULL) return null; // Accept as a special case.
+ if (nodeHandle == DTM.NULL) {
+ return null; // Accept as a special case.
+ }
throw e; // Programming error; want to know about it.
}
}
diff --git a/src/main/java/org/htmlunit/xpath/xml/utils/NodeVector.java b/src/main/java/org/htmlunit/xpath/xml/utils/NodeVector.java
index c1e13bc..72fac16 100644
--- a/src/main/java/org/htmlunit/xpath/xml/utils/NodeVector.java
+++ b/src/main/java/org/htmlunit/xpath/xml/utils/NodeVector.java
@@ -148,8 +148,9 @@ else if ((m_firstFree + 1) >= m_mapSize) {
* @return Node at specified index
*/
public int elementAt(final int i) {
-
- if (null == m_map) return DTM.NULL;
+ if (null == m_map) {
+ return DTM.NULL;
+ }
return m_map[i];
}
@@ -161,13 +162,16 @@ public int elementAt(final int i) {
* @return True if the given node was found.
*/
public boolean contains(final int s) {
-
- if (null == m_map) return false;
+ if (null == m_map) {
+ return false;
+ }
for (int i = 0; i < m_firstFree; i++) {
final int node = m_map[i];
- if (node == s) return true;
+ if (node == s) {
+ return true;
+ }
}
return false;
@@ -183,13 +187,16 @@ public boolean contains(final int s) {
* index or later in the vector; returns -1 if the object is not found.
*/
public int indexOf(final int elem, final int index) {
-
- if (null == m_map) return -1;
+ if (null == m_map) {
+ return -1;
+ }
for (int i = index; i < m_firstFree; i++) {
final int node = m_map[i];
- if (node == elem) return i;
+ if (node == elem) {
+ return i;
+ }
}
return -1;
@@ -204,13 +211,16 @@ public int indexOf(final int elem, final int index) {
* index or later in the vector; returns -1 if the object is not found.
*/
public int indexOf(final int elem) {
-
- if (null == m_map) return -1;
+ if (null == m_map) {
+ return -1;
+ }
for (int i = 0; i < m_firstFree; i++) {
final int node = m_map[i];
- if (node == elem) return i;
+ if (node == elem) {
+ return i;
+ }
}
return -1;
diff --git a/src/main/java/org/htmlunit/xpath/xml/utils/PrefixResolverDefault.java b/src/main/java/org/htmlunit/xpath/xml/utils/PrefixResolverDefault.java
index dff6193..e635714 100644
--- a/src/main/java/org/htmlunit/xpath/xml/utils/PrefixResolverDefault.java
+++ b/src/main/java/org/htmlunit/xpath/xml/utils/PrefixResolverDefault.java
@@ -65,7 +65,9 @@ public String getNamespaceForPrefix(
&& (((type = parent.getNodeType()) == Node.ELEMENT_NODE)
|| (type == Node.ENTITY_REFERENCE_NODE))) {
if (type == Node.ELEMENT_NODE) {
- if (parent.getNodeName().indexOf(prefix + ":") == 0) return parent.getNamespaceURI();
+ if (parent.getNodeName().indexOf(prefix + ":") == 0) {
+ return parent.getNamespaceURI();
+ }
final NamedNodeMap nnm = parent.getAttributes();
for (int i = 0; i < nnm.getLength(); i++) {
diff --git a/src/main/java/org/htmlunit/xpath/xml/utils/SuballocatedIntVector.java b/src/main/java/org/htmlunit/xpath/xml/utils/SuballocatedIntVector.java
index bf6fe32..28a13ab 100644
--- a/src/main/java/org/htmlunit/xpath/xml/utils/SuballocatedIntVector.java
+++ b/src/main/java/org/htmlunit/xpath/xml/utils/SuballocatedIntVector.java
@@ -72,8 +72,8 @@ public class SuballocatedIntVector {
*/
public SuballocatedIntVector(int blocksize, final int numblocks) {
// m_blocksize = blocksize;
- for (m_SHIFT = 0; 0 != (blocksize >>>= 1); ++m_SHIFT)
- ;
+ for (m_SHIFT = 0; 0 != (blocksize >>>= 1); ++m_SHIFT) {
+ }
m_blocksize = 1 << m_SHIFT;
m_MASK = m_blocksize - 1;
m_numblocks = numblocks;
@@ -134,7 +134,9 @@ public void addElement(final int value) {
m_map = newMap;
}
int[] block = m_map[index];
- if (null == block) block = m_map[index] = new int[m_blocksize];
+ if (null == block) {
+ block = m_map[index] = new int[m_blocksize];
+ }
block[offset] = value;
// Cache the current row of m_map. Next m_blocksize-1
@@ -157,7 +159,9 @@ public void addElement(final int value) {
* @param at Index of where to set the object
*/
public void setElementAt(final int value, final int at) {
- if (at < m_blocksize) m_map0[at] = value;
+ if (at < m_blocksize) {
+ m_map0[at] = value;
+ }
else {
final int index = at >>> m_SHIFT;
final int offset = at & m_MASK;
@@ -170,11 +174,15 @@ public void setElementAt(final int value, final int at) {
}
int[] block = m_map[index];
- if (null == block) block = m_map[index] = new int[m_blocksize];
+ if (null == block) {
+ block = m_map[index] = new int[m_blocksize];
+ }
block[offset] = value;
}
- if (at >= m_firstFree) m_firstFree = at + 1;
+ if (at >= m_firstFree) {
+ m_firstFree = at + 1;
+ }
}
/**
@@ -194,7 +202,9 @@ public void setElementAt(final int value, final int at) {
*/
public int elementAt(final int i) {
// This is actually a significant optimization!
- if (i < m_blocksize) return m_map0[i];
+ if (i < m_blocksize) {
+ return m_map0[i];
+ }
return m_map[i >>> m_SHIFT][i & m_MASK];
}
@@ -209,25 +219,34 @@ public int elementAt(final int i) {
* index or later in the vector; returns -1 if the object is not found.
*/
public int indexOf(final int elem, final int index) {
- if (index >= m_firstFree) return -1;
+ if (index >= m_firstFree) {
+ return -1;
+ }
int bindex = index >>> m_SHIFT;
int boffset = index & m_MASK;
final int maxindex = m_firstFree >>> m_SHIFT;
int[] block;
- for (; bindex < maxindex; ++bindex) {
+ for ( ; bindex < maxindex; ++bindex) {
block = m_map[bindex];
- if (block != null)
- for (int offset = boffset; offset < m_blocksize; ++offset)
- if (block[offset] == elem) return offset + bindex * m_blocksize;
+ if (block != null) {
+ for (int offset = boffset; offset < m_blocksize; ++offset) {
+ if (block[offset] == elem) {
+ return offset + bindex * m_blocksize;
+ }
+ }
+ }
boffset = 0; // after first
}
// Last block may need to stop before end
final int maxoffset = m_firstFree & m_MASK;
block = m_map[maxindex];
- for (int offset = boffset; offset < maxoffset; ++offset)
- if (block[offset] == elem) return offset + maxindex * m_blocksize;
+ for (int offset = boffset; offset < maxoffset; ++offset) {
+ if (block[offset] == elem) {
+ return offset + maxindex * m_blocksize;
+ }
+ }
return -1;
}