/** * Evaluate the expression as a boolean */ public boolean effectiveBooleanValue(XPathContext context) throws XPathException { SequenceIterator iter = getBaseExpression().iterate(context); return isInstance(iter, context); }
/** * Evaluate the expression as a boolean */ public boolean effectiveBooleanValue(XPathContext context) throws XPathException { SequenceIterator iter = getBaseExpression().iterate(context); return isInstance(iter, context); }
/** * Get the data type of the items returned * * @param th the type hierarchy cache * @return an integer representing the data type */ public ItemType getItemType(TypeHierarchy th) { // special case the filter [. instance of x] if (filter instanceof InstanceOfExpression && ((InstanceOfExpression)filter).getBaseExpression() instanceof ContextItemExpression) { return ((InstanceOfExpression)filter).getRequiredItemType(); } return start.getItemType(th); }
/** * Get the data type of the items returned * * @param th the type hierarchy cache * @return an integer representing the data type */ public ItemType getItemType(TypeHierarchy th) { // special case the filter [. instance of x] if (filter instanceof InstanceOfExpression && ((InstanceOfExpression)filter).getBaseExpression() instanceof ContextItemExpression) { return ((InstanceOfExpression)filter).getRequiredItemType(); } return start.getItemType(th); }
/** * Get the data type of the items returned * * @param th the type hierarchy cache * @return an integer representing the data type */ public ItemType getItemType(TypeHierarchy th) { // special case the filter [. instance of x] if (filter instanceof InstanceOfExpression && ((InstanceOfExpression)filter).getBaseExpression() instanceof ContextItemExpression) { return ((InstanceOfExpression)filter).getRequiredItemType(); } return start.getItemType(th); }
/** * 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() { String occ = Cardinality.getOccurrenceIndicator(targetCardinality); return "(" + getBaseExpression().toString() + " instance of " + targetType.toString() + occ + ")"; }
/** * Produce a short string identifying the expression for use in error messages * * @return a short string, sufficient to identify the expression */ @Override public String toShortString() { String occ = Cardinality.getOccurrenceIndicator(targetCardinality); return getBaseExpression().toShortString() + " instance of " + targetType.toString() + occ; }
/** * Produce a short string identifying the expression for use in error messages * * @return a short string, sufficient to identify the expression */ @Override public String toShortString() { String occ = Cardinality.getOccurrenceIndicator(targetCardinality); return getBaseExpression().toShortString() + " instance of " + targetType.toString() + occ; }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new InstanceOfExpression(getBaseExpression().copy(), SequenceType.makeSequenceType(targetType, targetCardinality)); }
/** * 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() { String occ = Cardinality.getOccurrenceIndicator(targetCardinality); return "(" + getBaseExpression().toString() + " instance of " + targetType.toString() + occ + ")"; }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new InstanceOfExpression(getBaseExpression().copy(), SequenceType.makeSequenceType(targetType, targetCardinality)); }
/** * Get an Itemtype that all the items matching this pattern must satisfy */ public ItemType getItemType() { if (getPredicate() instanceof InstanceOfExpression) { InstanceOfExpression ioe = (InstanceOfExpression)getPredicate(); if (ioe.getBaseExpression() instanceof ContextItemExpression) { return ioe.getRequiredItemType(); } } return AnyItemType.getInstance(); }
/** * Get an Itemtype that all the items matching this pattern must satisfy */ public ItemType getItemType() { if (getPredicate() instanceof InstanceOfExpression) { InstanceOfExpression ioe = (InstanceOfExpression)getPredicate(); if (ioe.getBaseExpression() instanceof ContextItemExpression) { return ioe.getRequiredItemType(); } } return AnyItemType.getInstance(); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings variable references that need to be rebound */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { InstanceOfExpression exp = new InstanceOfExpression(getBaseExpression().copy(rebindings), SequenceType.makeSequenceType(targetType, targetCardinality)); ExpressionTool.copyLocationInfo(this, exp); return exp; }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings variable references that need to be rebound */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { InstanceOfExpression exp = new InstanceOfExpression(getBaseExpression().copy(rebindings), SequenceType.makeSequenceType(targetType, targetCardinality)); 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 out) throws XPathException { out.startElement("instance", this); if (targetCardinality == StaticProperty.ALLOWS_ZERO) { out.emitAttribute("of", "empty-sequence()"); } else { out.emitAttribute("of", targetType.toExportString() + Cardinality.getOccurrenceIndicator(targetCardinality)); } if ("JS".equals(((ExpressionPresenter.ExportOptions) out.getOptions()).target)) { int targetVersion = ((ExpressionPresenter.ExportOptions) out.getOptions()).targetVersion; out.emitAttribute("jsTest", targetType.generateJavaScriptItemTypeTest(getBaseExpression().getItemType(), targetVersion)); } getBaseExpression().export(out); out.endElement(); }
private AbstractExpression exprFor (InstanceOfExpression expr) { ItemType type = expr.getRequiredItemType(); String typeExpr; if (type.isPlainType()) { typeExpr = type.toString(); } else if (type instanceof NodeTest) { lux.xpath.NodeTest nodeTest = nodeTestFor((NodeTest)type); typeExpr = nodeTest.toString(); } else { throw new LuxException ("Unsupported node test in instance-of expression: " + expr.toString()); } return new InstanceOf(typeExpr, exprFor (expr.getBaseExpression())); }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void export(ExpressionPresenter out) throws XPathException { out.startElement("instance", this); if (targetCardinality == StaticProperty.ALLOWS_ZERO) { out.emitAttribute("of", "empty-sequence()"); } else { out.emitAttribute("of", targetType.toExportString() + Cardinality.getOccurrenceIndicator(targetCardinality)); } if ("JS".equals(((ExpressionPresenter.ExportOptions) out.getOptions()).target)) { int targetVersion = ((ExpressionPresenter.ExportOptions) out.getOptions()).targetVersion; out.emitAttribute("jsTest", targetType.generateJavaScriptItemTypeTest(getBaseExpression().getItemType(), targetVersion)); } getBaseExpression().export(out); out.endElement(); }
/** * Get the data type of the items returned * * @return an integer representing the data type */ /*@NotNull*/ public ItemType getItemType() { // special case the expression B[. instance of x] if (getFilter() instanceof InstanceOfExpression && ((InstanceOfExpression) getFilter()).getBaseExpression() instanceof ContextItemExpression) { return ((InstanceOfExpression) getFilter()).getRequiredItemType(); } return getBase().getItemType(); }
/** * Get the data type of the items returned * * @return an integer representing the data type */ /*@NotNull*/ public ItemType getItemType() { // special case the expression B[. instance of x] if (getFilter() instanceof InstanceOfExpression && ((InstanceOfExpression) getFilter()).getBaseExpression() instanceof ContextItemExpression) { return ((InstanceOfExpression) getFilter()).getRequiredItemType(); } return getBase().getItemType(); }