public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { if (contextItemType.isAtomicType()) { return new ContextItemExpression(); } } return exp; }
/** * @return Whether to insert 'validate { }' code into generated xquery expression */ public boolean doValidate(Object requestedType) { ItemType t = unifyTypeFromODE(requestedType); t = simplify(t); if (t == null || t.isAtomicType()) return false; return true; }
public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { if (contextItemType.isAtomicType()) { return new ContextItemExpression(); } } return exp; }
public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { if (contextItemType.isAtomicType()) { return new ContextItemExpression(); } } return exp; }
/** * Attempt to optimize a copy operation. Return null if no optimization is possible. * @param select the expression that selects the items to be copied * @return null if no optimization is possible, or an expression that does an optimized * copy of these items otherwise */ public Expression optimizeCopy(Expression select) throws XPathException { final TypeHierarchy th = config.getTypeHierarchy(); if (select.getItemType(th).isAtomicType()) { return select; } return null; }
/** * Attempt to optimize a copy operation. Return null if no optimization is possible. * @param select the expression that selects the items to be copied * @return null if no optimization is possible, or an expression that does an optimized * copy of these items otherwise */ public Expression optimizeCopy(Expression select) throws XPathException { final TypeHierarchy th = config.getTypeHierarchy(); if (select.getItemType(th).isAtomicType()) { return select; } return null; }
/** * Determine whether this instruction creates new nodes. * The result depends on the type of the select expression. */ public final boolean createsNewNodes() { Executable exec = getExecutable(); if (exec == null) { return true; // This shouldn't happen, but we err on the safe side } final TypeHierarchy th = exec.getConfiguration().getTypeHierarchy(); return !select.getItemType(th).isAtomicType(); }
public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (operand.getItemType(th).isAtomicType()) { return operand; } return this; } else { return exp; } }
public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (operand.getItemType(th).isAtomicType()) { return operand; } return this; } else { return exp; } }
/** * Determine whether this instruction creates new nodes. * The result depends on the type of the select expression. */ public final boolean createsNewNodes() { Executable exec = getExecutable(); if (exec == null) { return true; // This shouldn't happen, but we err on the safe side } final TypeHierarchy th = exec.getConfiguration().getTypeHierarchy(); return !select.getItemType(th).isAtomicType(); }
public static String getTypeName(ItemType type) { if (type.isAtomicType()) { return type.getAtomizedItemType().getTypeName().getLocalPart(); } return type.toString(); }
/** * Determine the data type of the items returned by the expression * * @param th the type hierarchy cache */ public ItemType getItemType(TypeHierarchy th) { ItemType it = operand.getItemType(th); singleton = it.isAtomicType() && !Cardinality.allowsMany(operand.getCardinality()); if (allConverted) { return requiredItemType; } else { return Type.getCommonSuperType(requiredItemType, operand.getItemType(th), th); } }
/** * Determine the data type of the items returned by the expression * * @param th the type hierarchy cache */ public ItemType getItemType(TypeHierarchy th) { //resetStaticProperties(visitor); // allow cardinality to be recomputed // TODO: deleted above line without really understanding the consequences 2007-02-28 ItemType it = operand.getItemType(th); singleton = it.isAtomicType() && !Cardinality.allowsMany(operand.getCardinality()); if (allConverted) { return requiredItemType; } else { return Type.getCommonSuperType(requiredItemType, operand.getItemType(th), th); } }
/** * Determine the data type of the items returned by the expression * * @param th the type hierarchy cache */ public ItemType getItemType(TypeHierarchy th) { //resetStaticProperties(visitor); // allow cardinality to be recomputed // TODO: deleted above line without really understanding the consequences 2007-02-28 ItemType it = operand.getItemType(th); singleton = it.isAtomicType() && !Cardinality.allowsMany(operand.getCardinality()); if (allConverted) { return requiredItemType; } else { return Type.getCommonSuperType(requiredItemType, operand.getItemType(th), th); } }
public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { if (readOnce) { Expression optcopy = visitor.getConfiguration().getOptimizer().optimizeCopy(select); if (optcopy != null) { return optcopy; } } select = visitor.optimize(select, contextItemType); adoptChildExpression(select); final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (select.getItemType(th).isAtomicType()) { return select; } return this; }
public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { if (readOnce) { Expression optcopy = visitor.getConfiguration().getOptimizer().optimizeCopy(select); if (optcopy != null) { return optcopy; } } select = visitor.optimize(select, contextItemType); adoptChildExpression(select); final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (select.getItemType(th).isAtomicType()) { return select; } return this; }
/** * Make an expression that extracts the first item of a sequence, after atomization */ public static Expression makeFirstItem(Expression exp, StaticContext env) { final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); if (!exp.getItemType(th).isAtomicType()) { exp = new Atomizer(exp, env.getConfiguration()); } if (Cardinality.allowsMany(exp.getCardinality())) { exp = new FirstItemExpression(exp); } if (!th.isSubType(exp.getItemType(th), BuiltInAtomicType.STRING)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); } return exp; }
/** * Make an expression that extracts the first item of a sequence, after atomization */ public static Expression makeFirstItem(Expression exp, StaticContext env) { final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); if (!exp.getItemType(th).isAtomicType()) { exp = new Atomizer(exp, env.getConfiguration()); } if (Cardinality.allowsMany(exp.getCardinality())) { exp = new FirstItemExpression(exp); } if (!th.isSubType(exp.getItemType(th), BuiltInAtomicType.STRING)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); } return exp; }
/** * Make an expression that extracts the first item of a sequence, after atomization */ public static Expression makeFirstItem(Expression exp, StaticContext env) { final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); if (!exp.getItemType(th).isAtomicType()) { exp = new Atomizer(exp, env.getConfiguration()); } if (Cardinality.allowsMany(exp.getCardinality())) { exp = new FirstItemExpression(exp); } if (!th.isSubType(exp.getItemType(th), BuiltInAtomicType.STRING)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); } return exp; }
public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { select = visitor.typeCheck(select, contextItemType); separator = visitor.typeCheck(separator, contextItemType); if (!Cardinality.allowsMany(select.getCardinality())) { isSingleton = true; } final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (select.getItemType(th).isAtomicType()) { isAtomic = true; } select.setFlattened(true); if (select instanceof Literal && separator instanceof Literal) { XPathContext c = visitor.getStaticContext().makeEarlyEvaluationContext(); return new Literal(Value.asValue(evaluateItem(c))); } return this; }