/** * Determine the static cardinality of the expression */ public int computeCardinality() { return getBaseExpression().getCardinality(); }
/** * Determine the static cardinality of the expression */ public int computeCardinality() { return getBaseExpression().getCardinality(); }
public AbstractExpression exprFor (AtomicSequenceConverter atomizer) { return exprFor (atomizer.getBaseExpression()); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new AtomicSequenceConverter(getBaseExpression().copy(), requiredItemType); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new AtomicSequenceConverter(getBaseExpression().copy(), requiredItemType); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new AtomicSequenceConverter(getBaseExpression().copy(), requiredItemType); }
public void allocateConverterStatically(Configuration config, boolean allowNull) { converter = allocateConverter(config, allowNull, getBaseExpression().getItemType()); }
public Converter allocateConverter(Configuration config, boolean allowNull) { return allocateConverter(config, allowNull, getBaseExpression().getItemType()); }
public Converter allocateConverter(Configuration config, boolean allowNull) { return allocateConverter(config, allowNull, getBaseExpression().getItemType()); }
public void allocateConverterStatically(Configuration config, boolean allowNull) { converter = allocateConverter(config, allowNull, getBaseExpression().getItemType()); }
/** * 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) { AtomicSequenceConverter atomicConverter = new AtomicSequenceConverter(getBaseExpression().copy(rebindings), requiredItemType); ExpressionTool.copyLocationInfo(this, atomicConverter); atomicConverter.setConverter(converter); atomicConverter.setRoleDiagnostic(getRoleDiagnostic()); return atomicConverter; }
/** * 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) { AtomicSequenceConverter atomicConverter = new AtomicSequenceConverter(getBaseExpression().copy(rebindings), requiredItemType); ExpressionTool.copyLocationInfo(this, atomicConverter); atomicConverter.setConverter(converter); atomicConverter.setRoleDiagnostic(getRoleDiagnostic()); return atomicConverter; }
/** * Evaluate as an Item. This should only be called if the AtomicSequenceConverter has cardinality zero-or-one */ public AtomicValue evaluateItem(XPathContext context) throws XPathException { Converter conv = getConverterDynamically(context); AtomicValue item = (AtomicValue) getBaseExpression().evaluateItem(context); if (item == null) { return null; } ConversionResult result = conv.convert(item); if (roleDiagnostic != null && result instanceof ValidationFailure) { // TODO: use more of the information in the roleDiagnostic to form the error message ((ValidationFailure)result).setErrorCode(roleDiagnostic.getErrorCode()); } return result.asAtomic(); }
/** * Evaluate as an Item. This should only be called if the AtomicSequenceConverter has cardinality zero-or-one */ public AtomicValue evaluateItem(XPathContext context) throws XPathException { Converter conv = getConverterDynamically(context); AtomicValue item = (AtomicValue) getBaseExpression().evaluateItem(context); if (item == null) { return null; } ConversionResult result = conv.convert(item); if (roleDiagnostic != null && result instanceof ValidationFailure) { // TODO: use more of the information in the roleDiagnostic to form the error message ((ValidationFailure)result).setErrorCode(roleDiagnostic.getErrorCode()); } return result.asAtomic(); }
/** * Type-check the expression */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { typeCheckChildren(visitor, contextInfo); Configuration config = visitor.getConfiguration(); final TypeHierarchy th = config.getTypeHierarchy(); Expression operand = getBaseExpression(); if (th.isSubType(operand.getItemType(), requiredItemType)) { return operand; } else { if (converter == null) { allocateConverterStatically(config, true); } return this; } }
/** * Type-check the expression */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { typeCheckChildren(visitor, contextInfo); Configuration config = visitor.getConfiguration(); final TypeHierarchy th = config.getTypeHierarchy(); Expression operand = getBaseExpression(); if (th.isSubType(operand.getItemType(), requiredItemType)) { return operand; } else { if (converter == null) { allocateConverterStatically(config, true); } return this; } }
/** * 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("convert", this); destination.emitAttribute("from", getBaseExpression().getItemType().toExportString()); destination.emitAttribute("to", requiredItemType.toExportString()); if (converter instanceof Converter.PromoterToDouble || converter instanceof Converter.PromoterToFloat) { destination.emitAttribute("flags", "p"); } if (getRoleDiagnostic() != null) { destination.emitAttribute("diag", getRoleDiagnostic().save()); } getBaseExpression().export(destination); destination.endElement(); }
/** * 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("convert", this); destination.emitAttribute("from", getBaseExpression().getItemType().toExportString()); destination.emitAttribute("to", requiredItemType.toExportString()); if (converter instanceof Converter.PromoterToDouble || converter instanceof Converter.PromoterToFloat) { destination.emitAttribute("flags", "p"); } if (getRoleDiagnostic() != null) { destination.emitAttribute("diag", getRoleDiagnostic().save()); } getBaseExpression().export(destination); destination.endElement(); }
/** * Iterate over the sequence of values */ /*@NotNull*/ public SequenceIterator<? extends AtomicValue> iterate(final XPathContext context) throws XPathException { SequenceIterator<?> base = getBaseExpression().iterate(context); Converter conv = getConverterDynamically(context); if (conv == Converter.ToStringConverter.INSTANCE) { return new ItemMappingIterator<>(base, TO_STRING_MAPPER, true); } else { AtomicSequenceMappingFunction mapper = new AtomicSequenceMappingFunction(); mapper.setConverter(conv); if (roleDiagnostic != null) { mapper.setErrorCode(roleDiagnostic.getErrorCode()); } return new ItemMappingIterator<>((SequenceIterator<? extends AtomicValue>)base, mapper, true); } }
/** * Iterate over the sequence of values */ /*@NotNull*/ public SequenceIterator<? extends AtomicValue> iterate(final XPathContext context) throws XPathException { SequenceIterator<?> base = getBaseExpression().iterate(context); Converter conv = getConverterDynamically(context); if (conv == Converter.ToStringConverter.INSTANCE) { return new ItemMappingIterator<>(base, TO_STRING_MAPPER, true); } else { AtomicSequenceMappingFunction mapper = new AtomicSequenceMappingFunction(); mapper.setConverter(conv); if (roleDiagnostic != null) { mapper.setErrorCode(roleDiagnostic.getErrorCode()); } return new ItemMappingIterator<>((SequenceIterator<? extends AtomicValue>)base, mapper, true); } }