KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > type > ItemType


1 package net.sf.saxon.type;
2 import net.sf.saxon.om.Item;
3 import net.sf.saxon.om.NamePool;
4
5 import java.io.Serializable JavaDoc;
6
7
8 /**
9  * ItemType is an interface that allows testing of whether an Item conforms to an
10  * expected type. ItemType represents the types in the type hierarchy in the XPath model,
11  * as distinct from the schema model: an item type is either item() (matches everything),
12  * a node type (matches nodes), an atomic type (matches atomic values), or empty()
13  * (matches nothing). Atomic types, represented by the class AtomicType, are also
14  * instances of SimpleType in the schema type heirarchy. Node Types, represented by
15  * the class NodeTest, are also Patterns as used in XSLT.
16  * @see net.sf.saxon.type.AtomicType
17  * @see net.sf.saxon.pattern.NodeTest
18 */

19
20 public interface ItemType extends Serializable JavaDoc {
21
22     /**
23      * Test whether a given item conforms to this type
24      * @param item The item to be tested
25      * @return true if the item is an instance of this type; false otherwise
26     */

27
28     public boolean matchesItem(Item item);
29
30     /**
31      * Get the type from which this item type is derived by restriction. This
32      * is the supertype in the XPath type heirarchy, as distinct from the Schema
33      * base type: this means that the supertype of xs:boolean is xdt:anyAtomicType,
34      * whose supertype is item() (rather than xs:anySimpleType).
35      * <p>
36      * In fact the concept of "supertype" is not really well-defined, because the types
37      * form a lattice rather than a hierarchy. The only real requirement on this function
38      * is that it returns a type that strictly subsumes this type, ideally as narrowly
39      * as possible.
40      * @return the supertype, or null if this type is item()
41      */

42
43     public ItemType getSuperType();
44
45     /**
46      * Get the primitive item type corresponding to this item type. For item(),
47      * this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds,
48      * it is the value representing the node kind, for example Type.ELEMENT.
49      * For anyAtomicValue it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER.
50      * For other atomic types it is the primitive type as defined in XML Schema,
51      * except that INTEGER is considered to be a primitive type.
52      */

53
54     public ItemType getPrimitiveItemType();
55
56     /**
57      * Get the primitive type corresponding to this item type. For item(),
58      * this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds,
59      * it is the value representing the node kind, for example Type.ELEMENT.
60      * For anyAtomicValue it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER.
61      * For other atomic types it is the primitive type as defined in XML Schema,
62      * except that INTEGER is considered to be a primitive type.
63      */

64
65     public int getPrimitiveType();
66
67     /**
68      * Produce a representation of this type name for use in error messages.
69      * Where this is a QName, it will use conventional prefixes
70      */

71
72     public String JavaDoc toString(NamePool pool);
73
74     /**
75      * Get the item type of the atomic values that will be produced when an item
76      * of this type is atomized
77      */

78
79     public AtomicType getAtomizedItemType();
80
81 }
82
83 //
84
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
85
// you may not use this file except in compliance with the License. You may obtain a copy of the
86
// License at http://www.mozilla.org/MPL/
87
//
88
// Software distributed under the License is distributed on an "AS IS" basis,
89
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
90
// See the License for the specific language governing rights and limitations under the License.
91
//
92
// The Original Code is: all this file.
93
//
94
// The Initial Developer of the Original Code is Michael H. Kay.
95
//
96
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
97
//
98
// Contributor(s): none.
99
//
100
Popular Tags