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 693bb46 commit 666a074
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 70 deletions.
12 changes: 8 additions & 4 deletions src/main/java/org/htmlunit/xpath/axes/AxesWalker.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ AxesWalker cloneDeep(final WalkingIterator cloneOwner, final Vector<AxesWalker>
// recursive infinate loop.
if (null != cloneList) {
if (null != m_prevWalker) clone.m_prevWalker = m_prevWalker.cloneDeep(cloneOwner, cloneList);
} else {
}
else {
if (null != m_nextWalker) clone.m_nextWalker.m_prevWalker = clone;
}
return clone;
Expand Down Expand Up @@ -248,7 +249,8 @@ public int nextNode() {
if (DTM.NULL == nextNode) {

walker = walker.m_prevWalker;
} else {
}
else {
if (walker.acceptNode(nextNode) != DTMIterator.FILTER_ACCEPT) {
continue;
}
Expand Down Expand Up @@ -283,7 +285,8 @@ public int getLastPos(final XPathContext xctxt) {

try {
walker = (AxesWalker) clone();
} catch (final CloneNotSupportedException cnse) {
}
catch (final CloneNotSupportedException cnse) {
return -1;
}

Expand All @@ -302,7 +305,8 @@ public int getLastPos(final XPathContext xctxt) {
}

// TODO: Should probably save this in the iterator.
} finally {
}
finally {
lpi.setLastUsedWalker(savedWalker);
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/htmlunit/xpath/axes/BasicTestIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,17 @@ public int nextNode() {
continue;
}
break;
} while (next != DTM.NULL);
}
while (next != DTM.NULL);

if (DTM.NULL != next) {
m_pos++;
return next;
}
m_foundLast = true;
return DTM.NULL;
} finally {
}
finally {
}
}

Expand Down
31 changes: 21 additions & 10 deletions src/main/java/org/htmlunit/xpath/axes/DescendantIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public class DescendantIterator extends LocPathIterator {
if (OpCodes.FROM_SELF == stepType) {
orSelf = true;
// firstStepPos += 8;
} else if (OpCodes.FROM_ROOT == stepType) {
}
else if (OpCodes.FROM_ROOT == stepType) {
fromRoot = true;
// Ugly code... will go away when AST work is done.
final int nextStepPos = compiler.getNextStepPos(firstStepPos);
Expand All @@ -74,7 +75,8 @@ public class DescendantIterator extends LocPathIterator {
final int stepOp = compiler.getOp(nextStepPos);
if (OpCodes.ENDOP != stepOp) firstStepPos = nextStepPos;
else break;
} else break;
}
else break;
}

// Fix for http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1336
Expand All @@ -83,7 +85,8 @@ public class DescendantIterator extends LocPathIterator {
if (fromRoot) {
if (orSelf) m_axis = Axis.DESCENDANTSORSELFFROMROOT;
else m_axis = Axis.DESCENDANTSFROMROOT;
} else if (orSelf) m_axis = Axis.DESCENDANTORSELF;
}
else if (orSelf) m_axis = Axis.DESCENDANTORSELF;
else m_axis = Axis.DESCENDANT;

final int whatToShow = compiler.getWhatToShow(firstStepPos);
Expand Down Expand Up @@ -132,7 +135,8 @@ public int nextNode() {
(DTM.NULL == m_lastFetched)
? m_traverser.first(m_context)
: m_traverser.next(m_context, m_lastFetched);
} else {
}
else {
next =
m_lastFetched =
(DTM.NULL == m_lastFetched)
Expand All @@ -141,10 +145,15 @@ public int nextNode() {
}

if (DTM.NULL != next) {
if (DTMIterator.FILTER_ACCEPT == acceptNode(next)) break;
else continue;
} else break;
} while (next != DTM.NULL);
if (DTMIterator.FILTER_ACCEPT == acceptNode(next)) {
break;
}
continue;
}

break;
}
while (next != DTM.NULL);

if (DTM.NULL != next) {
m_pos++;
Expand All @@ -153,7 +162,8 @@ public int nextNode() {

m_foundLast = true;
return DTM.NULL;
} finally {
}
finally {
}
}

Expand All @@ -170,7 +180,8 @@ public void setRoot(final int context, final Object environment) {
|| NodeTest.WILD.equals(localName)
|| NodeTest.WILD.equals(namespace)) {
m_extendedTypeID = 0;
} else {
}
else {
final int type = getNodeTypeTest(what);
m_extendedTypeID = m_cdtm.getExpandedTypeID(namespace, localName, type);
}
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/org/htmlunit/xpath/axes/FilterExprWalker.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,16 @@ public static XNodeSet executeFilterExpr(

result = (org.htmlunit.xpath.objects.XNodeSet) expr.execute(xctxt);
result.setShouldCacheNodes(true);
} else result = (org.htmlunit.xpath.objects.XNodeSet) expr.execute(xctxt);
}
else result = (org.htmlunit.xpath.objects.XNodeSet) expr.execute(xctxt);

} catch (final javax.xml.transform.TransformerException se) {
}
catch (final javax.xml.transform.TransformerException se) {

// TODO: Fix...
throw new org.htmlunit.xpath.xml.utils.WrappedRuntimeException(se);
} finally {
}
finally {
xctxt.popCurrentNode();
xctxt.setNamespaceContext(savedResolver);
}
Expand Down Expand Up @@ -153,7 +156,8 @@ public short acceptNode(final int n) {
}

