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. package com.sun.org.apache.xerces.internal.impl.dv;
  58. import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition;
  59. /**
  60. * This interface <code>XSSimpleType</code> represents the simple type
  61. * definition of schema component and defines methods to query the information
  62. * contained.
  63. * Any simple type (atomic, list or union) will implement this interface.
  64. * It inherits from <code>XSTypeDecl</code>.
  65. *
  66. * @author Sandy Gao, IBM
  67. *
  68. * @version $Id: XSSimpleType.java,v 1.13 2003/11/11 20:14:58 sandygao Exp $
  69. */
  70. public interface XSSimpleType extends XSSimpleTypeDefinition {
  71. /**
  72. * constants defined for the values of 'whitespace' facet.
  73. * see <a href='http://www.w3.org/TR/xmlschema-2/#dt-whiteSpace'> XML Schema
  74. * Part 2: Datatypes </a>
  75. */
  76. /** preserve the white spaces */
  77. public static final short WS_PRESERVE = 0;
  78. /** replace the white spaces */
  79. public static final short WS_REPLACE = 1;
  80. /** collapse the white spaces */
  81. public static final short WS_COLLAPSE = 2;
  82. /**
  83. * Constant defined for the primitive built-in simple tpyes.
  84. * see <a href='http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes'>
  85. * XML Schema Part 2: Datatypes </a>
  86. */
  87. /** "string" type */
  88. public static final short PRIMITIVE_STRING = 1;
  89. /** "boolean" type */
  90. public static final short PRIMITIVE_BOOLEAN = 2;
  91. /** "decimal" type */
  92. public static final short PRIMITIVE_DECIMAL = 3;
  93. /** "float" type */
  94. public static final short PRIMITIVE_FLOAT = 4;
  95. /** "double" type */
  96. public static final short PRIMITIVE_DOUBLE = 5;
  97. /** "duration" type */
  98. public static final short PRIMITIVE_DURATION = 6;
  99. /** "dataTime" type */
  100. public static final short PRIMITIVE_DATETIME = 7;
  101. /** "time" type */
  102. public static final short PRIMITIVE_TIME = 8;
  103. /** "date" type */
  104. public static final short PRIMITIVE_DATE = 9;
  105. /** "gYearMonth" type */
  106. public static final short PRIMITIVE_GYEARMONTH = 10;
  107. /** "gYear" type */
  108. public static final short PRIMITIVE_GYEAR = 11;
  109. /** "gMonthDay" type */
  110. public static final short PRIMITIVE_GMONTHDAY = 12;
  111. /** "gDay" type */
  112. public static final short PRIMITIVE_GDAY = 13;
  113. /** "gMonth" type */
  114. public static final short PRIMITIVE_GMONTH = 14;
  115. /** "hexBinary" type */
  116. public static final short PRIMITIVE_HEXBINARY = 15;
  117. /** "base64Binary" type */
  118. public static final short PRIMITIVE_BASE64BINARY = 16;
  119. /** "anyURI" type */
  120. public static final short PRIMITIVE_ANYURI = 17;
  121. /** "QName" type */
  122. public static final short PRIMITIVE_QNAME = 18;
  123. /** "NOTATION" type */
  124. public static final short PRIMITIVE_NOTATION = 19;
  125. /**
  126. * return an ID representing the built-in primitive base type.
  127. * REVISIT: This method is (currently) for internal use only.
  128. * the constants returned from this method are not finalized yet.
  129. * the names and values might change in the further.
  130. *
  131. * @return an ID representing the built-in primitive base type
  132. */
  133. public short getPrimitiveKind();
  134. /**
  135. * validate a given string against this simple type.
  136. *
  137. * @param content the string value that needs to be validated
  138. * @param context the validation context
  139. * @param validatedInfo used to store validation result
  140. *
  141. * @return the actual value (QName, Boolean) of the string value
  142. */
  143. public Object validate(String content, ValidationContext context, ValidatedInfo validatedInfo)
  144. throws InvalidDatatypeValueException;
  145. /**
  146. * validate a given string value, represented by content.toString().
  147. * note that if content is a StringBuffer, for performance reasons,
  148. * it's possible that the content of the string buffer is modified.
  149. *
  150. * @param content the string value that needs to be validated
  151. * @param context the validation context
  152. * @param validatedInfo used to store validation result
  153. *
  154. * @return the actual value (QName, Boolean) of the string value
  155. */
  156. public Object validate(Object content, ValidationContext context, ValidatedInfo validatedInfo)
  157. throws InvalidDatatypeValueException;
  158. /**
  159. * validate an actual value against this simple type.
  160. *
  161. * @param value the actual value that needs to be validated
  162. * @param context the validation context
  163. * @param validatedInfo used to provide the actual value and member types
  164. * @exception InvalidDatatypeValueException exception for invalid values.
  165. */
  166. public void validate(ValidationContext context, ValidatedInfo validatedInfo)
  167. throws InvalidDatatypeValueException;
  168. /**
  169. * If this type is created from restriction, then some facets can be applied
  170. * to the simple type. <code>XSFacets</code> is used to pass the value of
  171. * different facets.
  172. *
  173. * @param facets the value of all the facets
  174. * @param presentFacets bit combination value of the costraining facet
  175. * constants which are present.
  176. * @param fixedFacets bit combination value of the costraining facet
  177. * constants which are fixed.
  178. * @param ValidationContext the validation context
  179. * @exception InvalidDatatypeFacetException exception for invalid facet values.
  180. */
  181. public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
  182. throws InvalidDatatypeFacetException;
  183. /**
  184. * Check whether two actual values are equal.
  185. *
  186. * @param value1 the first value
  187. * @param value2 the second value
  188. * @return true if the two value are equal
  189. */
  190. public boolean isEqual(Object value1, Object value2);
  191. /**
  192. * Check the order of the two actual values. (May not be supported by all
  193. * simple types.
  194. * REVISIT: Andy believes that a compare() method is necessary.
  195. * I don't see the necessity for schema (the only place where we
  196. * need to compare two values is to check min/maxIn/Exclusive
  197. * facets, but we only need a private method for this case.)
  198. * But Andy thinks XPATH potentially needs this compare() method.
  199. *
  200. * @param value1 the first value
  201. * @prarm value2 the second value
  202. * @return > 0 if value1 > value2
  203. * = 0 if value1 == value2
  204. * < = if value1 < value2
  205. */
  206. //public short compare(Object value1, Object value2);
  207. /**
  208. * Check whether this type is or is derived from ID.
  209. * REVISIT: this method makes ID special, which is not a good design.
  210. * but since ID is not a primitive, there doesn't seem to be a
  211. * clean way of doing it except to define special method like this.
  212. *
  213. * @return whether this simple type is or is derived from ID.
  214. */
  215. public boolean isIDType();
  216. /**
  217. * Return the whitespace corresponding to this datatype.
  218. *
  219. * @return valid values are WS_PRESERVE, WS_REPLACE, WS_COLLAPSE.
  220. * @exception DatatypeException
  221. * union datatypes don't have whitespace facet associated with them
  222. */
  223. public short getWhitespace() throws DatatypeException;
  224. }