1 /* 2 * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.xml.datatype; 27 28 import javax.xml.XMLConstants; 29 import javax.xml.namespace.QName; 30 31 /** 32 * <p>Utility class to contain basic Datatype values as constants.</p> 33 * 34 * @author Jeff Suttor 35 * @since 1.5 36 */ 37 38 public final class DatatypeConstants { 39 40 /** 41 * <p>Private constructor to prevent instantiation.</p> 42 */ DatatypeConstants()43 private DatatypeConstants() { 44 } 45 46 /** 47 * Value for first month of year. 48 */ 49 public static final int JANUARY = 1; 50 51 /** 52 * Value for second month of year. 53 */ 54 public static final int FEBRUARY = 2; 55 56 /** 57 * Value for third month of year. 58 */ 59 public static final int MARCH = 3; 60 61 /** 62 * Value for fourth month of year. 63 */ 64 public static final int APRIL = 4; 65 66 /** 67 * Value for fifth month of year. 68 */ 69 public static final int MAY = 5; 70 71 /** 72 * Value for sixth month of year. 73 */ 74 public static final int JUNE = 6; 75 76 /** 77 * Value for seventh month of year. 78 */ 79 public static final int JULY = 7; 80 81 /** 82 * Value for eighth month of year. 83 */ 84 public static final int AUGUST = 8; 85 86 /** 87 * Value for ninth month of year. 88 */ 89 public static final int SEPTEMBER = 9; 90 91 /** 92 * Value for tenth month of year. 93 */ 94 public static final int OCTOBER = 10; 95 96 /** 97 * Value for eleven month of year. 98 */ 99 public static final int NOVEMBER = 11; 100 101 /** 102 * Value for twelve month of year. 103 */ 104 public static final int DECEMBER = 12; 105 106 /** 107 * <p>Comparison result.</p> 108 */ 109 public static final int LESSER = -1; 110 111 /** 112 * <p>Comparison result.</p> 113 */ 114 public static final int EQUAL = 0; 115 116 /** 117 * <p>Comparison result.</p> 118 */ 119 public static final int GREATER = 1; 120 121 /** 122 * <p>Comparison result.</p> 123 */ 124 public static final int INDETERMINATE = 2; 125 126 /** 127 * Designation that an "int" field is not set. 128 */ 129 public static final int FIELD_UNDEFINED = Integer.MIN_VALUE; 130 131 /** 132 * <p>A constant that represents the years field.</p> 133 */ 134 public static final Field YEARS = new Field("YEARS", 0); 135 136 /** 137 * <p>A constant that represents the months field.</p> 138 */ 139 public static final Field MONTHS = new Field("MONTHS", 1); 140 141 /** 142 * <p>A constant that represents the days field.</p> 143 */ 144 public static final Field DAYS = new Field("DAYS", 2); 145 146 /** 147 * <p>A constant that represents the hours field.</p> 148 */ 149 public static final Field HOURS = new Field("HOURS", 3); 150 151 /** 152 * <p>A constant that represents the minutes field.</p> 153 */ 154 public static final Field MINUTES = new Field("MINUTES", 4); 155 156 /** 157 * <p>A constant that represents the seconds field.</p> 158 */ 159 public static final Field SECONDS = new Field("SECONDS", 5); 160 161 /** 162 * Type-safe enum class that represents six fields 163 * of the {@link Duration} class. 164 * @since 1.5 165 */ 166 public static final class Field { 167 168 /** 169 * <p><code>String</code> representation of <code>Field</code>.</p> 170 */ 171 private final String str; 172 /** 173 * <p>Unique id of the field.</p> 174 * 175 * <p>This value allows the {@link Duration} class to use switch 176 * statements to process fields.</p> 177 */ 178 private final int id; 179 180 /** 181 * <p>Construct a <code>Field</code> with specified values.</p> 182 * @param str <code>String</code> representation of <code>Field</code> 183 * @param id <code>int</code> representation of <code>Field</code> 184 */ Field(final String str, final int id)185 private Field(final String str, final int id) { 186 this.str = str; 187 this.id = id; 188 } 189 /** 190 * Returns a field name in English. This method 191 * is intended to be used for debugging/diagnosis 192 * and not for display to end-users. 193 * 194 * @return 195 * a non-null valid String constant. 196 */ toString()197 public String toString() { return str; } 198 199 /** 200 * <p>Get id of this Field.</p> 201 * 202 * @return Id of field. 203 */ getId()204 public int getId() { 205 return id; 206 } 207 } 208 209 /** 210 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>dateTime</code>.</p> 211 */ 212 public static final QName DATETIME = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "dateTime"); 213 214 /** 215 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>time</code>.</p> 216 */ 217 public static final QName TIME = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "time"); 218 219 /** 220 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>date</code>.</p> 221 */ 222 public static final QName DATE = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "date"); 223 224 /** 225 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gYearMonth</code>.</p> 226 */ 227 public static final QName GYEARMONTH = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gYearMonth"); 228 229 /** 230 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gMonthDay</code>.</p> 231 */ 232 public static final QName GMONTHDAY = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gMonthDay"); 233 234 /** 235 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gYear</code>.</p> 236 */ 237 public static final QName GYEAR = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gYear"); 238 239 /** 240 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gMonth</code>.</p> 241 */ 242 public static final QName GMONTH = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gMonth"); 243 244 /** 245 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gDay</code>.</p> 246 */ 247 public static final QName GDAY = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gDay"); 248 249 /** 250 * <p>Fully qualified name for W3C XML Schema datatype <code>duration</code>.</p> 251 */ 252 public static final QName DURATION = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "duration"); 253 254 /** 255 * <p>Fully qualified name for XQuery 1.0 and XPath 2.0 datatype <code>dayTimeDuration</code>.</p> 256 */ 257 public static final QName DURATION_DAYTIME = new QName(XMLConstants.W3C_XPATH_DATATYPE_NS_URI, "dayTimeDuration"); 258 259 /** 260 * <p>Fully qualified name for XQuery 1.0 and XPath 2.0 datatype <code>yearMonthDuration</code>.</p> 261 */ 262 public static final QName DURATION_YEARMONTH = new QName(XMLConstants.W3C_XPATH_DATATYPE_NS_URI, "yearMonthDuration"); 263 264 /** 265 * W3C XML Schema max timezone offset is -14:00. Zone offset is in minutes. 266 */ 267 public static final int MAX_TIMEZONE_OFFSET = -14 * 60; 268 269 /** 270 * W3C XML Schema min timezone offset is +14:00. Zone offset is in minutes. 271 */ 272 public static final int MIN_TIMEZONE_OFFSET = 14 * 60; 273 274 } 275