Skip to content

Commit b852c2d

Browse files
committed
[ignore] fix formatting
1 parent e3cb994 commit b852c2d

File tree

2 files changed

+143
-146
lines changed

2 files changed

+143
-146
lines changed

exist-core/src/main/java/org/exist/xquery/LocationStep.java

Lines changed: 60 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
/**
4343
* Processes all location path steps (like descendant::*, ancestor::XXX).
44-
*
44+
* <p>
4545
* The results of the first evaluation of the expression are cached for the
4646
* lifetime of the object and only reloaded if the context sequence (as passed
4747
* to the {@link #eval(Sequence, Item)} method) has changed.
@@ -63,7 +63,7 @@ public class LocationStep extends Step {
6363
//private int parentDeps = Dependency.UNKNOWN_DEPENDENCY;
6464
private boolean preloadedData = false;
6565
protected boolean optimized = false;
66-
// private boolean inUpdate = false;
66+
//private boolean inUpdate = false;
6767
private boolean useDirectChildSelect = false;
6868
private boolean applyPredicate = true;
6969

@@ -84,36 +84,36 @@ public LocationStep(final XQueryContext context, final int axis) {
8484
* Creates a new instance.
8585
*
8686
* @param context the XQuery context
87-
* @param axis the axis of the location step
88-
* @param test a node test on the axis
87+
* @param axis the axis of the location step
88+
* @param test a node test on the axis
8989
*/
90-
public LocationStep(final XQueryContext context, final int axis, final NodeTest test) {
90+
public LocationStep(final XQueryContext context, final int axis, final NodeTest test) {
9191
super(context, axis, test);
9292
}
9393

9494
@Override
9595
public int getDependencies() {
96-
int deps = Dependency.CONTEXT_SET;
96+
int dependencies = Dependency.CONTEXT_SET;
9797

9898
// self axis has an obvious dependency on the context item
9999
// likewise we depend on the context item if this is a single path step (outside a predicate)
100-
if (!this.inPredicate &&
101-
(this.axis == Constants.SELF_AXIS ||
100+
if (!inPredicate &&
101+
(axis == Constants.SELF_AXIS ||
102102
(parent != null && parent.getSubExpressionCount() > 0 && parent.getSubExpression(0) == this))) {
103-
deps = deps | Dependency.CONTEXT_ITEM;
103+
dependencies = dependencies | Dependency.CONTEXT_ITEM;
104104
}
105105

106106
// TODO : normally, we should call this one...
107107
// int deps = super.getDependencies(); ???
108-
for (final Predicate pred : predicates) {
109-
deps |= pred.getDependencies();
108+
for (final Predicate predicate : predicates) {
109+
dependencies |= predicate.getDependencies();
110110
}
111111

112112
// TODO : should we remove the CONTEXT_ITEM dependency returned by the
113113
// predicates ? See the comment above.
114114
// consider nested predicates however...
115115

116-
return deps;
116+
return dependencies;
117117
}
118118

119119
/**
@@ -147,10 +147,10 @@ private boolean hasPreloadedData() {
147147
* @param nodes a <code>NodeSet</code> value
148148
*/
149149
public void setPreloadedData(final DocumentSet docs, final NodeSet nodes) {
150-
this.preloadedData = true;
151-
this.currentDocs = docs;
152-
this.currentSet = nodes;
153-
this.optimized = true;
150+
preloadedData = true;
151+
currentDocs = docs;
152+
currentSet = nodes;
153+
optimized = true;
154154
}
155155

156156
/**
@@ -165,12 +165,9 @@ private Sequence applyPredicate(Sequence outerSequence, final Sequence contextSe
165165
if (contextSequence == null) {
166166
return Sequence.EMPTY_SEQUENCE;
167167
}
168-
if (predicates.size() == 0
169-
|| !applyPredicate
170-
|| (!(contextSequence instanceof VirtualNodeSet) && contextSequence
171-
.isEmpty()))
172-
// Nothing to apply
173-
{
168+
if (predicates.size() == 0 || !applyPredicate || (
169+
!(contextSequence instanceof VirtualNodeSet) && contextSequence.isEmpty())) {
170+
// Nothing to apply
174171
return contextSequence;
175172
}
176173
Sequence result;
@@ -183,9 +180,8 @@ private Sequence applyPredicate(Sequence outerSequence, final Sequence contextSe
183180
//
184181
// If the predicate is known to return a node set, no special treatment
185182
// is required.
186-
if (abbreviatedStep
187-
&& (pred.getExecutionMode() != Predicate.ExecutionMode.NODE || !contextSequence
188-
.isPersistentSet())) {
183+
if (abbreviatedStep && (
184+
pred.getExecutionMode() != Predicate.ExecutionMode.NODE || !contextSequence.isPersistentSet())) {
189185
result = new ValueSequence();
190186
((ValueSequence) result).keepUnOrdered(unordered);
191187
if (contextSequence.isPersistentSet()) {
@@ -222,9 +218,9 @@ private Sequence processPredicate(Sequence outerSequence, final Sequence context
222218
for (final Iterator<Predicate> i = predicates.iterator(); i.hasNext()
223219
&& (result instanceof VirtualNodeSet || !result.isEmpty()); ) {
224220
// TODO : log and/or profile ?
225-
final Predicate pred = i.next();
226-
pred.setContextDocSet(getContextDocSet());
227-
result = pred.evalPredicate(outerSequence, result, axis);
221+
final Predicate predicate = i.next();
222+
predicate.setContextDocSet(getContextDocSet());
223+
result = predicate.evalPredicate(outerSequence, result, axis);
228224
// subsequent predicates operate on the result of the previous one
229225
outerSequence = null;
230226
context.setContextSequencePosition(-1, null);
@@ -234,7 +230,7 @@ private Sequence processPredicate(Sequence outerSequence, final Sequence context
234230

235231
@Override
236232
public void analyze(final AnalyzeContextInfo contextInfo) throws XPathException {
237-
this.parent = contextInfo.getParent();
233+
parent = contextInfo.getParent();
238234

239235
unordered = (contextInfo.getFlags() & UNORDERED) > 0;
240236

@@ -248,16 +244,18 @@ public void analyze(final AnalyzeContextInfo contextInfo) throws XPathException
248244
if ((contextInfo.getFlags() & USE_TREE_TRAVERSAL) > 0) {
249245
useDirectChildSelect = true;
250246
}
247+
251248
// Mark ".", which is expanded as self::node() by the parser
252249
// even though it may *also* be relevant with atomic sequences
253-
if (this.axis == Constants.SELF_AXIS
254-
&& this.test.getType() == Type.NODE) {
250+
// JL: may be unnecessary since ContextItemExpression will add the DOT_TEST flag by itself
251+
// JL: literal self::node() might still need this
252+
if (axis == Constants.SELF_AXIS && test.getType() == Type.NODE) {
255253
contextInfo.addFlag(DOT_TEST);
256254
}
257255

258-
//Change axis from descendant-or-self to descendant for '//'
259-
if (this.axis == Constants.DESCENDANT_SELF_AXIS && isAbbreviated()) {
260-
this.axis = Constants.DESCENDANT_AXIS;
256+
// Change axis from descendant-or-self to descendant for '//'
257+
if (axis == Constants.DESCENDANT_SELF_AXIS && isAbbreviated()) {
258+
axis = Constants.DESCENDANT_AXIS;
261259
}
262260

263261
final Expression contextStep;
@@ -320,8 +318,8 @@ public void analyze(final AnalyzeContextInfo contextInfo) throws XPathException
320318
staticReturnType = Type.EMPTY;
321319
}
322320
break;
323-
// case Constants.PARENT_AXIS:
324-
// case Constants.ATTRIBUTE_AXIS:
321+
// case Constants.PARENT_AXIS:
322+
// case Constants.ATTRIBUTE_AXIS:
325323
default:
326324
}
327325

@@ -385,7 +383,6 @@ public Sequence eval(Sequence contextSequence, final Item contextItem)
385383

386384
try {
387385
switch (axis) {
388-
389386
case Constants.DESCENDANT_AXIS:
390387
case Constants.DESCENDANT_SELF_AXIS:
391388
result = getDescendants(context, contextSequence);
@@ -486,16 +483,15 @@ private boolean needsComputation() {
486483
if (nodeTestType == null) {
487484
nodeTestType = test.getType();
488485
}
489-
if (nodeTestType != Type.NODE
490-
&& nodeTestType != Type.ELEMENT
491-
&& nodeTestType != Type.PROCESSING_INSTRUCTION) {
486+
if (nodeTestType != Type.NODE &&
487+
nodeTestType != Type.ELEMENT &&
488+
nodeTestType != Type.PROCESSING_INSTRUCTION) {
492489
if (context.getProfiler().isEnabled()) {
493490
context.getProfiler().message(this, Profiler.OPTIMIZATIONS,
494491
"OPTIMIZATION", "avoid useless computations");
495492
}
496493
return false;
497494
}
498-
499495
}
500496
return true;
501497
}
@@ -556,7 +552,7 @@ private Sequence getSelf(final XQueryContext context, final Sequence contextSequ
556552
} else {
557553
final NewArrayNodeSet results = new NewArrayNodeSet();
558554
for (final NodeProxy p : contextSet) {
559-
if(test.matches(p)) {
555+
if (test.matches(p)) {
560556
results.add(p);
561557
}
562558
}
@@ -601,10 +597,8 @@ protected Sequence getAttributes(final XQueryContext context, final Sequence con
601597
if (hasPreloadedData()) {
602598
final DocumentSet docs = getDocumentSet(contextSet);
603599
synchronized (context) {
604-
if (currentSet == null
605-
|| currentDocs == null
606-
|| (!optimized && !(docs == currentDocs || docs
607-
.equalDocs(currentDocs)))) {
600+
if (currentSet == null || currentDocs == null || (
601+
!optimized && !(docs == currentDocs || docs.equalDocs(currentDocs)))) {
608602
final StructuralIndex index = context.getBroker().getStructuralIndex();
609603
if (context.getProfiler().isEnabled()) {
610604
context.getProfiler().message(
@@ -691,10 +685,8 @@ private Sequence getChildren(final XQueryContext context, final Sequence context
691685
synchronized (context) {
692686
// TODO : understand why this one is different from the other
693687
// ones
694-
if (currentSet == null
695-
|| currentDocs == null
696-
|| (!optimized && !(docs == currentDocs || docs
697-
.equalDocs(currentDocs)))) {
688+
if (currentSet == null || currentDocs == null || (
689+
!optimized && !(docs == currentDocs || docs.equalDocs(currentDocs)))) {
698690
final StructuralIndex index = context.getBroker().getStructuralIndex();
699691
if (context.getProfiler().isEnabled()) {
700692
context.getProfiler().message(
@@ -735,15 +727,14 @@ private Sequence getChildren(final XQueryContext context, final Sequence context
735727
private Sequence getDescendants(final XQueryContext context, final Sequence contextSequence) throws XPathException {
736728
if (!contextSequence.isPersistentSet()) {
737729
final MemoryNodeSet nodes = contextSequence.toMemNodeSet();
738-
return nodes.getDescendants(axis == Constants.DESCENDANT_SELF_AXIS,
739-
test);
730+
return nodes.getDescendants(axis == Constants.DESCENDANT_SELF_AXIS, test);
740731
}
741732

742733
final NodeSet contextSet = contextSequence.toNodeSet();
743734
// TODO : understand this. I guess comments should be treated in a
744735
// similar way ? -pb
745-
if ((!hasPreloadedData() && test.isWildcardTest())
746-
|| test.getType() == Type.PROCESSING_INSTRUCTION) {
736+
if ((!hasPreloadedData() && test.isWildcardTest()) ||
737+
test.getType() == Type.PROCESSING_INSTRUCTION) {
747738
// test is one out of *, text(), node() including
748739
// processing-instruction(targetname)
749740
final VirtualNodeSet vset = new VirtualNodeSet(context.getBroker(), axis, test, contextId, contextSet);
@@ -754,10 +745,8 @@ private Sequence getDescendants(final XQueryContext context, final Sequence cont
754745
synchronized (context) {
755746
// TODO : understand why this one is different from the other
756747
// ones
757-
if (currentSet == null
758-
|| currentDocs == null
759-
|| (!optimized && !(docs == currentDocs || docs
760-
.equalDocs(currentDocs)))) {
748+
if (currentSet == null || currentDocs == null || (
749+
!optimized && !(docs == currentDocs || docs.equalDocs(currentDocs)))) {
761750
final StructuralIndex index = context.getBroker().getStructuralIndex();
762751
if (context.getProfiler().isEnabled()) {
763752
context.getProfiler().message(
@@ -774,11 +763,11 @@ private Sequence getDescendants(final XQueryContext context, final Sequence cont
774763

775764
switch (axis) {
776765
case Constants.DESCENDANT_SELF_AXIS:
777-
return currentSet.selectAncestorDescendant(contextSet, NodeSet.DESCENDANT, true, contextId,
778-
true);
766+
return currentSet.selectAncestorDescendant(
767+
contextSet, NodeSet.DESCENDANT, true, contextId, true);
779768
case Constants.DESCENDANT_AXIS:
780-
return currentSet.selectAncestorDescendant(contextSet, NodeSet.DESCENDANT, false, contextId,
781-
true);
769+
return currentSet.selectAncestorDescendant(
770+
contextSet, NodeSet.DESCENDANT, false, contextId, true);
782771
default:
783772
throw new IllegalArgumentException("Unsupported axis specified");
784773
}
@@ -910,11 +899,9 @@ protected Sequence getSiblings(final XQueryContext context, final Sequence conte
910899
/**
911900
* Get the preceding or following axis nodes
912901
*
913-
* @param context the xquery context
902+
* @param context the xquery context
914903
* @param contextSequence the context sequence
915-
*
916904
* @return the nodes from the preceding or following axis
917-
*
918905
* @throws XPathException if an error occurs
919906
*/
920907
private Sequence getPrecedingOrFollowing(final XQueryContext context, final Sequence contextSequence)
@@ -1034,11 +1021,9 @@ private int computeLimit() throws XPathException {
10341021
/**
10351022
* Get the ancestor axis nodes
10361023
*
1037-
* @param context the xquery context
1024+
* @param context the xquery context
10381025
* @param contextSequence the context sequence
1039-
*
10401026
* @return the ancestor nodes
1041-
*
10421027
* @throws XPathException if an error occurs
10431028
*/
10441029
protected Sequence getAncestors(final XQueryContext context, final Sequence contextSequence) throws XPathException {
@@ -1138,11 +1123,9 @@ protected Sequence getAncestors(final XQueryContext context, final Sequence cont
11381123
/**
11391124
* Get the parent axis nodes
11401125
*
1141-
* @param context the xquery context
1126+
* @param context the xquery context
11421127
* @param contextSequence the context sequence
1143-
*
11441128
* @return the parent nodes
1145-
*
11461129
* @throws XPathException if an error occurs
11471130
*/
11481131
protected Sequence getParents(final XQueryContext context, final Sequence contextSequence) throws XPathException {
@@ -1164,7 +1147,8 @@ protected Sequence getParents(final XQueryContext context, final Sequence contex
11641147
} else if (hasPreloadedData()) {
11651148
final DocumentSet docs = getDocumentSet(contextSet);
11661149
synchronized (context) {
1167-
if (currentSet == null || currentDocs == null || (!optimized && !(docs == currentDocs || docs.equalDocs(currentDocs)))) {
1150+
if (currentSet == null || currentDocs == null ||
1151+
(!optimized && !(docs == currentDocs || docs.equalDocs(currentDocs)))) {
11681152
final StructuralIndex index = context.getBroker().getStructuralIndex();
11691153
if (context.getProfiler().isEnabled()) {
11701154
context.getProfiler().message(
@@ -1313,7 +1297,7 @@ private class FollowingSiblingFilter extends AbstractFilterBase {
13131297
boolean sibling = false;
13141298

13151299
FollowingSiblingFilter(final NodeTest test, final NodeProxy start, final NodeSet result,
1316-
final int contextId, final int limit) {
1300+
final int contextId, final int limit) {
13171301
super(test, result, contextId, limit);
13181302
this.start = start;
13191303
this.level = start.getNodeId().getTreeLevel();
@@ -1365,7 +1349,7 @@ private class PrecedingSiblingFilter extends AbstractFilterBase {
13651349
final NodeProxy referenceNode;
13661350

13671351
PrecedingSiblingFilter(final NodeTest test, final NodeProxy start, final NodeProxy referenceNode,
1368-
final NodeSet result, final int contextId) {
1352+
final NodeSet result, final int contextId) {
13691353
super(test, result, contextId, -1);
13701354
this.level = start.getNodeId().getTreeLevel();
13711355
this.referenceNode = referenceNode;
@@ -1413,7 +1397,7 @@ private class FollowingFilter extends AbstractFilterBase {
14131397
boolean isAfter = false;
14141398

14151399
FollowingFilter(final NodeTest test, final NodeProxy root, final NodeProxy referenceNode, final NodeSet result,
1416-
final int contextId, final int limit) {
1400+
final int contextId, final int limit) {
14171401
super(test, result, contextId, limit);
14181402
this.root = root;
14191403
this.referenceNode = referenceNode;
@@ -1462,7 +1446,7 @@ private class PrecedingFilter extends AbstractFilterBase {
14621446
final NodeProxy referenceNode;
14631447

14641448
PrecedingFilter(final NodeTest test, final NodeProxy root, final NodeProxy referenceNode, final NodeSet result,
1465-
final int contextId) {
1449+
final int contextId) {
14661450
super(test, result, contextId, -1);
14671451
this.root = root;
14681452
this.referenceNode = referenceNode;

0 commit comments

Comments
 (0)