Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jun 4, 2024
1 parent 3bbe0a8 commit 4c63e5d
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 104 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.htmlunit</groupId>
<artifactId>htmlunit-xpath</artifactId>
<version>4.1.0</version>
<version>4.2.0-SNAPSHOT</version>
<name>HtmlUnit-XPath</name>
<organization>
<name>HtmlUnit</name>
Expand Down Expand Up @@ -183,6 +183,7 @@
<version>${dependencycheck.version}</version>
<configuration>
<failBuildOnCVSS>0</failBuildOnCVSS>
<assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
</configuration>
<executions>
<execution>
Expand Down
28 changes: 21 additions & 7 deletions src/main/java/org/htmlunit/xpath/objects/XObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/htmlunit/xpath/objects/XString.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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

Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
Loading

0 comments on commit 4c63e5d

Please sign in to comment.