public ItemType getOperandItemType() { if (operandItemType == null) { operandItemType = getBaseExpression().getItemType(); } return operandItemType; }
/** * The toString() method for an expression attempts to give a representation of the expression * in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath. * In the case of XSLT instructions, the toString() method gives an abstracted view of the syntax */ @Override public String toString() { return "data(" + getBaseExpression().toString() + ")"; }
public ItemType getOperandItemType() { if (operandItemType == null) { operandItemType = getBaseExpression().getItemType(); } return operandItemType; }
/** * The toString() method for an expression attempts to give a representation of the expression * in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath. * In the case of XSLT instructions, the toString() method gives an abstracted view of the syntax */ @Override public String toString() { return "data(" + getBaseExpression().toString() + ")"; }
@Override public String toShortString() { return getBaseExpression().toShortString(); }
public AbstractExpression exprFor (Atomizer atomizer) { Expression base = atomizer.getBaseExpression(); return exprFor (base); //return new FunCall (FunCall.FN_DATA, ValueType.ATOMIC, exprFor (base)); }
@Override public String toShortString() { return getBaseExpression().toShortString(); }
/** * Determine the data type of the items returned by the expression, if possible * * @return a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER. For this class, the * result is always an atomic type, but it might be more specific. */ /*@NotNull*/ public ItemType getItemType() { operandItemType = getBaseExpression().getItemType(); TypeHierarchy th = getConfiguration().getTypeHierarchy(); return getAtomizedItemType(getBaseExpression(), untyped, th); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new Atomizer(getBaseExpression().copy(), config); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new Atomizer(getBaseExpression().copy(), config); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new Atomizer(getBaseExpression().copy(), config); }
/** * Iterate over the sequence of values */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { SequenceIterator base = getBaseExpression().iterate(context); return getAtomizingIterator(base, untyped && operandItemType instanceof NodeTest); }
/** * Determine the data type of the items returned by the expression, if possible * * @return a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER. For this class, the * result is always an atomic type, but it might be more specific. */ /*@NotNull*/ public ItemType getItemType() { operandItemType = getBaseExpression().getItemType(); TypeHierarchy th = getConfiguration().getTypeHierarchy(); return getAtomizedItemType(getBaseExpression(), untyped, th); }
/** * Evaluate as an Item. This should only be called if the Atomizer has cardinality zero-or-one, * which will only be the case if the underlying expression has cardinality zero-or-one. */ public AtomicValue evaluateItem(XPathContext context) throws XPathException { Item i = getBaseExpression().evaluateItem(context); if (i == null) { return null; } else { return i.atomize().head(); } }
/** * Evaluate as an Item. This should only be called if the Atomizer has cardinality zero-or-one, * which will only be the case if the underlying expression has cardinality zero-or-one. */ public AtomicValue evaluateItem(XPathContext context) throws XPathException { Item i = getBaseExpression().evaluateItem(context); if (i == null) { return null; } else { return i.atomize().head(); } }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { Atomizer copy = new Atomizer(getBaseExpression().copy(rebindings), roleDiagnostic); copy.untyped = untyped; copy.singleValued = singleValued; ExpressionTool.copyLocationInfo(this, copy); return copy; }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { Atomizer copy = new Atomizer(getBaseExpression().copy(rebindings)); copy.untyped = untyped; copy.singleValued = singleValued; ExpressionTool.copyLocationInfo(this, copy); return copy; }
/** * Factory method to construct a CardinalityChecker. The method may create an expression that combines * the cardinality checking with the functionality of the underlying expression class * @param sequence the base sequence whose cardinality is to be checked * @param cardinality the required cardinality * @param role information to be used in error reporting * @return a new Expression that does the CardinalityChecking (not necessarily a CardinalityChecker) */ public static Expression makeCardinalityChecker(Expression sequence, int cardinality, RoleLocator role) { Expression result; if (sequence instanceof Atomizer && !Cardinality.allowsMany(cardinality)) { Expression base = ((Atomizer)sequence).getBaseExpression(); result = new SingletonAtomizer(base, role, Cardinality.allowsZero(cardinality)); } else { result = new CardinalityChecker(sequence, cardinality, role); } ExpressionTool.copyLocationInfo(sequence, result); return result; }
/** * Iterate over the sequence of values */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { try { SequenceIterator base = getBaseExpression().iterate(context); return getAtomizingIterator(base, untyped && operandItemType instanceof NodeTest); } catch (XPathException e) { if (roleDiagnostic == null) { throw e; } else { String message = e.getMessage() + ". Failed while atomizing the " + roleDiagnostic.getMessage(); XPathException e2 = new XPathException(message, e.getErrorCodeLocalPart(), e.getLocator()); e2.setXPathContext(context); e2.maybeSetLocation(getLocation()); throw e2; } } }
private void computeSingleValued(TypeHierarchy th) { ItemType operandType = getOperandItemType(); if (th.relationship(operandType, ArrayItemType.ANY_ARRAY_TYPE) != TypeHierarchy.DISJOINT) { singleValued = false; } else { singleValued = untyped; if (!singleValued) { ItemType nodeType = getBaseExpression().getItemType(); if (nodeType instanceof NodeTest) { SchemaType st = ((NodeTest) nodeType).getContentType(); if (st == Untyped.getInstance() || st.isAtomicType() || (st.isComplexType() && st != AnyType.getInstance())) { singleValued = true; } if (!nodeType.getUType().overlaps(UType.ELEMENT.union(UType.ATTRIBUTE))) { singleValued = true; } } } } }