/** * Get a sequence type to which a given value conforms * @param value the given value * @param th the type hierarchy cache * @return the best available sequence type to which the supplied value conforms */ public static SequenceType getSequenceType(Sequence<?> value, TypeHierarchy th) { return SequenceType.makeSequenceType(getItemType(value, th), getCardinality(value)); }
/** * Get a sequence type to which a given value conforms * @param value the given value * @param th the type hierarchy cache * @return the best available sequence type to which the supplied value conforms */ public static SequenceType getSequenceType(Sequence<?> value, TypeHierarchy th) { return SequenceType.makeSequenceType(getItemType(value, th), getCardinality(value)); }
} else { throw new XPathException("Cannot convert value " + value.getClass() + " of type " + SequenceTool.getItemType(value, context.getConfiguration().getTypeHierarchy()) + " to class " + targetClass.getName());
} else { throw new XPathException("Cannot convert value " + value.getClass() + " of type " + SequenceTool.getItemType(value, context.getConfiguration().getTypeHierarchy()) + " to class " + targetClass.getName());
/** * Get the type of the map. This method is used largely for diagnostics, to report * the type of a map when it differs from the required type. * * @param th the type hierarchy cache * @return the type of this map */ @Override public ItemType getItemType(TypeHierarchy th) { return new MapType(key.getItemType(), SequenceType.makeSequenceType( SequenceTool.getItemType(value, th), SequenceTool.getCardinality(value))); }
GroundedValue<?> val = entry.getValue(); if (valueType == null) { valueType = SequenceTool.getItemType(val, th); valueCard = SequenceTool.getCardinality(val); } else { valueType = Type.getCommonSuperType(valueType, SequenceTool.getItemType(val, th), th); valueCard = Cardinality.union(valueCard, SequenceTool.getCardinality(val));
public Object convert(Sequence<?> value, Class<?> targetClass, XPathContext context) throws XPathException { Configuration config = context.getConfiguration(); GroundedValue<?> gv = value.materialize(); PJConverter converter = allocate( config, SequenceTool.getItemType(gv, config.getTypeHierarchy()), SequenceTool.getCardinality(gv), targetClass); if (converter instanceof General) { converter = Identity.INSTANCE; } return converter.convert(gv, targetClass, context); } }
/** * Determine the data type of the items in the expression, if possible * * @return for the default implementation: AnyItemType (not known) */ /*@NotNull*/ public ItemType getItemType() { // Avoid getting the configuration if we can: it's a common source of NPE's if (value instanceof AtomicValue) { return ((AtomicValue) value).getItemType(); } else if (value.getLength() == 0) { return ErrorType.getInstance(); } else { TypeHierarchy th = getConfiguration().getTypeHierarchy(); return SequenceTool.getItemType(value, th); } }
public Object convert(Sequence<?> value, Class<?> targetClass, XPathContext context) throws XPathException { Configuration config = context.getConfiguration(); GroundedValue<?> gv = value.materialize(); PJConverter converter = allocate( config, SequenceTool.getItemType(gv, config.getTypeHierarchy()), SequenceTool.getCardinality(gv), targetClass); if (converter instanceof General) { converter = Identity.INSTANCE; } return converter.convert(gv, targetClass, context); } }
/** * Determine the data type of the items in the expression, if possible * * @return for the default implementation: AnyItemType (not known) */ /*@NotNull*/ public ItemType getItemType() { // Avoid getting the configuration if we can: it's a common source of NPE's if (value instanceof AtomicValue) { return ((AtomicValue) value).getItemType(); } else if (value.getLength() == 0) { return ErrorType.getInstance(); } else { TypeHierarchy th = getConfiguration().getTypeHierarchy(); return SequenceTool.getItemType(value, th); } }
for (GroundedValue<?> s : members()) { if (contentType == null) { contentType = SequenceTool.getItemType(s, th); contentCard = SequenceTool.getCardinality(s); } else { contentType = Type.getCommonSuperType(contentType, SequenceTool.getItemType(s, th)); contentCard = Cardinality.union(contentCard, SequenceTool.getCardinality(s));
for (GroundedValue<?> s : members()) { if (contentType == null) { contentType = SequenceTool.getItemType(s, th); contentCard = SequenceTool.getCardinality(s); } else { contentType = Type.getCommonSuperType(contentType, SequenceTool.getItemType(s, th)); contentCard = Cardinality.union(contentCard, SequenceTool.getCardinality(s));
if (keyType == null) { keyType = key.getItemType(); valueType = SequenceTool.getItemType(val, th); valueCard = SequenceTool.getCardinality(val); } else { keyType = (AtomicType)Type.getCommonSuperType(keyType, key.getItemType(), th); valueType = Type.getCommonSuperType(valueType, SequenceTool.getItemType(val, th), th); valueCard = Cardinality.union(valueCard, SequenceTool.getCardinality(val));
if (keyType == null) { keyType = key.getItemType(); valueType = SequenceTool.getItemType(val, th); valueCard = SequenceTool.getCardinality(val); } else { keyType = (AtomicType)Type.getCommonSuperType(keyType, key.getItemType(), th); valueType = Type.getCommonSuperType(valueType, SequenceTool.getItemType(val, th), th); valueCard = Cardinality.union(valueCard, SequenceTool.getCardinality(val));
public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); Item value = arguments[0].head(); ItemType type = SequenceTool.getItemType(value, th); if (th.isSubType(type, AnyNodeTest.getInstance())) { return new StringValue("node-set"); } else if (th.isSubType(type, BuiltInAtomicType.STRING)) { return new StringValue("string"); } else if (th.isSubType(type, NumericType.getInstance())) { return new StringValue("number"); } else if (th.isSubType(type, BuiltInAtomicType.BOOLEAN)) { return new StringValue("boolean"); } else { return new StringValue(type.toString()); } } }
public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); Item value = arguments[0].head(); ItemType type = SequenceTool.getItemType(value, th); if (th.isSubType(type, AnyNodeTest.getInstance())) { return new StringValue("node-set"); } else if (th.isSubType(type, BuiltInAtomicType.STRING)) { return new StringValue("string"); } else if (th.isSubType(type, NumericType.getInstance())) { return new StringValue("number"); } else if (th.isSubType(type, BuiltInAtomicType.BOOLEAN)) { return new StringValue("boolean"); } else { return new StringValue(type.toString()); } } }
if (relation == TypeHierarchy.SAME_TYPE || relation == TypeHierarchy.SUBSUMED_BY) { constantValue = ((Literal) select).getValue(); type = SequenceType.makeSequenceType(SequenceTool.getItemType(constantValue, th), SequenceTool.getCardinality(constantValue));
if (relation == TypeHierarchy.SAME_TYPE || relation == TypeHierarchy.SUBSUMED_BY) { constantValue = ((Literal) select).getValue(); type = SequenceType.makeSequenceType(SequenceTool.getItemType(constantValue, th), SequenceTool.getCardinality(constantValue));
ItemType suppliedItemType = SequenceTool.getItemType(value, this);
ItemType suppliedItemType = SequenceTool.getItemType(value, this);