1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 // $Id: DatatypeConstants.java 446598 2006-09-15 12:55:40Z jeremias $ 19 20 package javax.xml.datatype; 21 22 import javax.xml.XMLConstants; 23 import javax.xml.namespace.QName; 24 25 /** 26 * <p>Utility class to contain basic Datatype values as constants.</p> 27 * 28 * @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a> 29 * @version $Revision: 446598 $, $Date: 2006-09-15 05:55:40 -0700 (Fri, 15 Sep 2006) $ 30 * @since 1.5 31 */ 32 33 public final class DatatypeConstants { 34 35 /** 36 * <p>Private constructor to prevent instantiation.</p> 37 */ DatatypeConstants()38 private DatatypeConstants() { 39 } 40 41 /** 42 * Value for first month of year. 43 */ 44 public static final int JANUARY = 1; 45 46 /** 47 * Value for second month of year. 48 */ 49 public static final int FEBRUARY = 2; 50 51 /** 52 * Value for third month of year. 53 */ 54 public static final int MARCH = 3; 55 56 /** 57 * Value for fourth month of year. 58 */ 59 public static final int APRIL = 4; 60 61 /** 62 * Value for fifth month of year. 63 */ 64 public static final int MAY = 5; 65 66 /** 67 * Value for sixth month of year. 68 */ 69 public static final int JUNE = 6; 70 71 /** 72 * Value for seventh month of year. 73 */ 74 public static final int JULY = 7; 75 76 /** 77 * Value for eighth month of year. 78 */ 79 public static final int AUGUST = 8; 80 81 /** 82 * Value for ninth month of year. 83 */ 84 public static final int SEPTEMBER = 9; 85 86 /** 87 * Value for tenth month of year. 88 */ 89 public static final int OCTOBER = 10; 90 91 /** 92 * Value for eleven month of year. 93 */ 94 public static final int NOVEMBER = 11; 95 96 /** 97 * Value for twelve month of year. 98 */ 99 public static final int DECEMBER = 12; 100 101 /** 102 * <p>Comparison result.</p> 103 */ 104 public static final int LESSER = -1; 105 106 /** 107 * <p>Comparison result.</p> 108 */ 109 public static final int EQUAL = 0; 110 111 /** 112 * <p>Comparison result.</p> 113 */ 114 public static final int GREATER = 1; 115 116 /** 117 * <p>Comparison result.</p> 118 */ 119 public static final int INDETERMINATE = 2; 120 121 /** 122 * Designation that an "int" field is not set. 123 */ 124 public static final int FIELD_UNDEFINED = Integer.MIN_VALUE; 125 126 /** 127 * <p>A constant that represents the years field.</p> 128 */ 129 public static final Field YEARS = new Field("YEARS", 0); 130 131 /** 132 * <p>A constant that represents the months field.</p> 133 */ 134 public static final Field MONTHS = new Field("MONTHS", 1); 135 136 /** 137 * <p>A constant that represents the days field.</p> 138 */ 139 public static final Field DAYS = new Field("DAYS", 2); 140 141 /** 142 * <p>A constant that represents the hours field.</p> 143 */ 144 public static final Field HOURS = new Field("HOURS", 3); 145 146 /** 147 * <p>A constant that represents the minutes field.</p> 148 */ 149 public static final Field MINUTES = new Field("MINUTES", 4); 150 151 /** 152 * <p>A constant that represents the seconds field.</p> 153 */ 154 public static final Field SECONDS = new Field("SECONDS", 5); 155 156 /** 157 * Type-safe enum class that represents six fields 158 * of the {@link Duration} class. 159 */ 160 public static final class Field { 161 162 /** 163 * <p><code>String</code> representation of <ode>Field</code>.</p> 164 */ 165 private final String str; 166 /** 167 * <p>Unique id of the field.</p> 168 * 169 * <p>This value allows the {@link Duration} class to use switch 170 * statements to process fields.</p> 171 */ 172 private final int id; 173 174 /** 175 * <p>Construct a <code>Field</code> with specified values.</p> 176 * @param str <code>String</code> representation of <code>Field</code> 177 * @param id <code>int</code> representation of <code>Field</code> 178 */ Field(final String str, final int id)179 private Field(final String str, final int id) { 180 this.str = str; 181 this.id = id; 182 } 183 /** 184 * Returns a field name in English. This method 185 * is intended to be used for debugging/diagnosis 186 * and not for display to end-users. 187 * 188 * @return 189 * a non-null valid String constant. 190 */ toString()191 public String toString() { return str; } 192 193 /** 194 * <p>Get id of this Field.</p> 195 * 196 * @return Id of field. 197 */ getId()198 public int getId() { 199 return id; 200 } 201 } 202 203 /** 204 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>dateTime</code>.</p> 205 */ 206 public static final QName DATETIME = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "dateTime"); 207 208 /** 209 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>time</code>.</p> 210 */ 211 public static final QName TIME = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "time"); 212 213 /** 214 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>date</code>.</p> 215 */ 216 public static final QName DATE = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "date"); 217 218 /** 219 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gYearMonth</code>.</p> 220 */ 221 public static final QName GYEARMONTH = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gYearMonth"); 222 223 /** 224 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gMonthDay</code>.</p> 225 */ 226 public static final QName GMONTHDAY = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gMonthDay"); 227 228 /** 229 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gYear</code>.</p> 230 */ 231 public static final QName GYEAR = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gYear"); 232 233 /** 234 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gMonth</code>.</p> 235 */ 236 public static final QName GMONTH = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gMonth"); 237 238 /** 239 * <p>Fully qualified name for W3C XML Schema 1.0 datatype <code>gDay</code>.</p> 240 */ 241 public static final QName GDAY = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "gDay"); 242 243 /** 244 * <p>Fully qualified name for W3C XML Schema datatype <code>duration</code>.</p> 245 */ 246 public static final QName DURATION = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "duration"); 247 248 /** 249 * <p>Fully qualified name for XQuery 1.0 and XPath 2.0 datatype <code>dayTimeDuration</code>.</p> 250 */ 251 public static final QName DURATION_DAYTIME = new QName(XMLConstants.W3C_XPATH_DATATYPE_NS_URI, "dayTimeDuration"); 252 253 /** 254 * <p>Fully qualified name for XQuery 1.0 and XPath 2.0 datatype <code>yearMonthDuration</code>.</p> 255 */ 256 public static final QName DURATION_YEARMONTH = new QName(XMLConstants.W3C_XPATH_DATATYPE_NS_URI, "yearMonthDuration"); 257 258 /** 259 * W3C XML Schema max timezone offset is -14:00. Zone offset is in minutes. 260 */ 261 public static final int MAX_TIMEZONE_OFFSET = -14 * 60; 262 263 /** 264 * W3C XML Schema min timezone offset is +14:00. Zone offset is in minutes. 265 */ 266 public static final int MIN_TIMEZONE_OFFSET = 14 * 60; 267 268 } 269