/** * Get the subscript expression * * @return the expression used to compute the one-based start offset */ public Expression getSubscriptExpression() { return getSubscript(); }
/** * Get the subscript expression * * @return the expression used to compute the one-based start offset */ public Expression getSubscriptExpression() { return getSubscript(); }
/** * Compare two expressions to see if they are equal * * @param other the other expression * @return true if the expressions are equivalent */ public boolean equals(Object other) { return other instanceof SubscriptExpression && getBaseExpression().isEqual(((SubscriptExpression) other).getBaseExpression()) && getSubscript().isEqual(((SubscriptExpression) other).getSubscript()); }
/** * <p>The toString() method for an expression attempts to give a representation of the expression * in an XPath-like form.</p> * <p>For subclasses of Expression that represent XPath expressions, the result should always be a string that * parses as an XPath 3.0 expression.</p> * * @return a representation of the expression as a string */ @Override public String toString() { return ExpressionTool.parenthesize(getBaseExpression()) + "[" + getSubscript() + "]"; }
/** * Compare two expressions to see if they are equal * * @param other the other expression * @return true if the expressions are equivalent */ public boolean equals(Object other) { return other instanceof SubscriptExpression && getBaseExpression().isEqual(((SubscriptExpression) other).getBaseExpression()) && getSubscript().isEqual(((SubscriptExpression) other).getSubscript()); }
/** * <p>The toString() method for an expression attempts to give a representation of the expression * in an XPath-like form.</p> * <p>For subclasses of Expression that represent XPath expressions, the result should always be a string that * parses as an XPath 3.0 expression.</p> * * @return a representation of the expression as a string */ @Override public String toString() { return ExpressionTool.parenthesize(getBaseExpression()) + "[" + getSubscript() + "]"; }
/** * <p>The toString() method for an expression attempts to give a representation of the expression * in an XPath-like form.</p> * <p>For subclasses of Expression that represent XPath expressions, the result should always be a string that * parses as an XPath 3.0 expression.</p> * * @return a representation of the expression as a string */ @Override public String toShortString() { return ExpressionTool.parenthesize(getBaseExpression()) + "[" + getSubscript().toShortString() + "]"; }
public int computeHashCode() { return getBaseExpression().hashCode() ^ getSubscript().hashCode(); }
/** * <p>The toString() method for an expression attempts to give a representation of the expression * in an XPath-like form.</p> * <p>For subclasses of Expression that represent XPath expressions, the result should always be a string that * parses as an XPath 3.0 expression.</p> * * @return a representation of the expression as a string */ @Override public String toShortString() { return ExpressionTool.parenthesize(getBaseExpression()) + "[" + getSubscript().toShortString() + "]"; }
public int computeHashCode() { return getBaseExpression().hashCode() ^ getSubscript().hashCode(); }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void export(ExpressionPresenter destination) throws XPathException { destination.startElement("subscript", this); getBaseExpression().export(destination); getSubscript().export(destination); destination.endElement(); }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (Literal.isConstantOne(getSubscript())) { return FirstItemExpression.makeFirstItemExpression(getBaseExpression()); } return this; }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings variables that need to be re-bound */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { SubscriptExpression exp = new SubscriptExpression(getBaseExpression().copy(rebindings), getSubscript().copy(rebindings)); ExpressionTool.copyLocationInfo(this, exp); return exp; }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void export(ExpressionPresenter destination) throws XPathException { destination.startElement("subscript", this); getBaseExpression().export(destination); getSubscript().export(destination); destination.endElement(); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings variables that need to be re-bound */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { SubscriptExpression exp = new SubscriptExpression(getBaseExpression().copy(rebindings), getSubscript().copy(rebindings)); ExpressionTool.copyLocationInfo(this, exp); return exp; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (Literal.isConstantOne(getSubscript())) { return FirstItemExpression.makeFirstItemExpression(getBaseExpression()); } return this; }
public Item evaluateItem(XPathContext context) throws XPathException { NumericValue index = (NumericValue) getSubscript().evaluateItem(context); if (index == null) { return null; } int intindex = index.asSubscript(); if (intindex != -1) { Item item; SequenceIterator<?> iter = getBaseExpression().iterate(context); if (intindex == 1) { item = iter.next(); } else if (iter instanceof MemoSequence.ProgressiveIterator) { MemoSequence mem = ((MemoSequence.ProgressiveIterator)iter).getMemoSequence(); item = mem.itemAt(intindex - 1); } else if ((iter.getProperties() & SequenceIterator.GROUNDED) != 0) { GroundedValue value = iter.materialize(); item = value.itemAt(intindex - 1); } else { SequenceIterator tail = TailIterator.make(iter, intindex); item = tail.next(); tail.close(); } return item; } else { // there is no item at the required position return null; } }
public Item evaluateItem(XPathContext context) throws XPathException { NumericValue index = (NumericValue) getSubscript().evaluateItem(context); if (index == null) { return null; } int intindex = index.asSubscript(); if (intindex != -1) { Item item; SequenceIterator<?> iter = getBaseExpression().iterate(context); if (intindex == 1) { item = iter.next(); } else if (iter instanceof MemoSequence.ProgressiveIterator) { MemoSequence mem = ((MemoSequence.ProgressiveIterator)iter).getMemoSequence(); item = mem.itemAt(intindex - 1); } else if ((iter.getProperties() & SequenceIterator.GROUNDED) != 0) { GroundedValue value = iter.materialize(); item = value.itemAt(intindex - 1); } else { SequenceIterator tail = TailIterator.make(iter, intindex); item = tail.next(); tail.close(); } return item; } else { // there is no item at the required position return null; } }