Skip to content

Commit 4c63e5d

Browse files
committed
code style
1 parent 3bbe0a8 commit 4c63e5d

File tree

9 files changed

+274
-104
lines changed

9 files changed

+274
-104
lines changed

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.htmlunit</groupId>
66
<artifactId>htmlunit-xpath</artifactId>
7-
<version>4.1.0</version>
7+
<version>4.2.0-SNAPSHOT</version>
88
<name>HtmlUnit-XPath</name>
99
<organization>
1010
<name>HtmlUnit</name>
@@ -183,6 +183,7 @@
183183
<version>${dependencycheck.version}</version>
184184
<configuration>
185185
<failBuildOnCVSS>0</failBuildOnCVSS>
186+
<assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
186187
</configuration>
187188
<executions>
188189
<execution>

src/main/java/org/htmlunit/xpath/objects/XObject.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ public boolean lessThan(final XObject obj2) throws javax.xml.transform.Transform
260260
// nodeset function. Because the arguments
261261
// are backwards, we call the opposite comparison
262262
// function.
263-
if (obj2.getType() == XObject.CLASS_NODESET) return obj2.greaterThan(this);
263+
if (obj2.getType() == XObject.CLASS_NODESET) {
264+
return obj2.greaterThan(this);
265+
}
264266

265267
return this.num() < obj2.num();
266268
}
@@ -280,7 +282,9 @@ public boolean lessThanOrEqual(final XObject obj2)
280282
// nodeset function. Because the arguments
281283
// are backwards, we call the opposite comparison
282284
// function.
283-
if (obj2.getType() == XObject.CLASS_NODESET) return obj2.greaterThanOrEqual(this);
285+
if (obj2.getType() == XObject.CLASS_NODESET) {
286+
return obj2.greaterThanOrEqual(this);
287+
}
284288

285289
return this.num() <= obj2.num();
286290
}
@@ -299,7 +303,9 @@ public boolean greaterThan(final XObject obj2) throws javax.xml.transform.Transf
299303
// nodeset function. Because the arguments
300304
// are backwards, we call the opposite comparison
301305
// function.
302-
if (obj2.getType() == XObject.CLASS_NODESET) return obj2.lessThan(this);
306+
if (obj2.getType() == XObject.CLASS_NODESET) {
307+
return obj2.lessThan(this);
308+
}
303309

304310
return this.num() > obj2.num();
305311
}
@@ -319,7 +325,9 @@ public boolean greaterThanOrEqual(final XObject obj2)
319325
// nodeset function. Because the arguments
320326
// are backwards, we call the opposite comparison
321327
// function.
322-
if (obj2.getType() == XObject.CLASS_NODESET) return obj2.lessThanOrEqual(this);
328+
if (obj2.getType() == XObject.CLASS_NODESET) {
329+
return obj2.lessThanOrEqual(this);
330+
}
323331

