KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > dv > XSSimpleType


1 /*
2  * Copyright 2001, 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.impl.dv;
18
19 import org.apache.xerces.xs.XSSimpleTypeDefinition;
20
21 /**
22  * This interface <code>XSSimpleType</code> represents the simple type
23  * definition of schema component and defines methods to query the information
24  * contained.
25  * Any simple type (atomic, list or union) will implement this interface.
26  * It inherits from <code>XSTypeDecl</code>.
27  *
28  * @xerces.internal
29  *
30  * @author Sandy Gao, IBM
31  *
32  * @version $Id: XSSimpleType.java,v 1.17 2004/10/06 14:56:50 mrglavas Exp $
33  */

34 public interface XSSimpleType extends XSSimpleTypeDefinition {
35
36     /**
37      * constants defined for the values of 'whitespace' facet.
38      * see <a HREF='http://www.w3.org/TR/xmlschema-2/#dt-whiteSpace'> XML Schema
39      * Part 2: Datatypes </a>
40      */

41     /** preserve the white spaces */
42     public static final short WS_PRESERVE = 0;
43     /** replace the white spaces */
44     public static final short WS_REPLACE = 1;
45     /** collapse the white spaces */
46     public static final short WS_COLLAPSE = 2;
47
48     /**
49      * Constant defined for the primitive built-in simple tpyes.
50      * see <a HREF='http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes'>
51      * XML Schema Part 2: Datatypes </a>
52      */

53     /** "string" type */
54     public static final short PRIMITIVE_STRING = 1;
55     /** "boolean" type */
56     public static final short PRIMITIVE_BOOLEAN = 2;
57     /** "decimal" type */
58     public static final short PRIMITIVE_DECIMAL = 3;
59     /** "float" type */
60     public static final short PRIMITIVE_FLOAT = 4;
61     /** "double" type */
62     public static final short PRIMITIVE_DOUBLE = 5;
63     /** "duration" type */
64     public static final short PRIMITIVE_DURATION = 6;
65     /** "dataTime" type */
66     public static final short PRIMITIVE_DATETIME = 7;
67     /** "time" type */
68     public static final short PRIMITIVE_TIME = 8;
69     /** "date" type */
70     public static final short PRIMITIVE_DATE = 9;
71     /** "gYearMonth" type */
72     public static final short PRIMITIVE_GYEARMONTH = 10;
73     /** "gYear" type */
74     public static final short PRIMITIVE_GYEAR = 11;
75     /** "gMonthDay" type */
76     public static final short PRIMITIVE_GMONTHDAY = 12;
77     /** "gDay" type */
78     public static final short PRIMITIVE_GDAY = 13;
79     /** "gMonth" type */
80     public static final short PRIMITIVE_GMONTH = 14;
81     /** "hexBinary" type */
82     public static final short PRIMITIVE_HEXBINARY = 15;
83     /** "base64Binary" type */
84     public static final short PRIMITIVE_BASE64BINARY = 16;
85     /** "anyURI" type */
86     public static final short PRIMITIVE_ANYURI = 17;
87     /** "QName" type */
88     public static final short PRIMITIVE_QNAME = 18;
89     /** "precisionDecimal" type */
90     public static final short PRIMITIVE_PRECISIONDECIMAL = 19;
91     /** "NOTATION" type */
92     public static final short PRIMITIVE_NOTATION = 20;
93
94     /**
95      * return an ID representing the built-in primitive base type.
96      * REVISIT: This method is (currently) for internal use only.
97      * the constants returned from this method are not finalized yet.
98      * the names and values might change in the further.
99      *
100      * @return an ID representing the built-in primitive base type
101      */

102     public short getPrimitiveKind();
103
104     /**
105      * validate a given string against this simple type.
106      *
107      * @param content the string value that needs to be validated
108      * @param context the validation context
109      * @param validatedInfo used to store validation result
110      *
111      * @return the actual value (QName, Boolean) of the string value
112      */

113     public Object JavaDoc validate(String JavaDoc content, ValidationContext context, ValidatedInfo validatedInfo)
114         throws InvalidDatatypeValueException;
115
116     /**
117      * validate a given string value, represented by content.toString().
118      * note that if content is a StringBuffer, for performance reasons,
119      * it's possible that the content of the string buffer is modified.
120      *
121      * @param content the string value that needs to be validated
122      * @param context the validation context
123      * @param validatedInfo used to store validation result
124      *
125      * @return the actual value (QName, Boolean) of the string value
126      */

127     public Object JavaDoc validate(Object JavaDoc content, ValidationContext context, ValidatedInfo validatedInfo)
128         throws InvalidDatatypeValueException;
129
130     /**
131      * Validate an actual value against this simple type.
132      *
133      * @param context the validation context
134      * @param validatedInfo used to provide the actual value and member types
135      * @exception InvalidDatatypeValueException exception for invalid values.
136      */

137     public void validate(ValidationContext context, ValidatedInfo validatedInfo)
138         throws InvalidDatatypeValueException;
139
140     /**
141      * If this type is created from restriction, then some facets can be applied
142      * to the simple type. <code>XSFacets</code> is used to pass the value of
143      * different facets.
144      *
145      * @param facets the value of all the facets
146      * @param presentFacet bit combination value of the costraining facet
147      * constants which are present.
148      * @param fixedFacet bit combination value of the costraining facet
149      * constants which are fixed.
150      * @param context the validation context
151      * @exception InvalidDatatypeFacetException exception for invalid facet values.
152      */

153     public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
154         throws InvalidDatatypeFacetException;
155
156     /**
157      * Check whether two actual values are equal.
158      *
159      * @param value1 the first value
160      * @param value2 the second value
161      * @return true if the two value are equal
162      */

163     public boolean isEqual(Object JavaDoc value1, Object JavaDoc value2);
164
165     /**
166      * Check the order of the two actual values. (May not be supported by all
167      * simple types.
168      * REVISIT: Andy believes that a compare() method is necessary.
169      * I don't see the necessity for schema (the only place where we
170      * need to compare two values is to check min/maxIn/Exclusive
171      * facets, but we only need a private method for this case.)
172      * But Andy thinks XPATH potentially needs this compare() method.
173      *
174      * @param value1 the first value
175      * @prarm value2 the second value
176      * @return > 0 if value1 > value2
177      * = 0 if value1 == value2
178      * < = if value1 < value2
179      */

180     //public short compare(Object value1, Object value2);
181

182     /**
183      * Check whether this type is or is derived from ID.
184      * REVISIT: this method makes ID special, which is not a good design.
185      * but since ID is not a primitive, there doesn't seem to be a
186      * clean way of doing it except to define special method like this.
187      *
188      * @return whether this simple type is or is derived from ID.
189      */

190     public boolean isIDType();
191
192     /**
193      * Return the whitespace corresponding to this datatype.
194      *
195      * @return valid values are WS_PRESERVE, WS_REPLACE, WS_COLLAPSE.
196      * @exception DatatypeException
197      * union datatypes don't have whitespace facet associated with them
198      */

199     public short getWhitespace() throws DatatypeException;
200 }
201
Popular Tags