Skip to content

Commit 78811a1

Browse files
committed
code style
1 parent c7f54cb commit 78811a1

19 files changed

+330
-126
lines changed

src/main/java/org/htmlunit/xpath/NodeSetDTM.java

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@ public int nextNode() {
153153
@Override
154154
public int previousNode() {
155155

156-
if (!m_cacheNodes)
157-
throw new RuntimeException(
158-
XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_ITERATE, null));
156+
if (!m_cacheNodes) {
157+
throw new RuntimeException(
158+
XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_ITERATE, null));
159+
}
159160

160161
if ((m_next - 1) > 0) {
161162
m_next--;
@@ -179,12 +180,17 @@ public boolean isFresh() {
179180
@Override
180181
public void runTo(final int index) {
181182

182-
if (!m_cacheNodes)
183-
throw new RuntimeException(
184-
XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_INDEX, null));
183+
if (!m_cacheNodes) {
184+
throw new RuntimeException(
185+
XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_INDEX, null));
186+
}
185187

186-
if ((index >= 0) && (m_next < m_firstFree)) m_next = index;
187-
else m_next = m_firstFree - 1;
188+
if ((index >= 0) && (m_next < m_firstFree)) {
189+
m_next = index;
190+
}
191+
else {
192+
m_next = m_firstFree - 1;
193+
}
188194
}
189195

190196
/** {@inheritDoc} */
@@ -282,7 +288,9 @@ public void addNodeInDocOrder(final int node, final boolean test, final XPathCon
282288
}
283289
}
284290

285-
if (!foundit) addElement(node);
291+
if (!foundit) {
292+
addElement(node);
293+
}
286294
}
287295

288296
// checkDups();
@@ -348,9 +356,10 @@ public int getCurrentPos() {
348356
@Override
349357
public void setCurrentPos(final int i) {
350358

351-
if (!m_cacheNodes)
352-
throw new RuntimeException(
353-
XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_INDEX, null));
359+
if (!m_cacheNodes) {
360+
throw new RuntimeException(
361+
XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_INDEX, null));
362+
}
354363

