public ItemType getSuperType(TypeHierarchy th) { return NodeKindTest.makeNodeKindTest(kind); }
public ItemType getSuperType(TypeHierarchy th) { return NodeKindTest.makeNodeKindTest(kind); }
/** * Get the type from which this item type is derived by restriction. This * is the supertype in the XPath type heirarchy, as distinct from the Schema * base type: this means that the supertype of xs:boolean is xs:anyAtomicType, * whose supertype is item() (rather than xs:anySimpleType). * <p> * In fact the concept of "supertype" is not really well-defined, because the types * form a lattice rather than a hierarchy. The only real requirement on this function * is that it returns a type that strictly subsumes this type, ideally as narrowly * as possible. * @return the supertype, or null if this type is item() * @param th the type hierarchy cache */ public ItemType getSuperType(TypeHierarchy th) { return NodeKindTest.makeNodeKindTest(nodeKind); }
/** * Get the type from which this item type is derived by restriction. This * is the supertype in the XPath type heirarchy, as distinct from the Schema * base type: this means that the supertype of xs:boolean is xs:anyAtomicType, * whose supertype is item() (rather than xs:anySimpleType). * <p> * In fact the concept of "supertype" is not really well-defined, because the types * form a lattice rather than a hierarchy. The only real requirement on this function * is that it returns a type that strictly subsumes this type, ideally as narrowly * as possible. * @return the supertype, or null if this type is item() * @param th the type hierarchy cache */ public ItemType getSuperType(TypeHierarchy th) { return NodeKindTest.makeNodeKindTest(nodeKind); }
/** * Get the type from which this item type is derived by restriction. This * is the supertype in the XPath type heirarchy, as distinct from the Schema * base type: this means that the supertype of xs:boolean is xs:anyAtomicType, * whose supertype is item() (rather than xs:anySimpleType). * <p> * In fact the concept of "supertype" is not really well-defined, because the types * form a lattice rather than a hierarchy. The only real requirement on this function * is that it returns a type that strictly subsumes this type, ideally as narrowly * as possible. * @return the supertype, or null if this type is item() * @param th the type hierarchy cache */ public ItemType getSuperType(TypeHierarchy th) { return NodeKindTest.makeNodeKindTest(nodeKind); }
/** * Get the type from which this item type is derived by restriction. This * is the supertype in the XPath type heirarchy, as distinct from the Schema * base type: this means that the supertype of xs:boolean is xs:anyAtomicType, * whose supertype is item() (rather than xs:anySimpleType). * <p> * In fact the concept of "supertype" is not really well-defined, because the types * form a lattice rather than a hierarchy. The only real requirement on this function * is that it returns a type that strictly subsumes this type, ideally as narrowly * as possible. * @return the supertype, or null if this type is item() * @param th the type hierarchy cache */ public ItemType getSuperType(TypeHierarchy th) { return NodeKindTest.makeNodeKindTest(nodeKind); }
/** * Get a NodeTest that all the nodes matching this pattern must satisfy */ public NodeTest getNodeTest() { if (nodeType==Type.NODE) { return AnyNodeTest.getInstance(); } else { return NodeKindTest.makeNodeKindTest(nodeType); } }
/** * Get a NodeTest that all the nodes matching this pattern must satisfy */ public NodeTest getNodeTest() { if (nodeType == Type.NODE) { return AnyNodeTest.getInstance(); } else { return NodeKindTest.makeNodeKindTest(nodeType); } }
/** * Determine the data type of the items returned by this expression * * @return Type.NODE or a subtype, based on the NodeTest in the axis step, plus * information about the content type if this is known from schema analysis */ /*@NotNull*/ public final ItemType getItemType() { if (itemType != null) { return itemType; } int p = AxisInfo.principalNodeType[axis]; switch (p) { case Type.ATTRIBUTE: case Type.NAMESPACE: return NodeKindTest.makeNodeKindTest(p); default: if (test == null) { return AnyNodeTest.getInstance(); } else { return test; } } }
/** * Determine the data type of the items returned by this expression * * @return Type.NODE or a subtype, based on the NodeTest in the axis step, plus * information about the content type if this is known from schema analysis */ /*@NotNull*/ public final ItemType getItemType() { if (itemType != null) { return itemType; } int p = AxisInfo.principalNodeType[axis]; switch (p) { case Type.ATTRIBUTE: case Type.NAMESPACE: return NodeKindTest.makeNodeKindTest(p); default: if (test == null) { return AnyNodeTest.getInstance(); } else { return test; } } }
/** * Get the primitive item type corresponding to this item type. For item(), * this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds, * it is the value representing the node kind, for example Type.ELEMENT. * For anyAtomicValue it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER. * For other atomic types it is the primitive type as defined in XML Schema, * except that INTEGER is considered to be a primitive type. */ public ItemType getPrimitiveItemType() { int p = getPrimitiveType(); if (p == Type.NODE) { return AnyNodeTest.getInstance(); } else { return NodeKindTest.makeNodeKindTest(p); } }
/** * Get the ItemType of an Item * @param item the item whose type is required * @param th the type hierarchy cache * @return the item type of the item */ public static ItemType getItemType(Item item, TypeHierarchy th) { if (item instanceof AtomicValue) { return ((AtomicValue)item).getItemType(th); } else { return NodeKindTest.makeNodeKindTest(((NodeInfo)item).getNodeKind()); // We could return a more precise type than this, for example one that includes // a ContentTypeTest for the type annotation of the nodes. However, given the way in which // this method is used, this wouldn't be very useful } }
/** * Get the primitive item type corresponding to this item type. For item(), * this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds, * it is the value representing the node kind, for example Type.ELEMENT. * For anyAtomicValue it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER. * For other atomic types it is the primitive type as defined in XML Schema, * except that INTEGER is considered to be a primitive type. */ /*@NotNull*/ public ItemType getPrimitiveItemType() { int p = getPrimitiveType(); if (p == Type.NODE) { return AnyNodeTest.getInstance(); } else { return NodeKindTest.makeNodeKindTest(p); } }
/** * Get the ItemType of an Item * @param item the item whose type is required * @param th the type hierarchy cache * @return the item type of the item */ public static ItemType getItemType(Item item, TypeHierarchy th) { if (item instanceof AtomicValue) { return ((AtomicValue)item).getItemType(th); } else { return NodeKindTest.makeNodeKindTest(((NodeInfo)item).getNodeKind()); // We could return a more precise type than this, for example one that includes // a ContentTypeTest for the type annotation of the nodes. However, given the way in which // this method is used, this wouldn't be very useful } }
/** * Get the primitive item type corresponding to this item type. For item(), * this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds, * it is the value representing the node kind, for example Type.ELEMENT. * For anyAtomicValue it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER. * For other atomic types it is the primitive type as defined in XML Schema, * except that INTEGER is considered to be a primitive type. */ public ItemType getPrimitiveItemType() { int p = getPrimitiveType(); if (p == Type.NODE) { return AnyNodeTest.getInstance(); } else { return NodeKindTest.makeNodeKindTest(p); } }
/** * Get the primitive item type corresponding to this item type. For item(), * this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds, * it is the value representing the node kind, for example Type.ELEMENT. * For anyAtomicValue it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER. * For other atomic types it is the primitive type as defined in XML Schema, * except that INTEGER is considered to be a primitive type. */ /*@NotNull*/ public ItemType getPrimitiveItemType() { int p = getPrimitiveType(); if (p == Type.NODE) { return AnyNodeTest.getInstance(); } else { return NodeKindTest.makeNodeKindTest(p); } }
/** * Get simple node number. This is defined as one plus the number of previous siblings of the * same node type and name. It is not accessible directly in XSL. This version doesn't require * the controller, and therefore doesn't remember previous results. It is used only by getPath(). * * @param node the node whose number is required * @return the node number, as defined above */ private static int getNumberSimple(NodeInfo node) { int fingerprint = node.getFingerprint(); NodeTest same; if (fingerprint == -1) { same = NodeKindTest.makeNodeKindTest(node.getNodeKind()); } else { same = new NameTest(node); } AxisIterator preceding = node.iterateAxis(Axis.PRECEDING_SIBLING, same); int i = 1; while (preceding.next() != null) { i++; } return i; }
/** * Get an ItemType representing the type of a supplied XdmItem. If the supplied item is * an atomic value, the returned ItemType will reflect the most specific atomic type of the * item. If the supplied item is a node, the returned item type will reflect the node kind, * and if the node has a name, then its name. It will not reflect the type annotation. * * @param item the supplied item whose type is required * @return the type of the supplied item */ public ItemType getItemType(XdmItem item) { if (item.isAtomicValue()) { AtomicValue value = (AtomicValue) item.getUnderlyingValue(); AtomicType type = value.getItemType(); return new ConstructedItemType(type, processor); } else { NodeInfo node = (NodeInfo) item.getUnderlyingValue(); int kind = node.getNodeKind(); if (node.getLocalPart().isEmpty()) { return new ConstructedItemType(NodeKindTest.makeNodeKindTest(kind), processor); } else { return new ConstructedItemType(new SameNameTest(node), processor); } } }
/** * Get the value of the item as a CharSequence. This is in some cases more efficient than * the version of the method that returns a String. */ public CharSequence getStringValueCS() { // Might not be the same as the string value of the underlying node because of space stripping switch (getNodeKind()) { case Type.DOCUMENT: case Type.ELEMENT: AxisIterator iter = iterateAxis(AxisInfo.DESCENDANT, NodeKindTest.makeNodeKindTest(Type.TEXT)); FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.C64); while (true) { NodeInfo it = iter.next(); if (it == null) { break; } sb.append(it.getStringValueCS()); } return sb.condense(); default: return node.getStringValueCS(); } }
/** * Get the value of the item as a CharSequence. This is in some cases more efficient than * the version of the method that returns a String. */ public CharSequence getStringValueCS() { // Might not be the same as the string value of the underlying node because of space stripping switch (getNodeKind()) { case Type.DOCUMENT: case Type.ELEMENT: AxisIterator iter = iterateAxis(Axis.DESCENDANT, NodeKindTest.makeNodeKindTest(Type.TEXT)); FastStringBuffer sb = new FastStringBuffer(1024); while(true) { NodeInfo it = (NodeInfo)iter.next(); if (it == null) { break; } sb.append(it.getStringValueCS()); } return sb.condense(); default: return node.getStringValueCS(); } }