KickJava   Java API By Example, From Geeks To Geeks.

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


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  * An implementation of ItemType that matches any item (node or atomic value)
10 */

11
12 public class AnyItemType implements ItemType, Serializable JavaDoc {
13
14     private AnyItemType(){};
15
16     private static AnyItemType theInstance = new AnyItemType();
17
18     /**
19      * Factory method to get the singleton instance
20      */

21
22     public static AnyItemType getInstance() {
23         return theInstance;
24     }
25
26
27     /**
28      * Test whether a given item conforms to this type
29      * @param item The item to be tested
30      * @return true if the item is an instance of this type; false otherwise
31     */

32
33     public boolean matchesItem(Item item) {
34         return true;
35     }
36
37     public ItemType getSuperType() {
38         return null;
39     }
40
41     /**
42      * Get the primitive item type corresponding to this item type. For item(),
43      * this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds,
44      * it is the value representing the node kind, for example Type.ELEMENT.
45      * For anyAtomicValue it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER.
46      * For other atomic types it is the primitive type as defined in XML Schema,
47      * except that INTEGER is considered to be a primitive type.
48      */

49
50     public ItemType getPrimitiveItemType() {
51         return this;
52     }
53
54     public int getPrimitiveType() {
55         return Type.ITEM;
56     }
57
58     public AtomicType getAtomizedItemType() {
59         return Type.ANY_ATOMIC_TYPE;
60     }
61
62     public String JavaDoc toString() {
63         return "item()";
64     }
65
66     public String JavaDoc toString(NamePool pool) {
67         return "item()";
68     }
69
70     /**
71      * Returns a hash code value for the object.
72      */

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