return DTMIterator.FILTER_ACCEPT;
} catch (final javax.xml.transform.TransformerException se) {
}
catch (final javax.xml.transform.TransformerException se) {
throw new RuntimeException(se.getMessage());
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/htmlunit/xpath/axes/IteratorPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public synchronized DTMIterator getInstance() {
// Create a new object if so.
try {
return (DTMIterator) m_orig.clone();
} catch (final Exception ex) {
}
catch (final Exception ex) {
throw new WrappedRuntimeException(ex);
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/htmlunit/xpath/axes/LocPathIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public abstract class LocPathIterator extends PredicatedNodeTest
implements Cloneable, DTMIterator, PathComponent {

/** Create a LocPathIterator object. */
protected LocPathIterator() {}
protected LocPathIterator() {
}

/**
* Create a LocPathIterator object.
Expand Down Expand Up @@ -239,7 +240,8 @@ public int getLength() {

try {
clone = (LocPathIterator) clone();
} catch (final CloneNotSupportedException cnse) {
}
catch (final CloneNotSupportedException cnse) {
return -1;
}

Expand Down Expand Up @@ -375,7 +377,8 @@ public void runTo(final int index) {
if (-1 == index) {
while (DTM.NULL != nextNode())
;
} else {
}
else {
while (DTM.NULL != nextNode()) {
if (getCurrentPos() >= index) break;
}
Expand Down
42 changes: 28 additions & 14 deletions src/main/java/org/htmlunit/xpath/axes/NodeSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ private boolean cacheComplete() {
final boolean complete;
if (m_cache != null) {
complete = m_cache.isComplete();
} else {
}
else {
complete = false;
}
return complete;
Expand Down Expand Up @@ -143,7 +144,8 @@ public NodeSequence(final Object nodeVector) {
}

/** Create a new NodeSequence in an invalid (null) state. */
public NodeSequence() {}
public NodeSequence() {
}

/** {@inheritDoc} */
@Override
Expand Down Expand Up @@ -186,7 +188,8 @@ public void setRoot(final int nodeHandle, final Object environment) {
runTo(-1);
m_next = 0;
}
} else assertion(false, "Can not setRoot on a non-iterated NodeSequence!");
}
else assertion(false, "Can not setRoot on a non-iterated NodeSequence!");
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -226,7 +229,8 @@ public int nextNode() {
final int next = vec.elementAt(m_next);
m_next++;
return next;
} else if (cacheComplete() || (-1 != m_last) || (null == m_iter)) {
}
else if (cacheComplete() || (-1 != m_last) || (null == m_iter)) {
m_next++;
return DTM.NULL;
}
Expand All @@ -240,12 +244,15 @@ public int nextNode() {
if (m_iter.isDocOrdered()) {
getVector().addElement(next);
m_next++;
} else {
}
else {
final int insertIndex = addNodeInDocOrder(next);
if (insertIndex >= 0) m_next++;
}
} else m_next++;
} else {
}
else m_next++;
}
else {
// We have exhausted the iterator, and if there is a cache
// it must have all nodes in it by now, so let the cache
// know that it is complete.
Expand Down Expand Up @@ -313,7 +320,8 @@ public void setShouldCacheNodes(final boolean b) {
if (!hasCache()) {
setVector(new NodeVector());
}
} else setVector(null);
}
else setVector(null);
}

/** {@inheritDoc} */
Expand All @@ -330,13 +338,17 @@ public void runTo(final int index) {
while (DTM.NULL != nextNode())
;
m_next = pos;
} else if (m_next == index) {
} else if (hasCache() && m_next < getVector().size()) {
}
else if (m_next == index) {
}
else if (hasCache() && m_next < getVector().size()) {
m_next = index;
} else if ((null == getVector()) && (index < m_next)) {
}
else if ((null == getVector()) && (index < m_next)) {
while ((m_next >= index) && DTM.NULL != previousNode())
;
} else {
}
else {
while ((m_next < index) && DTM.NULL != nextNode())
;
}
Expand Down Expand Up @@ -498,13 +510,15 @@ protected void setObject(final Object obj) {
}
m_cache = new IteratorCache();
m_cache.setVector(v);
} else if (obj instanceof IteratorCache) {
}
else if (obj instanceof IteratorCache) {
final IteratorCache cache = (IteratorCache) obj;
m_cache = cache;

// Keep our superclass informed of the current NodeVector
super.setObject(cache.getVector());
} else {
}
else {
super.setObject(obj);
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/org/htmlunit/xpath/axes/OneStepIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ protected int getProximityPosition(final int predicateIndex) {
}

m_proximityPositions[predicateIndex] += count;
} catch (final CloneNotSupportedException cnse) {
}
catch (final CloneNotSupportedException cnse) {

// can't happen
} finally {
// can't happen
}
finally {
xctxt.popCurrentNode();
}
}
Expand Down Expand Up @@ -174,9 +176,11 @@ public int getLength() {
while (DTM.NULL != (clone.nextNode())) {
count++;
}
} catch (final CloneNotSupportedException cnse) {
}
catch (final CloneNotSupportedException cnse) {
// can't happen
} finally {
}
finally {
xctxt.popCurrentNode();
}
if (isPredicateTest && m_predicateIndex < 1) m_length = count;
Expand Down
Loading

0 comments on commit 666a074

Please sign in to comment.