From b7d5145bc93aa089b0034096b858ca900f4bf71c Mon Sep 17 00:00:00 2001 From: Ronald Brill Date: Sat, 2 Dec 2023 16:51:05 +0100 Subject: [PATCH] code style --- .../xpath/axes/AttributeIterator.java | 4 +- .../org/htmlunit/xpath/axes/AxesWalker.java | 20 +- .../xpath/axes/BasicTestIterator.java | 15 +- .../htmlunit/xpath/axes/WalkerFactory.java | 174 +++++++-------- .../xpath/xml/dtm/ref/dom2dtm/DOM2DTM.java | 210 +++++++----------- ...OM2DTMdefaultNamespaceDeclarationNode.java | 58 ++--- 6 files changed, 211 insertions(+), 270 deletions(-) diff --git a/src/main/java/org/htmlunit/xpath/axes/AttributeIterator.java b/src/main/java/org/htmlunit/xpath/axes/AttributeIterator.java index b57e861..c08a1c8 100644 --- a/src/main/java/org/htmlunit/xpath/axes/AttributeIterator.java +++ b/src/main/java/org/htmlunit/xpath/axes/AttributeIterator.java @@ -28,10 +28,10 @@ public class AttributeIterator extends ChildTestIterator { * * @param compiler A reference to the Compiler that contains the op map. * @param opPos The position within the op map, which contains the location path expression for - * this itterator. + * this iterator. * @throws javax.xml.transform.TransformerException if any */ - AttributeIterator(Compiler compiler, int opPos, int analysis) + AttributeIterator(final Compiler compiler, final int opPos, final int analysis) throws javax.xml.transform.TransformerException { super(compiler, opPos, analysis); } diff --git a/src/main/java/org/htmlunit/xpath/axes/AxesWalker.java b/src/main/java/org/htmlunit/xpath/axes/AxesWalker.java index ed6a23c..e6786da 100644 --- a/src/main/java/org/htmlunit/xpath/axes/AxesWalker.java +++ b/src/main/java/org/htmlunit/xpath/axes/AxesWalker.java @@ -258,19 +258,15 @@ public int nextNode() { // return walker.returnNextNode(nextNode); break; - } else { - AxesWalker prev = walker; - - walker = walker.m_nextWalker; - - walker.setRoot(nextNode); - - walker.m_prevWalker = prev; - - continue; } - } // if(null != nextNode) - } // while(null != walker) + + AxesWalker prev = walker; + walker = walker.m_nextWalker; + walker.setRoot(nextNode); + walker.m_prevWalker = prev; + continue; + } + } return nextNode; } diff --git a/src/main/java/org/htmlunit/xpath/axes/BasicTestIterator.java b/src/main/java/org/htmlunit/xpath/axes/BasicTestIterator.java index 7f36c1c..f5f08ce 100644 --- a/src/main/java/org/htmlunit/xpath/axes/BasicTestIterator.java +++ b/src/main/java/org/htmlunit/xpath/axes/BasicTestIterator.java @@ -35,7 +35,7 @@ public abstract class BasicTestIterator extends LocPathIterator { * * @param nscontext The namespace context for this iterator, should be OK if null. */ - protected BasicTestIterator(PrefixResolver nscontext) { + protected BasicTestIterator(final PrefixResolver nscontext) { super(nscontext); } @@ -48,12 +48,12 @@ protected BasicTestIterator(PrefixResolver nscontext) { * @param opPos The position of this iterator in the opcode list from the compiler. * @throws javax.xml.transform.TransformerException if any */ - protected BasicTestIterator(Compiler compiler, int opPos, int analysis) + protected BasicTestIterator(final Compiler compiler, final int opPos, final int analysis) throws javax.xml.transform.TransformerException { super(analysis); - int firstStepPos = OpMap.getFirstChildPos(opPos); - int whatToShow = compiler.getWhatToShow(firstStepPos); + final int firstStepPos = OpMap.getFirstChildPos(opPos); + final int whatToShow = compiler.getWhatToShow(firstStepPos); if ((0 == (whatToShow @@ -96,8 +96,9 @@ public int nextNode() { if (DTM.NULL != next) { if (DTMIterator.FILTER_ACCEPT == acceptNode(next)) break; - else continue; - } else break; + continue; + } + break; } while (next != DTM.NULL); if (DTM.NULL != next) { @@ -114,7 +115,7 @@ public int nextNode() { @Override public DTMIterator cloneWithReset() throws CloneNotSupportedException { - ChildTestIterator clone = (ChildTestIterator) super.cloneWithReset(); + final ChildTestIterator clone = (ChildTestIterator) super.cloneWithReset(); clone.resetProximityPositions(); diff --git a/src/main/java/org/htmlunit/xpath/axes/WalkerFactory.java b/src/main/java/org/htmlunit/xpath/axes/WalkerFactory.java index e3d75f8..faa3149 100644 --- a/src/main/java/org/htmlunit/xpath/axes/WalkerFactory.java +++ b/src/main/java/org/htmlunit/xpath/axes/WalkerFactory.java @@ -51,14 +51,14 @@ public class WalkerFactory { * @return non-null AxesWalker derivative. * @throws javax.xml.transform.TransformerException if any */ - static AxesWalker loadWalkers(WalkingIterator lpi, Compiler compiler, int stepOpCodePos) + static AxesWalker loadWalkers(final WalkingIterator lpi, final Compiler compiler, int stepOpCodePos) throws javax.xml.transform.TransformerException { int stepType; AxesWalker firstWalker = null; AxesWalker walker, prevWalker = null; - int analysis = analyze(compiler, stepOpCodePos); + final int analysis = analyze(compiler, stepOpCodePos); while (OpCodes.ENDOP != (stepType = compiler.getOp(stepOpCodePos))) { walker = createDefaultWalker(compiler, stepOpCodePos, lpi, analysis); @@ -83,11 +83,11 @@ static AxesWalker loadWalkers(WalkingIterator lpi, Compiler compiler, int stepOp return firstWalker; } - public static boolean isSet(int analysis, int bits) { + public static boolean isSet(final int analysis, final int bits) { return 0 != (analysis & bits); } - public static void diagnoseIterator(String name, int analysis, Compiler compiler) { + public static void diagnoseIterator(final String name, final int analysis, final Compiler compiler) { System.out.println( compiler.toString() + ", " @@ -108,13 +108,13 @@ public static void diagnoseIterator(String name, int analysis, Compiler compiler * @return non-null reference to a LocPathIterator or derivative. * @throws javax.xml.transform.TransformerException if any */ - public static DTMIterator newDTMIterator(Compiler compiler, int opPos, boolean isTopLevel) + public static DTMIterator newDTMIterator(final Compiler compiler, final int opPos, final boolean isTopLevel) throws javax.xml.transform.TransformerException { - int firstStepPos = OpMap.getFirstChildPos(opPos); - int analysis = analyze(compiler, firstStepPos); - boolean isOneStep = isOneStep(analysis); - LocPathIterator iter; + final int firstStepPos = OpMap.getFirstChildPos(opPos); + final int analysis = analyze(compiler, firstStepPos); + final boolean isOneStep = isOneStep(analysis); + final LocPathIterator iter; // Is the iteration a one-step attribute pattern (i.e. select="@foo")? if (isOneStep && walksSelfOnly(analysis) && isWild(analysis) && !hasPredicate(analysis)) { @@ -217,9 +217,9 @@ else if (isOptimizableForDescendantIterator(compiler, firstStepPos) * @param stepOpCodePos The opcode position for the step. * @return 32 bits as an integer that give information about the location path as a whole. */ - public static int getAxisFromStep(Compiler compiler, int stepOpCodePos) { + public static int getAxisFromStep(final Compiler compiler, final int stepOpCodePos) { - int stepType = compiler.getOp(stepOpCodePos); + final int stepType = compiler.getOp(stepOpCodePos); switch (stepType) { case OpCodes.FROM_FOLLOWING: @@ -267,7 +267,7 @@ public static int getAxisFromStep(Compiler compiler, int stepOpCodePos) { * @param axis One of Axis.ANCESTOR, etc. * @return One of BIT_ANCESTOR, etc. */ - public static int getAnalysisBitFromAxes(int axis) { + public static int getAnalysisBitFromAxes(final int axis) { switch (axis) // Generate new traverser { case Axis.ANCESTOR: @@ -313,10 +313,10 @@ public static int getAnalysisBitFromAxes(int axis) { } } - static boolean functionProximateOrContainsProximate(Compiler compiler, int opPos) { - int endFunc = opPos + compiler.getOp(opPos + 1) - 1; + static boolean functionProximateOrContainsProximate(final Compiler compiler, int opPos) { + final int endFunc = opPos + compiler.getOp(opPos + 1) - 1; opPos = OpMap.getFirstChildPos(opPos); - int funcID = compiler.getOp(opPos); + final int funcID = compiler.getOp(opPos); // System.out.println("funcID: "+funcID); // System.out.println("opPos: "+opPos); // System.out.println("endFunc: "+endFunc); @@ -327,17 +327,17 @@ static boolean functionProximateOrContainsProximate(Compiler compiler, int opPos default: opPos++; for (int p = opPos; p < endFunc; p = compiler.getNextOpPos(p)) { - int innerExprOpPos = p + 2; - boolean prox = isProximateInnerExpr(compiler, innerExprOpPos); + final int innerExprOpPos = p + 2; + final boolean prox = isProximateInnerExpr(compiler, innerExprOpPos); if (prox) return true; } } return false; } - static boolean isProximateInnerExpr(Compiler compiler, int opPos) { - int op = compiler.getOp(opPos); - int innerExprOpPos = opPos + 2; + static boolean isProximateInnerExpr(final Compiler compiler, final int opPos) { + final int op = compiler.getOp(opPos); + final int innerExprOpPos = opPos + 2; switch (op) { case OpCodes.OP_ARGUMENT: if (isProximateInnerExpr(compiler, innerExprOpPos)) return true; @@ -356,8 +356,8 @@ static boolean isProximateInnerExpr(Compiler compiler, int opPos) { case OpCodes.OP_LT: case OpCodes.OP_LTE: case OpCodes.OP_EQUALS: - int leftPos = OpMap.getFirstChildPos(op); - int rightPos = compiler.getNextOpPos(leftPos); + final int leftPos = OpMap.getFirstChildPos(op); + final int rightPos = compiler.getNextOpPos(leftPos); isProx = isProximateInnerExpr(compiler, leftPos); if (isProx) return true; isProx = isProximateInnerExpr(compiler, rightPos); @@ -370,10 +370,10 @@ static boolean isProximateInnerExpr(Compiler compiler, int opPos) { } /** Tell if the predicates need to have proximity knowledge. */ - public static boolean mightBeProximate(Compiler compiler, int opPos, int stepType) + public static boolean mightBeProximate(final Compiler compiler, final int opPos, final int stepType) throws javax.xml.transform.TransformerException { - boolean mightBeProximate = false; + final boolean mightBeProximate = false; switch (stepType) { case OpCodes.OP_VARIABLE: @@ -386,8 +386,8 @@ public static boolean mightBeProximate(Compiler compiler, int opPos, int stepTyp int predPos = compiler.getFirstPredicateOpPos(opPos); while (OpCodes.OP_PREDICATE == compiler.getOp(predPos)) { - int innerExprOpPos = predPos + 2; - int predOp = compiler.getOp(innerExprOpPos); + final int innerExprOpPos = predPos + 2; + final int predOp = compiler.getOp(innerExprOpPos); switch (predOp) { case OpCodes.OP_VARIABLE: @@ -407,8 +407,8 @@ public static boolean mightBeProximate(Compiler compiler, int opPos, int stepTyp case OpCodes.OP_LT: case OpCodes.OP_LTE: case OpCodes.OP_EQUALS: - int leftPos = OpMap.getFirstChildPos(innerExprOpPos); - int rightPos = compiler.getNextOpPos(leftPos); + final int leftPos = OpMap.getFirstChildPos(innerExprOpPos); + final int rightPos = compiler.getNextOpPos(leftPos); isProx = isProximateInnerExpr(compiler, leftPos); if (isProx) return true; isProx = isProximateInnerExpr(compiler, rightPos); @@ -433,7 +433,7 @@ public static boolean mightBeProximate(Compiler compiler, int opPos, int stepTyp * @return 32 bits as an integer that give information about the location path as a whole. * @throws javax.xml.transform.TransformerException if any */ - private static boolean isOptimizableForDescendantIterator(Compiler compiler, int stepOpCodePos) + private static boolean isOptimizableForDescendantIterator(final Compiler compiler, int stepOpCodePos) throws javax.xml.transform.TransformerException { int stepType; @@ -453,7 +453,7 @@ private static boolean isOptimizableForDescendantIterator(Compiler compiler, int stepCount++; if (stepCount > 3) return false; - boolean mightBeProximate = mightBeProximate(compiler, stepOpCodePos, stepType); + final boolean mightBeProximate = mightBeProximate(compiler, stepOpCodePos, stepType); if (mightBeProximate) return false; switch (stepType) { @@ -498,7 +498,7 @@ private static boolean isOptimizableForDescendantIterator(Compiler compiler, int nodeTestType = compiler.getStepTestType(stepOpCodePos); - int nextStepOpCodePos = compiler.getNextStepPos(stepOpCodePos); + final int nextStepOpCodePos = compiler.getNextStepPos(stepOpCodePos); if (nextStepOpCodePos < 0) break; @@ -524,7 +524,7 @@ private static boolean isOptimizableForDescendantIterator(Compiler compiler, int * @return 32 bits as an integer that give information about the location path as a whole. * @throws javax.xml.transform.TransformerException if any */ - private static int analyze(Compiler compiler, int stepOpCodePos) + private static int analyze(final Compiler compiler, int stepOpCodePos) throws javax.xml.transform.TransformerException { int stepType; @@ -534,7 +534,7 @@ private static int analyze(Compiler compiler, int stepOpCodePos) while (OpCodes.ENDOP != (stepType = compiler.getOp(stepOpCodePos))) { stepCount++; - boolean predAnalysis = analyzePredicate(compiler, stepOpCodePos, stepType); + final boolean predAnalysis = analyzePredicate(compiler, stepOpCodePos, stepType); if (predAnalysis) analysisResult |= BIT_PREDICATE; @@ -630,7 +630,7 @@ private static int analyze(Compiler compiler, int stepOpCodePos) * @param axis One of Axis.XXX. * @return true if the axis is not a child axis and does not go up from the axis root. */ - public static boolean isDownwardAxisOfMany(int axis) { + public static boolean isDownwardAxisOfMany(final int axis) { return Axis.DESCENDANTORSELF == axis || (Axis.DESCENDANT == axis) || (Axis.FOLLOWING == axis) @@ -658,7 +658,7 @@ public static boolean isDownwardAxisOfMany(int axis) { * @return A StepPattern object, which may contain relative StepPatterns. * @throws javax.xml.transform.TransformerException if any */ - static StepPattern loadSteps(Compiler compiler, int stepOpCodePos) + static StepPattern loadSteps(final Compiler compiler, int stepOpCodePos) throws javax.xml.transform.TransformerException { if (DEBUG_PATTERN_CREATION) { System.out.println("================"); @@ -686,10 +686,10 @@ static StepPattern loadSteps(Compiler compiler, int stepOpCodePos) } int axis = Axis.SELF; - int paxis = Axis.SELF; + final int paxis = Axis.SELF; StepPattern tail = step; for (StepPattern pat = step; null != pat; pat = pat.getRelativePathPattern()) { - int nextAxis = pat.getAxis(); + final int nextAxis = pat.getAxis(); // int nextPaxis = pat.getPredicateAxis(); pat.setAxis(axis); @@ -716,24 +716,24 @@ static StepPattern loadSteps(Compiler compiler, int stepOpCodePos) // inverted match: "self::*/parent::@*/parent::node()" // Lovely business, this. // -sb - int whatToShow = pat.getWhatToShow(); + final int whatToShow = pat.getWhatToShow(); if (whatToShow == DTMFilter.SHOW_ATTRIBUTE || whatToShow == DTMFilter.SHOW_NAMESPACE) { - int newAxis = (whatToShow == DTMFilter.SHOW_ATTRIBUTE) ? Axis.ATTRIBUTE : Axis.NAMESPACE; + final int newAxis = (whatToShow == DTMFilter.SHOW_ATTRIBUTE) ? Axis.ATTRIBUTE : Axis.NAMESPACE; if (isDownwardAxisOfMany(axis)) { - StepPattern attrPat = + final StepPattern attrPat = new StepPattern( whatToShow, pat.getNamespace(), pat.getLocalName(), // newAxis, pat.getPredicateAxis); newAxis); // don't care about the predicate axis - XNumber score = pat.getStaticScore(); + final XNumber score = pat.getStaticScore(); pat.setNamespace(null); pat.setLocalName(NodeTest.WILD); attrPat.setPredicates(pat.getPredicates()); pat.setPredicates(null); pat.setWhatToShow(DTMFilter.SHOW_ELEMENT); - StepPattern rel = pat.getRelativePathPattern(); + final StepPattern rel = pat.getRelativePathPattern(); pat.setRelativePathPattern(attrPat); attrPat.setRelativePathPattern(rel); attrPat.setStaticScore(score); @@ -758,9 +758,9 @@ static StepPattern loadSteps(Compiler compiler, int stepOpCodePos) } if (axis < Axis.ALL) { - StepPattern selfPattern = new ContextMatchStepPattern(axis, paxis); + final StepPattern selfPattern = new ContextMatchStepPattern(axis, paxis); // We need to keep the new nodetest from affecting the score... - XNumber score = tail.getStaticScore(); + final XNumber score = tail.getStaticScore(); tail.setRelativePathPattern(selfPattern); tail.setStaticScore(score); selfPattern.setStaticScore(score); @@ -781,20 +781,20 @@ static StepPattern loadSteps(Compiler compiler, int stepOpCodePos) * @return the head of the list. * @throws javax.xml.transform.TransformerException if any */ - private static StepPattern createDefaultStepPattern(Compiler compiler, int opPos) + private static StepPattern createDefaultStepPattern(final Compiler compiler, final int opPos) throws javax.xml.transform.TransformerException { - int stepType = compiler.getOp(opPos); + final int stepType = compiler.getOp(opPos); int whatToShow = compiler.getWhatToShow(opPos); StepPattern ai = null; - int axis; + final int axis; switch (stepType) { case OpCodes.OP_VARIABLE: case OpCodes.OP_FUNCTION: case OpCodes.OP_GROUP: - Expression expr; + final Expression expr; switch (stepType) { case OpCodes.OP_VARIABLE: @@ -865,7 +865,7 @@ private static StepPattern createDefaultStepPattern(Compiler compiler, int opPos whatToShow, compiler.getStepNS(opPos), compiler.getStepLocalName(opPos), axis); } - int argLen = compiler.getFirstPredicateOpPos(opPos); + final int argLen = compiler.getFirstPredicateOpPos(opPos); ai.setPredicates(compiler.getCompiledPredicates(argLen)); @@ -883,7 +883,7 @@ private static StepPattern createDefaultStepPattern(Compiler compiler, int opPos * @return true if step has a predicate. * @throws javax.xml.transform.TransformerException if any */ - static boolean analyzePredicate(Compiler compiler, int opPos, int stepType) + static boolean analyzePredicate(final Compiler compiler, final int opPos, final int stepType) throws javax.xml.transform.TransformerException { switch (stepType) { @@ -894,8 +894,8 @@ static boolean analyzePredicate(Compiler compiler, int opPos, int stepType) default: } - int pos = compiler.getFirstPredicateOpPos(opPos); - int nPredicates = compiler.countPredicates(pos); + final int pos = compiler.getFirstPredicateOpPos(opPos); + final int nPredicates = compiler.countPredicates(pos); return nPredicates > 0; } @@ -912,10 +912,10 @@ static boolean analyzePredicate(Compiler compiler, int opPos, int stepType) * @throws RuntimeException if the input is bad. */ private static AxesWalker createDefaultWalker( - Compiler compiler, int opPos, WalkingIterator lpi, int analysis) { + final Compiler compiler, final int opPos, final WalkingIterator lpi, final int analysis) { - AxesWalker ai; - int stepType = compiler.getOp(opPos); + final AxesWalker ai; + final int stepType = compiler.getOp(opPos); /* * System.out.println("0: "+compiler.getOp(opPos)); @@ -989,7 +989,7 @@ private static AxesWalker createDefaultWalker( if (simpleInit) { ai.initNodeTest(DTMFilter.SHOW_ALL); } else { - int whatToShow = compiler.getWhatToShow(opPos); + final int whatToShow = compiler.getWhatToShow(opPos); if ((0 == (whatToShow @@ -1006,8 +1006,8 @@ private static AxesWalker createDefaultWalker( return ai; } - public static String getAnalysisString(int analysis) { - StringBuilder buf = new StringBuilder(); + public static String getAnalysisString(final int analysis) { + final StringBuilder buf = new StringBuilder(); buf.append("count: ").append(getStepCount(analysis)).append(" "); if ((analysis & BIT_NODETEST_ANY) != 0) { buf.append("NTANY|"); @@ -1072,73 +1072,73 @@ public static String getAnalysisString(int analysis) { /** Set to true for diagnostics about iterator creation */ static final boolean DEBUG_ITERATOR_CREATION = false; - public static boolean hasPredicate(int analysis) { + public static boolean hasPredicate(final int analysis) { return 0 != (analysis & BIT_PREDICATE); } - public static boolean isWild(int analysis) { + public static boolean isWild(final int analysis) { return 0 != (analysis & BIT_NODETEST_ANY); } - public static boolean walksAttributes(int analysis) { + public static boolean walksAttributes(final int analysis) { return 0 != (analysis & BIT_ATTRIBUTE); } - public static boolean walksNamespaces(int analysis) { + public static boolean walksNamespaces(final int analysis) { return 0 != (analysis & BIT_NAMESPACE); } - public static boolean walksChildren(int analysis) { + public static boolean walksChildren(final int analysis) { return 0 != (analysis & BIT_CHILD); } - public static boolean walksDescendants(int analysis) { + public static boolean walksDescendants(final int analysis) { return isSet(analysis, BIT_DESCENDANT | BIT_DESCENDANT_OR_SELF); } - public static boolean walksSubtree(int analysis) { + public static boolean walksSubtree(final int analysis) { return isSet(analysis, BIT_DESCENDANT | BIT_DESCENDANT_OR_SELF | BIT_CHILD); } - public static boolean walksSubtreeOnlyMaybeAbsolute(int analysis) { + public static boolean walksSubtreeOnlyMaybeAbsolute(final int analysis) { return walksSubtree(analysis) && !walksExtraNodes(analysis) && !walksUp(analysis) && !walksSideways(analysis); } - public static boolean walksFilteredList(int analysis) { + public static boolean walksFilteredList(final int analysis) { return isSet(analysis, BIT_FILTER); } - public static boolean walksInDocOrder(int analysis) { + public static boolean walksInDocOrder(final int analysis) { return (walksSubtreeOnlyMaybeAbsolute(analysis) || walksExtraNodesOnly(analysis) || walksFollowingOnlyMaybeAbsolute(analysis)) && !isSet(analysis, BIT_FILTER); } - public static boolean walksFollowingOnlyMaybeAbsolute(int analysis) { + public static boolean walksFollowingOnlyMaybeAbsolute(final int analysis) { return isSet(analysis, BIT_SELF | BIT_FOLLOWING_SIBLING | BIT_FOLLOWING) && !walksSubtree(analysis) && !walksUp(analysis) && !walksSideways(analysis); } - public static boolean walksUp(int analysis) { + public static boolean walksUp(final int analysis) { return isSet(analysis, BIT_PARENT | BIT_ANCESTOR | BIT_ANCESTOR_OR_SELF); } - public static boolean walksSideways(int analysis) { + public static boolean walksSideways(final int analysis) { return isSet( analysis, BIT_FOLLOWING | BIT_FOLLOWING_SIBLING | BIT_PRECEDING | BIT_PRECEDING_SIBLING); } - public static boolean walksExtraNodes(int analysis) { + public static boolean walksExtraNodes(final int analysis) { return isSet(analysis, BIT_NAMESPACE | BIT_ATTRIBUTE); } - public static boolean walksExtraNodesOnly(int analysis) { + public static boolean walksExtraNodesOnly(final int analysis) { return walksExtraNodes(analysis) && !isSet(analysis, BIT_SELF) && !walksSubtree(analysis) @@ -1147,11 +1147,11 @@ public static boolean walksExtraNodesOnly(int analysis) { && !isAbsolute(analysis); } - public static boolean isAbsolute(int analysis) { + public static boolean isAbsolute(final int analysis) { return isSet(analysis, BIT_ROOT | BIT_FILTER); } - public static boolean walksChildrenOnly(int analysis) { + public static boolean walksChildrenOnly(final int analysis) { return walksChildren(analysis) && !isSet(analysis, BIT_SELF) && !walksExtraNodes(analysis) @@ -1161,7 +1161,7 @@ public static boolean walksChildrenOnly(int analysis) { && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT)); } - public static boolean walksChildrenAndExtraAndSelfOnly(int analysis) { + public static boolean walksChildrenAndExtraAndSelfOnly(final int analysis) { return walksChildren(analysis) && !walksDescendants(analysis) && !walksUp(analysis) @@ -1169,7 +1169,7 @@ public static boolean walksChildrenAndExtraAndSelfOnly(int analysis) { && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT)); } - public static boolean walksDescendantsAndExtraAndSelfOnly(int analysis) { + public static boolean walksDescendantsAndExtraAndSelfOnly(final int analysis) { return !walksChildren(analysis) && walksDescendants(analysis) && !walksUp(analysis) @@ -1177,7 +1177,7 @@ && walksDescendants(analysis) && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT)); } - public static boolean walksSelfOnly(int analysis) { + public static boolean walksSelfOnly(final int analysis) { return isSet(analysis, BIT_SELF) && !walksSubtree(analysis) && !walksUp(analysis) @@ -1185,25 +1185,25 @@ public static boolean walksSelfOnly(int analysis) { && !isAbsolute(analysis); } - public static boolean walksUpOnly(int analysis) { + public static boolean walksUpOnly(final int analysis) { return !walksSubtree(analysis) && walksUp(analysis) && !walksSideways(analysis) && !isAbsolute(analysis); } - public static boolean walksDownOnly(int analysis) { + public static boolean walksDownOnly(final int analysis) { return walksSubtree(analysis) && !walksUp(analysis) && !walksSideways(analysis) && !isAbsolute(analysis); } - public static boolean canSkipSubtrees(int analysis) { + public static boolean canSkipSubtrees(final int analysis) { return isSet(analysis, BIT_CHILD) | walksSideways(analysis); } - public static boolean canCrissCross(int analysis) { + public static boolean canCrissCross(final int analysis) { // This could be done faster. Coded for clarity. if (walksSelfOnly(analysis)) return false; else if (walksDownOnly(analysis) && !canSkipSubtrees(analysis)) return false; @@ -1226,7 +1226,7 @@ else if (walksSubtree(analysis) * @param analysis The general analysis of the pattern. * @return true if the walk can be done in natural order. */ - private static boolean isNaturalDocOrder(Compiler compiler, int stepOpCodePos, int analysis) { + private static boolean isNaturalDocOrder(final Compiler compiler, int stepOpCodePos, final int analysis) { if (canCrissCross(analysis)) return false; // Namespaces can present some problems, so just punt if we're looking for @@ -1267,7 +1267,7 @@ private static boolean isNaturalDocOrder(Compiler compiler, int stepOpCodePos, i // This doesn't seem to work as a test for wild card. Hmph. // int nodeTestType = compiler.getStepTestType(stepOpCodePos); - String localName = compiler.getStepLocalName(stepOpCodePos); + final String localName = compiler.getStepLocalName(stepOpCodePos); // System.err.println("localName: "+localName); if (localName.equals("*")) { foundWildAttribute = true; @@ -1302,7 +1302,7 @@ private static boolean isNaturalDocOrder(Compiler compiler, int stepOpCodePos, i new Object[] {Integer.toString(stepType)})); } - int nextStepOpCodePos = compiler.getNextStepPos(stepOpCodePos); + final int nextStepOpCodePos = compiler.getNextStepPos(stepOpCodePos); if (nextStepOpCodePos < 0) break; @@ -1312,11 +1312,11 @@ private static boolean isNaturalDocOrder(Compiler compiler, int stepOpCodePos, i return true; } - public static boolean isOneStep(int analysis) { + public static boolean isOneStep(final int analysis) { return (analysis & BITS_COUNT) == 0x00000001; } - public static int getStepCount(int analysis) { + public static int getStepCount(final int analysis) { return analysis & BITS_COUNT; } diff --git a/src/main/java/org/htmlunit/xpath/xml/dtm/ref/dom2dtm/DOM2DTM.java b/src/main/java/org/htmlunit/xpath/xml/dtm/ref/dom2dtm/DOM2DTM.java index f8ad92e..2e99b3d 100644 --- a/src/main/java/org/htmlunit/xpath/xml/dtm/ref/dom2dtm/DOM2DTM.java +++ b/src/main/java/org/htmlunit/xpath/xml/dtm/ref/dom2dtm/DOM2DTM.java @@ -45,7 +45,6 @@ */ public class DOM2DTM extends DTMDefaultBaseIterators { static final boolean JJK_DEBUG = false; - static final boolean JJK_NEWCODE = true; /** Manefest constant */ static final String NAMESPACE_DECL_NS = "http://www.w3.org/XML/1998/namespace"; @@ -88,7 +87,7 @@ public class DOM2DTM extends DTMDefaultBaseIterators { * @param dtmIdentity The DTM identity ID for this DTM. * @param doIndexing true if the caller considers it worth it to use indexing schemes. */ - public DOM2DTM(DTMManager mgr, DOMSource domSource, int dtmIdentity, boolean doIndexing) { + public DOM2DTM(final DTMManager mgr, final DOMSource domSource, final int dtmIdentity, final boolean doIndexing) { super(mgr, domSource, dtmIdentity, doIndexing); // Initialize DOM navigation @@ -109,8 +108,8 @@ public DOM2DTM(DTMManager mgr, DOMSource domSource, int dtmIdentity, boolean doI // %ISSUE% What about inherited namespaces in this case? // Do we need to special-case initialize them into the DTM model? if (ELEMENT_NODE == m_root.getNodeType()) { - NamedNodeMap attrs = m_root.getAttributes(); - int attrsize = (attrs == null) ? 0 : attrs.getLength(); + final NamedNodeMap attrs = m_root.getAttributes(); + final int attrsize = (attrs == null) ? 0 : attrs.getLength(); if (attrsize > 0) { int attrIndex = NULL; // start with no previous sib for (int i = 0; i < attrsize; ++i) { @@ -143,8 +142,8 @@ public DOM2DTM(DTMManager mgr, DOMSource domSource, int dtmIdentity, boolean doI * DTM behavior). * @return The index identity of the node that was added. */ - protected int addNode(Node node, int parentIndex, int previousSibling, int forceNodeType) { - int nodeIndex = m_nodes.size(); + protected int addNode(final Node node, final int parentIndex, final int previousSibling, final int forceNodeType) { + final int nodeIndex = m_nodes.size(); // Have we overflowed a DTM Identity's addressing range? if (m_dtmIdent.size() == (nodeIndex >>> DTMManager.IDENT_DTM_NODE_BITS)) { @@ -152,11 +151,11 @@ protected int addNode(Node node, int parentIndex, int previousSibling, int force if (m_mgr == null) throw new ClassCastException(); // Handle as Extended Addressing - DTMManagerDefault mgrD = (DTMManagerDefault) m_mgr; - int id = mgrD.getFirstFreeDTMID(); + final DTMManagerDefault mgrD = (DTMManagerDefault) m_mgr; + final int id = mgrD.getFirstFreeDTMID(); mgrD.addDTM(this, id, nodeIndex); m_dtmIdent.addElement(id << DTMManager.IDENT_DTM_NODE_BITS); - } catch (ClassCastException e) { + } catch (final ClassCastException e) { // %REVIEW% Wrong error message, but I've been told we're trying // not to add messages right not for I18N reasons. // %REVIEW% Should this be a Fatal Error? @@ -190,7 +189,7 @@ protected int addNode(Node node, int parentIndex, int previousSibling, int force // synthesize additional DTM Namespace Nodes that don't correspond // to DOM Attr Nodes. if (Node.ATTRIBUTE_NODE == type) { - String name = node.getNodeName(); + final String name = node.getNodeName(); if (name.startsWith("xmlns:") || name.equals("xmlns")) { type = DTM.NAMESPACE_NODE; @@ -210,7 +209,7 @@ protected int addNode(Node node, int parentIndex, int previousSibling, int force m_firstch.setElementAt(nodeIndex, parentIndex); } - String nsURI = node.getNamespaceURI(); + final String nsURI = node.getNamespaceURI(); // Deal with the difference between Namespace spec and XSLT // definitions of local name. (The former says PIs don't have @@ -222,7 +221,7 @@ protected int addNode(Node node, int parentIndex, int previousSibling, int force if (((type == Node.ELEMENT_NODE) || (type == Node.ATTRIBUTE_NODE)) && null == localName) localName = node.getNodeName(); // -sb - ExpandedNameTable exnt = m_expandedNameTable; + final ExpandedNameTable exnt = m_expandedNameTable; // %TBD% Nodes created with the old non-namespace-aware DOM // calls createElement() and createAttribute() will never have a @@ -238,7 +237,7 @@ protected int addNode(Node node, int parentIndex, int previousSibling, int force // DOM2DTM."); } - int expandedNameID = + final int expandedNameID = (null != localName) ? exnt.getExpandedTypeID(nsURI, localName, type) : type; m_exptype.setElementAt(expandedNameID, nodeIndex); @@ -410,7 +409,7 @@ else if (PROCESSING_INSTRUCTION_NODE == nexttype) { // Inserting next. NOTE that we force the node type; for // coalesced Text, this records CDATASections adjacent to // ordinary Text as Text. - int nextindex = addNode(next, m_last_parent, m_last_kid, nexttype); + final int nextindex = addNode(next, m_last_parent, m_last_kid, nexttype); m_last_kid = nextindex; @@ -418,8 +417,8 @@ else if (PROCESSING_INSTRUCTION_NODE == nexttype) { int attrIndex = NULL; // start with no previous sib // Process attributes _now_, rather than waiting. // Simpler control flow, makes NS cache available immediately. - NamedNodeMap attrs = next.getAttributes(); - int attrsize = (attrs == null) ? 0 : attrs.getLength(); + final NamedNodeMap attrs = next.getAttributes(); + final int attrsize = (attrs == null) ? 0 : attrs.getLength(); if (attrsize > 0) { for (int i = 0; i < attrsize; ++i) { // No need to force nodetype in this case; @@ -478,9 +477,9 @@ else if (PROCESSING_INSTRUCTION_NODE == nexttype) { /** {@inheritDoc} */ @Override - public Node getNode(int nodeHandle) { + public Node getNode(final int nodeHandle) { - int identity = makeNodeIdentity(nodeHandle); + final int identity = makeNodeIdentity(nodeHandle); return m_nodes.elementAt(identity); } @@ -492,7 +491,7 @@ public Node getNode(int nodeHandle) { * *

NEEDSDOC ($objectName$) @return */ - protected Node lookupNode(int nodeIdentity) { + protected Node lookupNode(final int nodeIdentity) { return m_nodes.elementAt(nodeIdentity); } @@ -525,7 +524,7 @@ protected int getNextNodeIdentity(int identity) { * @param node A node, which may be null. * @return The node handle or DTM.NULL. */ - private int getHandleFromNode(Node node) { + private int getHandleFromNode(final Node node) { if (null != node) { int len = m_nodes.size(); boolean isMore; @@ -557,7 +556,7 @@ private int getHandleFromNode(Node node) { * @param node A node, which may be null. * @return The node handle or DTM.NULL. */ - public int getHandleOfNode(Node node) { + public int getHandleOfNode(final Node node) { if (null != node) { // Is Node actually within the same document? If not, don't search! // This would be easier if m_root was always the Document node, but @@ -589,7 +588,7 @@ public int getHandleOfNode(Node node) { /** {@inheritDoc} */ @Override - public int getAttributeNode(int nodeHandle, String namespaceURI, String name) { + public int getAttributeNode(final int nodeHandle, String namespaceURI, final String name) { // %OPT% This is probably slower than it needs to be. if (null == namespaceURI) namespaceURI = ""; @@ -613,12 +612,12 @@ public int getAttributeNode(int nodeHandle, String namespaceURI, String name) { // of both -- retrieve the node, then test if the type matches // what you're looking for.) if (type == DTM.ATTRIBUTE_NODE || type == DTM.NAMESPACE_NODE) { - Node node = lookupNode(identity); + final Node node = lookupNode(identity); String nodeuri = node.getNamespaceURI(); if (null == nodeuri) nodeuri = ""; - String nodelocalname = node.getLocalName(); + final String nodelocalname = node.getLocalName(); if (nodeuri.equals(namespaceURI) && name.equals(nodelocalname)) return makeNodeHandle(identity); @@ -634,18 +633,18 @@ public int getAttributeNode(int nodeHandle, String namespaceURI, String name) { /** {@inheritDoc} */ @Override - public XString getStringValue(int nodeHandle) { + public XString getStringValue(final int nodeHandle) { - int type = getNodeType(nodeHandle); + final int type = getNodeType(nodeHandle); Node node = getNode(nodeHandle); // %TBD% If an element only has one text node, we should just use it // directly. if (DTM.ELEMENT_NODE == type || DTM.DOCUMENT_NODE == type || DTM.DOCUMENT_FRAGMENT_NODE == type) { - StringBuilder buf = new StringBuilder(); + final StringBuilder buf = new StringBuilder(); getNodeData(node, buf); - String s = (buf.length() > 0) ? buf.toString() : ""; + final String s = (buf.length() > 0) ? buf.toString() : ""; return new XString(s); } else if (TEXT_NODE == type || CDATA_SECTION_NODE == type) { @@ -656,12 +655,12 @@ public XString getStringValue(int nodeHandle) { // // %REVIEW% DOM Level 3 is expected to add a "whole text" // retrieval method which performs this function for us. - StringBuilder buf = new StringBuilder(); + final StringBuilder buf = new StringBuilder(); while (node != null) { buf.append(node.getNodeValue()); node = logicalNextDOMTextNode(node); } - String s = (buf.length() > 0) ? buf.toString() : ""; + final String s = (buf.length() > 0) ? buf.toString() : ""; return new XString(s); } else return new XString(node.getNodeValue()); } @@ -681,9 +680,9 @@ public XString getStringValue(int nodeHandle) { * * @param node Node whose subtree is to be walked, gathering the contents of all Text or * CDATASection nodes. - * @param buf FastStringBuffer into which the contents of the text nodes are to be concatenated. + * @param buf StringBuilder into which the contents of the text nodes are to be concatenated. */ - protected static void getNodeData(Node node, StringBuilder buf) { + protected static void getNodeData(final Node node, final StringBuilder buf) { switch (node.getNodeType()) { case Node.DOCUMENT_FRAGMENT_NODE: @@ -711,9 +710,9 @@ protected static void getNodeData(Node node, StringBuilder buf) { /** {@inheritDoc} */ @Override - public String getNodeName(int nodeHandle) { + public String getNodeName(final int nodeHandle) { - Node node = getNode(nodeHandle); + final Node node = getNode(nodeHandle); // Assume non-null. return node.getNodeName(); @@ -721,15 +720,15 @@ public String getNodeName(int nodeHandle) { /** {@inheritDoc} */ @Override - public String getNodeNameX(int nodeHandle) { + public String getNodeNameX(final int nodeHandle) { String name; - short type = getNodeType(nodeHandle); + final short type = getNodeType(nodeHandle); switch (type) { case DTM.NAMESPACE_NODE: { - Node node = getNode(nodeHandle); + final Node node = getNode(nodeHandle); // assume not null. name = node.getNodeName(); @@ -745,7 +744,7 @@ public String getNodeNameX(int nodeHandle) { case DTM.ENTITY_REFERENCE_NODE: case DTM.PROCESSING_INSTRUCTION_NODE: { - Node node = getNode(nodeHandle); + final Node node = getNode(nodeHandle); // assume not null. name = node.getNodeName(); @@ -764,79 +763,50 @@ public String getNodeNameX(int nodeHandle) { * @param qname Input name * @return Local part of the name if prefixed, or the given name if not */ - private static String getLocalPart(String qname) { + private static String getLocalPart(final String qname) { - int index = qname.indexOf(':'); + final int index = qname.indexOf(':'); return (index < 0) ? qname : qname.substring(index + 1); } /** {@inheritDoc} */ @Override - public String getLocalName(int nodeHandle) { - if (JJK_NEWCODE) { - int id = makeNodeIdentity(nodeHandle); - if (NULL == id) return null; - Node newnode = m_nodes.elementAt(id); - String newname = newnode.getLocalName(); - if (null == newname) { - // XSLT treats PIs, and possibly other things, as having QNames. - String qname = newnode.getNodeName(); - if ('#' == qname.charAt(0)) { - // Match old default for this function - // This conversion may or may not be necessary - newname = ""; - } else { - int index = qname.indexOf(':'); - newname = (index < 0) ? qname : qname.substring(index + 1); - } + public String getLocalName(final int nodeHandle) { + final int id = makeNodeIdentity(nodeHandle); + if (NULL == id) return null; + final Node newnode = m_nodes.elementAt(id); + String newname = newnode.getLocalName(); + if (null == newname) { + // XSLT treats PIs, and possibly other things, as having QNames. + final String qname = newnode.getNodeName(); + if ('#' == qname.charAt(0)) { + // Match old default for this function + // This conversion may or may not be necessary + newname = ""; + } else { + final int index = qname.indexOf(':'); + newname = (index < 0) ? qname : qname.substring(index + 1); } - return newname; - } - - String name; - short type = getNodeType(nodeHandle); - switch (type) { - case DTM.ATTRIBUTE_NODE: - case DTM.ELEMENT_NODE: - case DTM.ENTITY_REFERENCE_NODE: - case DTM.NAMESPACE_NODE: - case DTM.PROCESSING_INSTRUCTION_NODE: - { - Node node = getNode(nodeHandle); - - // assume not null. - name = node.getLocalName(); - - if (null == name) { - String qname = node.getNodeName(); - int index = qname.indexOf(':'); - - name = (index < 0) ? qname : qname.substring(index + 1); - } - } - break; - default: - name = ""; } - return name; + return newname; } /** {@inheritDoc} */ @Override - public String getPrefix(int nodeHandle) { + public String getPrefix(final int nodeHandle) { - String prefix; - short type = getNodeType(nodeHandle); + final String prefix; + final short type = getNodeType(nodeHandle); switch (type) { case DTM.NAMESPACE_NODE: { - Node node = getNode(nodeHandle); + final Node node = getNode(nodeHandle); // assume not null. - String qname = node.getNodeName(); - int index = qname.indexOf(':'); + final String qname = node.getNodeName(); + final int index = qname.indexOf(':'); prefix = (index < 0) ? "" : qname.substring(index + 1); } @@ -844,11 +814,11 @@ public String getPrefix(int nodeHandle) { case DTM.ATTRIBUTE_NODE: case DTM.ELEMENT_NODE: { - Node node = getNode(nodeHandle); + final Node node = getNode(nodeHandle); // assume not null. - String qname = node.getNodeName(); - int index = qname.indexOf(':'); + final String qname = node.getNodeName(); + final int index = qname.indexOf(':'); prefix = (index < 0) ? "" : qname.substring(0, index); } @@ -862,37 +832,11 @@ public String getPrefix(int nodeHandle) { /** {@inheritDoc} */ @Override - public String getNamespaceURI(int nodeHandle) { - if (JJK_NEWCODE) { - int id = makeNodeIdentity(nodeHandle); - if (id == NULL) return null; - Node node = m_nodes.elementAt(id); - return node.getNamespaceURI(); - } - - String nsuri; - short type = getNodeType(nodeHandle); - - switch (type) { - case DTM.ATTRIBUTE_NODE: - case DTM.ELEMENT_NODE: - case DTM.ENTITY_REFERENCE_NODE: - case DTM.NAMESPACE_NODE: - case DTM.PROCESSING_INSTRUCTION_NODE: - { - Node node = getNode(nodeHandle); - - // assume not null. - nsuri = node.getNamespaceURI(); - - // %TBD% Handle DOM1? - } - break; - default: - nsuri = null; - } - - return nsuri; + public String getNamespaceURI(final int nodeHandle) { + final int id = makeNodeIdentity(nodeHandle); + if (id == NULL) return null; + final Node node = m_nodes.elementAt(id); + return node.getNamespaceURI(); } /** @@ -920,7 +864,7 @@ private Node logicalNextDOMTextNode(Node n) { } if (n != null) { // Found a logical next sibling. Is it text? - int ntype = n.getNodeType(); + final int ntype = n.getNodeType(); if (TEXT_NODE != ntype && CDATA_SECTION_NODE != ntype) n = null; } return n; @@ -928,7 +872,7 @@ private Node logicalNextDOMTextNode(Node n) { /** {@inheritDoc} */ @Override - public String getNodeValue(int nodeHandle) { + public String getNodeValue(final int nodeHandle) { // The _type(nodeHandle) call was taking the lion's share of our // time, and was wrong anyway since it wasn't coverting handle to // identity. Inlined it. @@ -944,11 +888,11 @@ public String getNodeValue(int nodeHandle) { // // %REVIEW% DOM Level 3 is expected to add a "whole text" // retrieval method which performs this function for us. - Node node = getNode(nodeHandle); + final Node node = getNode(nodeHandle); Node n = logicalNextDOMTextNode(node); if (n == null) return node.getNodeValue(); - StringBuilder buf = new StringBuilder(); + final StringBuilder buf = new StringBuilder(); buf.append(node.getNodeValue()); while (n != null) { buf.append(n.getNodeValue()); @@ -959,22 +903,22 @@ public String getNodeValue(int nodeHandle) { /** {@inheritDoc} */ @Override - public int getElementById(String elementId) { + public int getElementById(final String elementId) { - Document doc = + final Document doc = (m_root.getNodeType() == Node.DOCUMENT_NODE) ? (Document) m_root : m_root.getOwnerDocument(); if (null != doc) { - Node elem = doc.getElementById(elementId); + final Node elem = doc.getElementById(elementId); if (null != elem) { int elemHandle = getHandleFromNode(elem); if (DTM.NULL == elemHandle) { int identity = m_nodes.size() - 1; while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { - Node node = getNode(identity); + final Node node = getNode(identity); if (node == elem) { elemHandle = getHandleFromNode(elem); break; diff --git a/src/main/java/org/htmlunit/xpath/xml/dtm/ref/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java b/src/main/java/org/htmlunit/xpath/xml/dtm/ref/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java index 48a1b1e..2effd23 100644 --- a/src/main/java/org/htmlunit/xpath/xml/dtm/ref/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +++ b/src/main/java/org/htmlunit/xpath/xml/dtm/ref/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java @@ -50,7 +50,7 @@ public class DOM2DTMdefaultNamespaceDeclarationNode implements Attr, TypeInfo { final String uri; final String nodename; - DOM2DTMdefaultNamespaceDeclarationNode(Element pseudoparent, String prefix, String uri) { + DOM2DTMdefaultNamespaceDeclarationNode(final Element pseudoparent, final String prefix, final String uri) { this.pseudoparent = pseudoparent; this.prefix = prefix; this.uri = uri; @@ -107,7 +107,7 @@ public Element getOwnerElement() { /** {@inheritDoc} */ @Override - public boolean isSupported(String feature, String version) { + public boolean isSupported(final String feature, final String version) { return false; } @@ -183,43 +183,43 @@ public short getNodeType() { /** {@inheritDoc} */ @Override - public void setNodeValue(String value) { + public void setNodeValue(final String value) { throw new RuntimeException(NOT_SUPPORTED_ERR); } /** {@inheritDoc} */ @Override - public void setValue(String value) { + public void setValue(final String value) { throw new RuntimeException(NOT_SUPPORTED_ERR); } /** {@inheritDoc} */ @Override - public void setPrefix(String value) { + public void setPrefix(final String value) { throw new RuntimeException(NOT_SUPPORTED_ERR); } /** {@inheritDoc} */ @Override - public Node insertBefore(Node a, Node b) { + public Node insertBefore(final Node a, final Node b) { throw new RuntimeException(NOT_SUPPORTED_ERR); } /** {@inheritDoc} */ @Override - public Node replaceChild(Node a, Node b) { + public Node replaceChild(final Node a, final Node b) { throw new RuntimeException(NOT_SUPPORTED_ERR); } /** {@inheritDoc} */ @Override - public Node appendChild(Node a) { + public Node appendChild(final Node a) { throw new RuntimeException(NOT_SUPPORTED_ERR); } /** {@inheritDoc} */ @Override - public Node removeChild(Node a) { + public Node removeChild(final Node a) { throw new RuntimeException(NOT_SUPPORTED_ERR); } @@ -231,7 +231,7 @@ public Document getOwnerDocument() { /** {@inheritDoc} */ @Override - public Node cloneNode(boolean deep) { + public Node cloneNode(final boolean deep) { throw new RuntimeException(NOT_SUPPORTED_ERR); } @@ -249,7 +249,7 @@ public String getTypeNamespace() { /** {@inheritDoc} */ @Override - public boolean isDerivedFrom(String ns, String localName, int derivationMethod) { + public boolean isDerivedFrom(final String ns, final String localName, final int derivationMethod) { return false; } @@ -267,19 +267,19 @@ public boolean isId() { /** {@inheritDoc} */ @Override - public Object setUserData(String key, Object data, UserDataHandler handler) { + public Object setUserData(final String key, final Object data, final UserDataHandler handler) { return getOwnerDocument().setUserData(key, data, handler); } /** {@inheritDoc} */ @Override - public Object getUserData(String key) { + public Object getUserData(final String key) { return getOwnerDocument().getUserData(key); } /** {@inheritDoc} */ @Override - public Object getFeature(String feature, String version) { + public Object getFeature(final String feature, final String version) { // we don't have any alternate node, either this node does the job // or we don't have anything that does return isSupported(feature, version) ? this : null; @@ -287,7 +287,7 @@ public Object getFeature(String feature, String version) { /** {@inheritDoc} */ @Override - public boolean isEqualNode(Node arg) { + public boolean isEqualNode(final Node arg) { if (arg == this) { return true; } @@ -340,13 +340,13 @@ public boolean isEqualNode(Node arg) { /** {@inheritDoc} */ @Override - public String lookupNamespaceURI(String specifiedPrefix) { - short type = this.getNodeType(); + public String lookupNamespaceURI(final String specifiedPrefix) { + final short type = this.getNodeType(); switch (type) { case Node.ELEMENT_NODE: { String namespace = this.getNamespaceURI(); - String pfx = this.getPrefix(); + final String pfx = this.getPrefix(); if (namespace != null) { // REVISIT: is it possible that prefix is empty string? if (specifiedPrefix == null && pfx == specifiedPrefix) { @@ -358,12 +358,12 @@ public String lookupNamespaceURI(String specifiedPrefix) { } } if (this.hasAttributes()) { - NamedNodeMap map = this.getAttributes(); - int length = map.getLength(); + final NamedNodeMap map = this.getAttributes(); + final int length = map.getLength(); for (int i = 0; i < length; i++) { - Node attr = map.item(i); - String attrPrefix = attr.getPrefix(); - String value = attr.getNodeValue(); + final Node attr = map.item(i); + final String attrPrefix = attr.getPrefix(); + final String value = attr.getNodeValue(); namespace = attr.getNamespaceURI(); if (namespace != null && namespace.equals("http://www.w3.org/2000/xmlns/")) { // at this point we are dealing with DOM Level 2 nodes only @@ -403,13 +403,13 @@ public String lookupNamespaceURI(String specifiedPrefix) { /** {@inheritDoc} */ @Override - public boolean isDefaultNamespace(String namespaceURI) { + public boolean isDefaultNamespace(final String namespaceURI) { return false; } /** {@inheritDoc} */ @Override - public String lookupPrefix(String namespaceURI) { + public String lookupPrefix(final String namespaceURI) { // REVISIT: When Namespaces 1.1 comes out this may not be true // Prefix can't be bound to null namespace @@ -417,7 +417,7 @@ public String lookupPrefix(String namespaceURI) { return null; } - short type = this.getNodeType(); + final short type = this.getNodeType(); switch (type) { case Node.ENTITY_NODE: @@ -442,14 +442,14 @@ public String lookupPrefix(String namespaceURI) { /** {@inheritDoc} */ @Override - public boolean isSameNode(Node other) { + public boolean isSameNode(final Node other) { // we do not use any wrapper so the answer is obvious return this == other; } /** {@inheritDoc} */ @Override - public void setTextContent(String textContent) throws DOMException { + public void setTextContent(final String textContent) throws DOMException { setNodeValue(textContent); } @@ -461,7 +461,7 @@ public String getTextContent() throws DOMException { /** {@inheritDoc} */ @Override - public short compareDocumentPosition(Node other) throws DOMException { + public short compareDocumentPosition(final Node other) throws DOMException { return 0; }