324332
return this.num() >= obj2.num();
325333
}
@@ -335,7 +343,9 @@ public boolean equals(final XObject obj2) {
335343
// In order to handle the 'all' semantics of
336344
// nodeset comparisons, we always call the
337345
// nodeset function.
338-
if (obj2.getType() == XObject.CLASS_NODESET) return obj2.equals(this);
346+
if (obj2.getType() == XObject.CLASS_NODESET) {
347+
return obj2.equals(this);
348+
}
339349

340350
if (null != m_obj) {
341351
return m_obj.equals(obj2.m_obj);
@@ -355,7 +365,9 @@ public boolean notEquals(final XObject obj2) throws javax.xml.transform.Transfor
355365
// In order to handle the 'all' semantics of
356366
// nodeset comparisons, we always call the
357367
// nodeset function.
358-
if (obj2.getType() == XObject.CLASS_NODESET) return obj2.notEquals(this);
368+
if (obj2.getType() == XObject.CLASS_NODESET) {
369+
return obj2.notEquals(this);
370+
}
359371

360372
return !equals(obj2);
361373
}
@@ -396,7 +408,9 @@ public boolean deepEquals(final Expression expr) {
396408
// If equals at the expression level calls deepEquals, I think we're
397409
// still safe from infinite recursion since this object overrides
398410
// equals. I hope.
399-
if (!isSameClass(expr) || !this.equals((XObject) expr)) return false;
411+
if (!isSameClass(expr) || !this.equals((XObject) expr)) {
412+
return false;
413+
}
400414

401415
return true;
402416
}

src/main/java/org/htmlunit/xpath/objects/XString.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public XString fixWhiteSpace(
428428
int d = s;
429429
boolean pres = false;
430430

431-
for (; s < len; s++) {
431+
for ( ; s < len; s++) {
432432
final char c = buf[s];
433433

434434
if (isSpace(c)) {

src/main/java/org/htmlunit/xpath/xml/dtm/ref/DTMDefaultBaseIterators.java

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public final class ChildrenIterator extends InternalAxisIteratorBase {
130130
@Override
131131
public void setStartNode(int node) {
132132
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
133-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
133+
if (node == DTMDefaultBase.ROOTNODE) {
134+
node = getDocument();
135+
}
134136
if (_isRestartable) {
135137
_startNode = node;
136138
_currentNode = (node == DTM.NULL) ? DTM.NULL : _firstch(makeNodeIdentity(node));
@@ -162,7 +164,9 @@ public final class ParentIterator extends InternalAxisIteratorBase {
162164
@Override
163165
public void setStartNode(int node) {
164166
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
165-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
167+
if (node == DTMDefaultBase.ROOTNODE) {
168+
node = getDocument();
169+
}
166170
if (_isRestartable) {
167171
_startNode = node;
168172
_currentNode = getParent(node);
@@ -199,7 +203,9 @@ public NamespaceIterator() {
199203
@Override
200204
public void setStartNode(int node) {
201205
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
202-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
206+
if (node == DTMDefaultBase.ROOTNODE) {
207+
node = getDocument();
208+
}
203209
if (_isRestartable) {
204210
_startNode = node;
205211
_currentNode = getFirstNamespaceNode(node, true);
@@ -214,7 +220,9 @@ public int next() {
214220

215221
final int node = _currentNode;
216222

217-
if (DTM.NULL != node) _currentNode = getNextNamespaceNode(_startNode, node, true);
223+
if (DTM.NULL != node) {
224+
_currentNode = getNextNamespaceNode(_startNode, node, true);
225+
}
218226

219227
return returnNode(node);
220228
}
@@ -244,7 +252,9 @@ public void setStartNode(final int node) {
244252
/** {@inheritDoc} */
245253
@Override
246254
public int next() {
247-
if (_startNode == _currentNode) return NULL;
255+
if (_startNode == _currentNode) {
256+
return NULL;
257+
}
248258

249259
_currentNode = _startNode;
250260

@@ -259,7 +269,9 @@ public class FollowingSiblingIterator extends InternalAxisIteratorBase {
259269
@Override
260270
public void setStartNode(int node) {
261271
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
262-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
272+
if (node == DTMDefaultBase.ROOTNODE) {
273+
node = getDocument();
274+
}
263275
if (_isRestartable) {
264276
_startNode = node;
265277
_currentNode = makeNodeIdentity(node);
@@ -285,7 +297,9 @@ public final class AttributeIterator extends InternalAxisIteratorBase {
285297
@Override
286298
public void setStartNode(int node) {
287299
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
288-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
300+
if (node == DTMDefaultBase.ROOTNODE) {
301+
node = getDocument();
302+
}
289303
if (_isRestartable) {
290304
_startNode = node;
291305
_currentNode = getFirstAttributeIdentity(makeNodeIdentity(node));
@@ -325,7 +339,9 @@ public boolean isReverse() {
325339
@Override
326340
public void setStartNode(int node) {
327341
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
328-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
342+
if (node == DTMDefaultBase.ROOTNODE) {
343+
node = getDocument();
344+
}
329345
if (_isRestartable) {
330346
_startNode = node;
331347
node = _startNodeID = makeNodeIdentity(node);
@@ -343,8 +359,12 @@ public void setStartNode(int node) {
343359
else {
344360
// Be careful to handle the Document node properly
345361
_currentNode = _parent(node);
346-
if (NULL != _currentNode) _currentNode = _firstch(_currentNode);
347-
else _currentNode = node;
362+
if (NULL != _currentNode) {
363+
_currentNode = _firstch(_currentNode);
364+
}
365+
else {
366+
_currentNode = node;
367+
}
348368
}
349369

350370
resetPosition();
@@ -413,14 +433,18 @@ public DTMAxisIterator cloneIterator() {
413433
@Override
414434
public void setStartNode(int node) {
415435
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
416-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
436+
if (node == DTMDefaultBase.ROOTNODE) {
437+
node = getDocument();
438+
}
417439
if (_isRestartable) {
418440
node = makeNodeIdentity(node);
419441

420442
// iterator is not a clone
421443
int parent, index;
422444

423-
if (_type(node) == DTM.ATTRIBUTE_NODE) node = _parent(node);
445+
if (_type(node) == DTM.ATTRIBUTE_NODE) {
446+
node = _parent(node);
447+
}
424448

425449
_startNode = node;
426450
_stack[index = 0] = node;
@@ -434,7 +458,9 @@ public void setStartNode(int node) {
434458
}
435459
_stack[index] = parent;
436460
}
437-
if (index > 0) --index; // Pop actual root node (if not start) back off the stack
461+
if (index > 0) {
462+
--index; // Pop actual root node (if not start) back off the stack
463+
}
438464

439465
_currentNode = _stack[index]; // Last parent before root node
440466

@@ -452,10 +478,13 @@ public int next() {
452478
// the tail-recursion.
453479
for (++_currentNode; _sp >= 0; ++_currentNode) {
454480
if (_currentNode < _stack[_sp]) {
455-
if (_type(_currentNode) != ATTRIBUTE_NODE && _type(_currentNode) != NAMESPACE_NODE)
481+
if (_type(_currentNode) != ATTRIBUTE_NODE && _type(_currentNode) != NAMESPACE_NODE) {
456482
return returnNode(makeNodeHandle(_currentNode));
483+
}
484+
}
485+
else {
486+
--_sp;
457487
}
458-
else --_sp;
459488
}
460489
return NULL;
461490
}
@@ -484,7 +513,9 @@ public FollowingIterator() {
484513
@Override
485514
public void setStartNode(int node) {
486515
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
487-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
516+
if (node == DTMDefaultBase.ROOTNODE) {
517+
node = getDocument();
518+
}
488519
if (_isRestartable) {
489520
_startNode = node;
490521
_currentNode = m_traverser.first(node);
@@ -545,7 +576,9 @@ public DTMAxisIterator cloneIterator() {
545576
@Override
546577
public void setStartNode(int node) {
547578
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
548-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
579+
if (node == DTMDefaultBase.ROOTNODE) {
580+
node = getDocument();
581+
}
549582

550583
if (_isRestartable) {
551584
int nodeID = makeNodeIdentity(node);
@@ -602,12 +635,16 @@ public class DescendantIterator extends InternalAxisIteratorBase {
602635
@Override
603636
public void setStartNode(int node) {
604637
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
605-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
638+
if (node == DTMDefaultBase.ROOTNODE) {
639+
node = getDocument();
640+
}
606641
if (_isRestartable) {
607642
node = makeNodeIdentity(node);
608643
_startNode = node;
609644

610-
if (_includeSelf) node--;
645+
if (_includeSelf) {
646+
node--;
647+
}
611648

612649
_currentNode = node;
613650

@@ -638,8 +675,9 @@ public int next() {
638675
return NULL;
639676
}
640677

641-
if (_includeSelf && (_currentNode + 1) == _startNode)
678+
if (_includeSelf && (_currentNode + 1) == _startNode) {
642679
return returnNode(makeNodeHandle(++_currentNode)); // | m_dtmIdent);
680+
}
643681

644682
int node = _currentNode;
645683
int type;
@@ -699,7 +737,9 @@ public SingletonIterator(final int node, final boolean constant) {
699737
@Override
700738
public void setStartNode(int node) {
701739
// %HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
702-
if (node == DTMDefaultBase.ROOTNODE) node = getDocument();
740+
if (node == DTMDefaultBase.ROOTNODE) {
741+
node = getDocument();
742+
}
703743
if (_isConstant) {
704744
_currentNode = _startNode;
705745

0 commit comments

Comments
 (0)