KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > impl > dv > XSSimpleType


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package com.sun.org.apache.xerces.internal.impl.dv;
59
60 import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition;
61
62 /**
63  * This interface <code>XSSimpleType</code> represents the simple type
64  * definition of schema component and defines methods to query the information
65  * contained.
66  * Any simple type (atomic, list or union) will implement this interface.
67  * It inherits from <code>XSTypeDecl</code>.
68  *
69  * @author Sandy Gao, IBM
70  *
71  * @version $Id: XSSimpleType.java,v 1.13 2003/11/11 20:14:58 sandygao Exp $
72  */

73 public interface XSSimpleType extends XSSimpleTypeDefinition {
74
75     /**
76      * constants defined for the values of 'whitespace' facet.
77      * see <a HREF='http://www.w3.org/TR/xmlschema-2/#dt-whiteSpace'> XML Schema
78      * Part 2: Datatypes </a>
79      */

80     /** preserve the white spaces */
81     public static final short WS_PRESERVE = 0;
82     /** replace the white spaces */
83     public static final short WS_REPLACE = 1;
84     /** collapse the white spaces */
85     public static final short WS_COLLAPSE = 2;
86
87     /**
88      * Constant defined for the primitive built-in simple tpyes.
89      * see <a HREF='http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes'>
90      * XML Schema Part 2: Datatypes </a>
91      */

92     /** "string" type */
93     public static final short PRIMITIVE_STRING = 1;
94     /** "boolean" type */
95     public static final short PRIMITIVE_BOOLEAN = 2;
96     /** "decimal" type */
97     public static final short PRIMITIVE_DECIMAL = 3;
98     /** "float" type */
99     public static final short PRIMITIVE_FLOAT = 4;
100     /** "double" type */
101     public static final short PRIMITIVE_DOUBLE = 5;
102     /** "duration" type */
103     public static final short PRIMITIVE_DURATION = 6;
104     /** "dataTime" type */
105     public static final short PRIMITIVE_DATETIME = 7;
106     /** "time" type */
107     public static final short PRIMITIVE_TIME = 8;
108     /** "date" type */
109     public static final short PRIMITIVE_DATE = 9;
110     /** "gYearMonth" type */
111     public static final short PRIMITIVE_GYEARMONTH = 10;
112     /** "gYear" type */
113     public static final short PRIMITIVE_GYEAR = 11;
114     /** "gMonthDay" type */
115     public static final short PRIMITIVE_GMONTHDAY = 12;
116     /** "gDay" type */
117     public static final short PRIMITIVE_GDAY = 13;
118     /** "gMonth" type */
119     public static final short PRIMITIVE_GMONTH = 14;
120     /** "hexBinary" type */
121     public static final short PRIMITIVE_HEXBINARY = 15;
122     /** "base64Binary" type */
123     public static final short PRIMITIVE_BASE64BINARY = 16;
124     /** "anyURI" type */
125     public static final short PRIMITIVE_ANYURI = 17;
126     /** "QName" type */
127     public static final short PRIMITIVE_QNAME = 18;
128     /** "NOTATION" type */
129     public static final short PRIMITIVE_NOTATION = 19;
130
131     /**
132      * return an ID representing the built-in primitive base type.
133      * REVISIT: This method is (currently) for internal use only.
134      * the constants returned from this method are not finalized yet.
135      * the names and values might change in the further.
136      *
137      * @return an ID representing the built-in primitive base type
138      */

139     public short getPrimitiveKind();
140
141     /**
142      * validate a given string against this simple type.
143      *
144      * @param content the string value that needs to be validated
145      * @param context the validation context
146      * @param validatedInfo used to store validation result
147      *
148      * @return the actual value (QName, Boolean) of the string value
149      */

150     public Object JavaDoc validate(String JavaDoc content, ValidationContext context, ValidatedInfo validatedInfo)
151         throws InvalidDatatypeValueException;
152
153     /**
154      * validate a given string value, represented by content.toString().
155      * note that if content is a StringBuffer, for performance reasons,
156      * it's possible that the content of the string buffer is modified.
157      *
158      * @param content the string value that needs to be validated
159      * @param context the validation context
160      * @param validatedInfo used to store validation result
161      *
162      * @return the actual value (QName, Boolean) of the string value
163      */

164     public Object JavaDoc validate(Object JavaDoc content, ValidationContext context, ValidatedInfo validatedInfo)
165         throws InvalidDatatypeValueException;
166
167     /**
168      * validate an actual value against this simple type.
169      *
170      * @param value the actual value that needs to be validated
171      * @param context the validation context
172      * @param validatedInfo used to provide the actual value and member types
173      * @exception InvalidDatatypeValueException exception for invalid values.
174      */

175     public void validate(ValidationContext context, ValidatedInfo validatedInfo)
176         throws InvalidDatatypeValueException;
177
178     /**
179      * If this type is created from restriction, then some facets can be applied
180      * to the simple type. <code>XSFacets</code> is used to pass the value of
181      * different facets.
182      *
183      * @param facets the value of all the facets
184      * @param presentFacets bit combination value of the costraining facet
185      * constants which are present.
186      * @param fixedFacets bit combination value of the costraining facet
187      * constants which are fixed.
188      * @param ValidationContext the validation context
189      * @exception InvalidDatatypeFacetException exception for invalid facet values.
190      */

191     public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
192         throws InvalidDatatypeFacetException;
193
194     /**
195      * Check whether two actual values are equal.
196      *
197      * @param value1 the first value
198      * @param value2 the second value
199      * @return true if the two value are equal
200      */

201     public boolean isEqual(Object JavaDoc value1, Object JavaDoc value2);
202
203     /**
204      * Check the order of the two actual values. (May not be supported by all
205      * simple types.
206      * REVISIT: Andy believes that a compare() method is necessary.
207      * I don't see the necessity for schema (the only place where we
208      * need to compare two values is to check min/maxIn/Exclusive
209      * facets, but we only need a private method for this case.)
210      * But Andy thinks XPATH potentially needs this compare() method.
211      *
212      * @param value1 the first value
213      * @prarm value2 the second value
214      * @return > 0 if value1 > value2
215      * = 0 if value1 == value2
216      * < = if value1 < value2
217      */

218     //public short compare(Object value1, Object value2);
219

220     /**
221      * Check whether this type is or is derived from ID.
222      * REVISIT: this method makes ID special, which is not a good design.
223      * but since ID is not a primitive, there doesn't seem to be a
224      * clean way of doing it except to define special method like this.
225      *
226      * @return whether this simple type is or is derived from ID.
227      */

228     public boolean isIDType();
229
230     /**
231      * Return the whitespace corresponding to this datatype.
232      *
233      * @return valid values are WS_PRESERVE, WS_REPLACE, WS_COLLAPSE.
234      * @exception DatatypeException
235      * union datatypes don't have whitespace facet associated with them
236      */

237     public short getWhitespace() throws DatatypeException;
238 }
239
Popular Tags