1. // $Id: DatatypeConstants.java,v 1.2.2.1 2004/04/28 23:12:57 jsuttor Exp $
  2. /*
  3. * @(#)DatatypeConstants.java 1.2 04/07/26
  4. *
  5. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  6. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  7. */
  8. package javax.xml.datatype;
  9. import javax.xml.XMLConstants;
  10. import javax.xml.namespace.QName;
  11. /**
  12. * <p>Utility class to contain basic Datatype values as constants.</p>
  13. *
  14. * @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a>
  15. * @version $Revision: 1.2.2.1 $, $Date: 2004/04/28 23:12:57 $
  16. * @since 1.5
  17. */
  18. public final class DatatypeConstants {
  19. /**
  20. * <p>Private constructor to prevent instantiation.</p>
  21. */
  22. private DatatypeConstants() {
  23. }
  24. /**
  25. * Value for first month of year.
  26. */
  27. public static final int JANUARY = 1;
  28. /**
  29. * Value for second month of year.
  30. */
  31. public static final int FEBRUARY = 2;
  32. /**
  33. * Value for third month of year.
  34. */
  35. public static final int MARCH = 3;
  36. /**
  37. * Value for fourth month of year.
  38. */
  39. public static final int APRIL = 4;
  40. /**
  41. * Value for fifth month of year.
  42. */
  43. public static final int MAY = 5;
  44. /**
  45. * Value for sixth month of year.
  46. */
  47. public static final int JUNE = 6;
  48. /**
  49. * Value for seventh month of year.
  50. */
  51. public static final int JULY = 7;
  52. /**
  53. * Value for eighth month of year.
  54. */
  55. public static final int AUGUST = 8;
  56. /**
  57. * Value for ninth month of year.
  58. */
  59. public static final int SEPTEMBER = 9;
  60. /**
  61. * Value for tenth month of year.
  62. */
  63. public static final int OCTOBER = 10;
  64. /**
  65. * Value for eleven month of year.
  66. */
  67. public static final int NOVEMBER = 11;
  68. /**
  69. * Value for twelve month of year.
  70. */
  71. public static final int DECEMBER = 12;
  72. /**
  73. * <p>Comparison result.</p>
  74. */
  75. public static final int LESSER = -1;
  76. /**
  77. * <p>Comparison result.</p>
  78. */
  79. public static final int EQUAL = 0;
  80. /**
  81. * <p>Comparison result.</p>
  82. */
  83. public static final int GREATER = 1;
  84. /**
  85. * <p>Comparison result.</p>
  86. */
  87. public static final int INDETERMINATE = 2;
  88. /**
  89. * Designation that an "int" field is not set.
  90. */
  91. public static final int FIELD_UNDEFINED = Integer.MIN_VALUE;
  92. /**
  93. * <p>A constant that represents the years field.</p>
  94. */
  95. public static final Field YEARS = new Field("YEARS", 0);
  96. /**
  97. * <p>A constant that represents the months field.</p>
  98. */
  99. public static final Field MONTHS = new Field("MONTHS", 1);
  100. /**
  101. * <p>A constant that represents the days field.</p>
  102. */
  103. public static final Field DAYS = new Field("DAYS", 2);
  104. /**
  105. * <p>A constant that represents the hours field.</p>
  106. */
  107. public static final Field HOURS = new Field("HOURS", 3);
  108. /**
  109. * <p>A constant that represents the minutes field.</p>
  110. */
  111. public static final Field MINUTES = new Field("MINUTES", 4);
  112. /**
  113. * <p>A constant that represents the seconds field.</p>
  114. */
  115. public static final Field SECONDS = new Field("SECONDS", 5);
  116. /**
  117. * Type-safe enum class that represents six fields
  118. * of the {@link Duration} class.
  119. */
  120. public static final class Field {
  121. /**
  122. * <p><code>String</code> representation of <ode>Field</code>.</p>
  123. */
  124. private final String str;
  125. /**
  126. * <p>Unique id of the field.</p>
  127. *
  128. * <p>This value allows the {@link Duration} class to use switch
  129. * statements to process fields.</p>
  130. */
  131. private final int id;
  132. /**
  133. * <p>Construct a <code>Field</code> with specified values.</p>
  134. * @param str <code>String</code> representation of <code>Field</code>
  135. * @param id <code>int</code> representation of <code>Field</code>
  136. */
  137. private Field(final String str, final int id) {
  138. this.str = str;
  139. this.id = id;
  140. }
  141. /**
  142. * Returns a field name in English. This method
  143. * is intended to be used for debugging/diagnosis
  144. * and not for display to end-users.
  145. *
  146. * @return
  147. * a non-null valid String constant.
  148. */
  149. public String toString() { return str; }
  150. /**
  151. * <p>Get id of this Field.</p>
  152. *
  153. * @return Id of field.
  154. */
  155. public int getId() {
  156. return id;
  157. }
  158. }
  159. /**
  160. * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>dateTime</code>.</p>
  161. */
  162. public static final QName DATETIME = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "dateTime");
  163. /**
  164. * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>time</code>.</p>
  165. */
  166. public static final QName TIME = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "time");
  167. /**
  168. * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>date</code>.</p>
  169. */
  170. public static final QName DATE = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "date");
  171. /**
  172. * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gYearMonth</code>.</p>
  173. */
  174. public static final QName GYEARMONTH = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gYearMonth");
  175. /**
  176. * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gMonthDay</code>.</p>
  177. */
  178. public static final QName GMONTHDAY = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gMonthDay");
  179. /**
  180. * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gYear</code>.</p>
  181. */
  182. public static final QName GYEAR = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gYear");
  183. /**
  184. * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gMonth</code>.</p>
  185. */
  186. public static final QName GMONTH = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gMonth");
  187. /**
  188. * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gDay</code>.</p>
  189. */
  190. public static final QName GDAY = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gDay");
  191. /**
  192. * <p>Fully qualified name for W3C XML Schema datatype <code>duration</code>.</p>
  193. */
  194. public static final QName DURATION = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "duration");
  195. /**
  196. * <p>Fully qualified name for XQuery 1.0 and XPath 2.0 datatype <code>dayTimeDuration</code>.</p>
  197. */
  198. public static final QName DURATION_DAYTIME = new QName(XMLConstants.W3C_XPATH_DATATYPE_NS_URI, "dayTimeDuration");
  199. /**
  200. * <p>Fully qualified name for XQuery 1.0 and XPath 2.0 datatype <code>yearMonthDuration</code>.</p>
  201. */
  202. public static final QName DURATION_YEARMONTH = new QName(XMLConstants.W3C_XPATH_DATATYPE_NS_URI, "yearMonthDuration");
  203. /**
  204. * W3C XML Schema max timezone offset is -14:00. Zone offset is in minutes.
  205. */
  206. public static final int MAX_TIMEZONE_OFFSET = -14 * 60;
  207. /**
  208. * W3C XML Schema min timezone offset is +14:00. Zone offset is in minutes.
  209. */
  210. public static final int MIN_TIMEZONE_OFFSET = 14 * 60;
  211. }