355364
m_next = i;
356365
}
@@ -359,8 +368,9 @@ public void setCurrentPos(final int i) {
359368
@Override
360369
public int getCurrentNode() {
361370

362-
if (!m_cacheNodes)
363-
throw new RuntimeException("This NodeSetDTM can not do indexing or counting functions!");
371+
if (!m_cacheNodes) {
372+
throw new RuntimeException("This NodeSetDTM can not do indexing or counting functions!");
373+
}
364374

365375
final int saved = m_next;
366376
// because nextNode always increments
@@ -386,10 +396,11 @@ public int getCurrentNode() {
386396
@Override
387397
public void setShouldCacheNodes(final boolean b) {
388398

389-
if (!isFresh())
390-
throw new RuntimeException(
391-
XPATHMessages.createXPATHMessage(
392-
XPATHErrorResources.ER_CANNOT_CALL_SETSHOULDCACHENODE, null));
399+
if (!isFresh()) {
400+
throw new RuntimeException(
401+
XPATHMessages.createXPATHMessage(
402+
XPATHErrorResources.ER_CANNOT_CALL_SETSHOULDCACHENODE, null));
403+
}
393404
m_cacheNodes = b;
394405
}
395406

src/main/java/org/htmlunit/xpath/XPathContext.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ public void reset() {
119119
* @return A non-null ErrorListener reference.
120120
*/
121121
public final ErrorListener getErrorListener() {
122-
if (null != m_errorListener) return m_errorListener;
122+
if (null != m_errorListener) {
123+
return m_errorListener;
124+
}
123125

124126
if (null == m_defaultErrorListener) {
125127
m_defaultErrorListener = new org.htmlunit.xpath.xml.utils.DefaultErrorHandler();
@@ -133,9 +135,10 @@ public final ErrorListener getErrorListener() {
133135
* @param listener A non-null ErrorListener reference.
134136
*/
135137
public void setErrorListener(final ErrorListener listener) throws IllegalArgumentException {
136-
if (listener == null)
137-
throw new IllegalArgumentException(
138-
XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, null));
138+
if (listener == null) {
139+
throw new IllegalArgumentException(
140+
XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, null));
141+
}
139142
m_errorListener = listener;
140143
}
141144

src/main/java/org/htmlunit/xpath/axes/LocPathIterator.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ public void setRoot(final int context, final Object environment) {
172172
m_currentContextNode = context; // only if top level?
173173

174174
// Yech, shouldn't have to do this. -sb
175-
if (null == m_prefixResolver) m_prefixResolver = xctxt.getNamespaceContext();
175+
if (null == m_prefixResolver) {
176+
m_prefixResolver = xctxt.getNamespaceContext();
177+
}
176178

177179
m_lastFetched = DTM.NULL;
178180
m_foundLast = false;
@@ -225,11 +227,15 @@ public int getLength() {
225227
// If we have already calculated the length, and the current predicate
226228
// is the first predicate, then return the length. We don't cache
227229
// the anything but the length of the list to the first predicate.
228-
if (-1 != m_length && isPredicateTest && m_predicateIndex < 1) return m_length;
230+
if (-1 != m_length && isPredicateTest && m_predicateIndex < 1) {
231+
return m_length;
232+
}
229233

230234
// I'm a bit worried about this one, since it doesn't have the
231235
// checks found above. I suspect it's fine. -sb
232-
if (m_foundLast) return m_pos;
236+
if (m_foundLast) {
237+
return m_pos;
238+
}
233239

234240
// Create a clone, and count from the current position to the end
235241
// of the list, not taking into account the current predicate and
@@ -260,7 +266,9 @@ public int getLength() {
260266
pos++;
261267
}
262268

263-
if (isPredicateTest && m_predicateIndex < 1) m_length = pos;
269+
if (isPredicateTest && m_predicateIndex < 1) {
270+
m_length = pos;
271+
}
264272

265273
return pos;
266274
}
@@ -357,7 +365,9 @@ protected int returnNextNode(final int nextNode) {
357365

358366
m_lastFetched = nextNode;
359367

360-
if (DTM.NULL == nextNode) m_foundLast = true;
368+
if (DTM.NULL == nextNode) {
369+
m_foundLast = true;
370+
}
361371

362372
return nextNode;
363373
}
@@ -372,15 +382,20 @@ public int getCurrentNode() {
372382
@Override
373383
public void runTo(final int index) {
374384

375-
if (m_foundLast || ((index >= 0) && (index <= getCurrentPos()))) return;
385+
if (m_foundLast || ((index >= 0) && (index <= getCurrentPos()))) {
386+
return;
387+
}
376388

377389
if (-1 == index) {
378-
while (DTM.NULL != nextNode())
390+
while (DTM.NULL != nextNode()) {
379391
;
380392
}
393+
}
381394
else {
382395
while (DTM.NULL != nextNode()) {
383-
if (getCurrentPos() >= index) break;
396+
if (getCurrentPos() >= index) {
397+
break;
398+
}
384399
}
385400
}
386401
}

src/main/java/org/htmlunit/xpath/axes/NodeSequence.java

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,16 @@ public void setRoot(final int nodeHandle, final Object environment) {
184184
m_dtmMgr = xctxt.getDTMManager();
185185
m_iter.setRoot(nodeHandle, environment);
186186
if (!m_iter.isDocOrdered()) {
187-
if (!hasCache()) setShouldCacheNodes(true);
187+
if (!hasCache()) {
188+
setShouldCacheNodes(true);
189+
}
188190
runTo(-1);
189191
m_next = 0;
190192
}
191193
}
192-
else assertion(false, "Can not setRoot on a non-iterated NodeSequence!");
194+
else {
195+
assertion(false, "Can not setRoot on a non-iterated NodeSequence!");
196+
}
193197
}
194198

195199
/** {@inheritDoc} */
@@ -236,7 +240,9 @@ else if (cacheComplete() || (-1 != m_last) || (null == m_iter)) {
236240
}
237241
}
238242

239-
if (null == m_iter) return DTM.NULL;
243+
if (null == m_iter) {
244+
return DTM.NULL;
245+
}
240246

241247
final int next = m_iter.nextNode();
242248
if (DTM.NULL != next) {
@@ -247,10 +253,14 @@ else if (cacheComplete() || (-1 != m_last) || (null == m_iter)) {
247253
}
248254
else {
249255
final int insertIndex = addNodeInDocOrder(next);
250-
if (insertIndex >= 0) m_next++;
256+
if (insertIndex >= 0) {
257+
m_next++;
258+
}
251259
}
252260
}
253-
else m_next++;
261+
else {
262+
m_next++;
263+
}
254264
}
255265
else {
256266
// We have exhausted the iterator, and if there is a cache
@@ -285,7 +295,9 @@ public int previousNode() {
285295
/** {@inheritDoc} */
286296
@Override
287297
public void detach() {
288-
if (null != m_iter) m_iter.detach();
298+
if (null != m_iter) {
299+
m_iter.detach();
300+
}
289301
super.detach();
290302
}
291303

@@ -321,7 +333,9 @@ public void setShouldCacheNodes(final boolean b) {
321333
setVector(new NodeVector());
322334
}
323335
}
324-
else setVector(null);
336+
else {
337+
setVector(null);
338+
}
325339
}
326340

327341
/** {@inheritDoc} */
@@ -335,8 +349,9 @@ public int getCurrentPos() {
335349
public void runTo(final int index) {
336350
if (-1 == index) {
337351
final int pos = m_next;
338-
while (DTM.NULL != nextNode())
352+
while (DTM.NULL != nextNode()) {
339353
;
354+
}
340355
m_next = pos;
341356
}
342357
else if (m_next == index) {
@@ -345,13 +360,15 @@ else if (hasCache() && m_next < getVector().size()) {
345360
m_next = index;
346361
}
347362
else if ((null == getVector()) && (index < m_next)) {
348-
while ((m_next >= index) && DTM.NULL != previousNode())
363+
while ((m_next >= index) && DTM.NULL != previousNode()) {
349364
;
350365
}
366+
}
351367
else {
352-
while ((m_next < index) && DTM.NULL != nextNode())
368+
while ((m_next < index) && DTM.NULL != nextNode()) {
353369
;
354370
}
371+
}
355372
}
356373

357374
/** {@inheritDoc} */
@@ -414,7 +431,9 @@ public DTMIterator cloneWithReset() throws CloneNotSupportedException {
414431
@Override
415432
public Object clone() throws CloneNotSupportedException {
416433
final NodeSequence clone = (NodeSequence) super.clone();
417-
if (null != m_iter) clone.m_iter = (DTMIterator) m_iter.clone();
434+
if (null != m_iter) {
435+
clone.m_iter = (DTMIterator) m_iter.clone();
436+
}
418437

419438
return clone;
420439
}

0 commit comments

Comments
 (0)