author | joehw |
Thu, 21 Dec 2017 17:08:05 -0800 | |
changeset 48412 | d4412e380f6b |
parent 47216 | 71c04702a3d5 |
child 54342 | 07212a29787a |
permissions | -rw-r--r-- |
12005 | 1 |
/* |
45261 | 2 |
* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. |
12005 | 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 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
28 |
import java.math.BigDecimal; |
12005 | 29 |
import java.math.BigInteger; |
30 |
import java.util.GregorianCalendar; |
|
31 |
import java.util.regex.Matcher; |
|
32 |
import java.util.regex.Pattern; |
|
42390
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
33 |
import com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl; |
12005 | 34 |
|
35 |
/** |
|
29999 | 36 |
* Factory that creates new {@code javax.xml.datatype} {@code Object}s that map XML to/from Java {@code Object}s. |
46069 | 37 |
* <p id="DatatypeFactory.newInstance"> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
38 |
* A new instance of the {@code DatatypeFactory} is created through the {@link #newInstance()} method |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
39 |
* that uses the following implementation resolution mechanisms to determine an implementation: |
12005 | 40 |
* <ol> |
41 |
* <li> |
|
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
42 |
* If the system property specified by {@link #DATATYPEFACTORY_PROPERTY}, "{@code javax.xml.datatype.DatatypeFactory}", |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
43 |
* exists, a class with the name of the property value is instantiated. |
12005 | 44 |
* Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}. |
45 |
* </li> |
|
46 |
* <li> |
|
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
47 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
48 |
* Use the configuration file "jaxp.properties". The file is in standard |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
49 |
* {@link java.util.Properties} format and typically located in the |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
50 |
* {@code conf} directory of the Java installation. It contains the fully qualified |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
51 |
* name of the implementation class with the key being the system property |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
52 |
* defined above. |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
53 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
54 |
* The jaxp.properties file is read only once by the JAXP implementation |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
55 |
* and its values are then cached for future use. If the file does not exist |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
56 |
* when the first attempt is made to read from it, no further attempts are |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
57 |
* made to check for its existence. It is not possible to change the value |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
58 |
* of any property in jaxp.properties after it has been read for the first time. |
12005 | 59 |
* </li> |
60 |
* <li> |
|
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
61 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
62 |
* Use the service-provider loading facility, defined by the {@link java.util.ServiceLoader} class, to attempt |
20581
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
63 |
* to locate and load an implementation of the service using the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
64 |
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}: |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
65 |
* the service-provider loading facility will use the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
66 |
* java.lang.Thread#getContextClassLoader() current thread's context class loader} |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
67 |
* to attempt to load the service. If the context class |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
68 |
* loader is null, the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
69 |
* ClassLoader#getSystemClassLoader() system class loader} will be used. |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
70 |
* <p> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
71 |
* In case of {@link java.util.ServiceConfigurationError service |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
72 |
* configuration error}, a {@link javax.xml.datatype.DatatypeConfigurationException} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
73 |
* will be thrown. |
12005 | 74 |
* </li> |
75 |
* <li> |
|
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
76 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
77 |
* The final mechanism is to attempt to instantiate the {@code Class} specified by |
12005 | 78 |
* {@link #DATATYPEFACTORY_IMPLEMENTATION_CLASS}. |
79 |
* Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}. |
|
80 |
* </li> |
|
81 |
* </ol> |
|
82 |
* |
|
48412 | 83 |
* @author Joseph Fialli |
84 |
* @author Jeff Suttor |
|
85 |
* @author Neeraj Bajaj |
|
12005 | 86 |
* |
87 |
* @since 1.5 |
|
88 |
*/ |
|
89 |
public abstract class DatatypeFactory { |
|
90 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
91 |
/** |
29999 | 92 |
* Default property name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
93 |
* |
29999 | 94 |
* <p>Default value is {@code javax.xml.datatype.DatatypeFactory}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
95 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
96 |
public static final String DATATYPEFACTORY_PROPERTY = |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
97 |
// We use a String constant here, rather than calling |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
98 |
// DatatypeFactory.class.getName() - in order to make javadoc |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
99 |
// generate a See Also: Constant Field Value link. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
100 |
"javax.xml.datatype.DatatypeFactory"; |
12005 | 101 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
102 |
/** |
29999 | 103 |
* Default implementation class name as defined in |
104 |
* <em>JSR 206: Java(TM) API for XML Processing (JAXP) 1.3</em>. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
105 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
106 |
* <p>Implementers should specify the name of an appropriate class |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
107 |
* to be instantiated if no other implementation resolution mechanism |
29999 | 108 |
* succeeds. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
109 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
110 |
* <p>Users should not refer to this field; it is intended only to |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
111 |
* document a factory implementation detail. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
112 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
113 |
public static final String DATATYPEFACTORY_IMPLEMENTATION_CLASS = |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
114 |
// We use new String() here to prevent javadoc from generating |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
115 |
// a See Also: Constant Field Value link. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
116 |
new String("com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl"); |
12005 | 117 |
|
118 |
/** |
|
119 |
* http://www.w3.org/TR/xpath-datamodel/#xdtschema defines two regexps |
|
120 |
* to constrain the value space of dayTimeDuration ([^YM]*[DT].*) |
|
121 |
* and yearMonthDuration ([^DT]*). Note that these expressions rely on |
|
122 |
* the fact that the value must be an xs:Duration, they simply exclude |
|
123 |
* some Durations. |
|
124 |
*/ |
|
125 |
private static final Pattern XDTSCHEMA_YMD = |
|
126 |
Pattern.compile("[^DT]*"); |
|
127 |
||
128 |
private static final Pattern XDTSCHEMA_DTD = |
|
129 |
Pattern.compile("[^YM]*[DT].*"); |
|
130 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
131 |
/** |
29999 | 132 |
* Protected constructor to prevent instantiation outside of package. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
133 |
* |
29999 | 134 |
* <p>Use {@link #newInstance()} to create a {@code DatatypeFactory}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
135 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
136 |
protected DatatypeFactory() { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
137 |
} |
12005 | 138 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
139 |
/** |
42390
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
140 |
* Creates a new instance of the {@code DatatypeFactory} {@linkplain |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
141 |
* #DATATYPEFACTORY_IMPLEMENTATION_CLASS builtin system-default |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
142 |
* implementation}. |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
143 |
* |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
144 |
* @return A new instance of the {@code DatatypeFactory} builtin |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
145 |
* system-default implementation. |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
146 |
* |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
147 |
* @since 9 |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
148 |
*/ |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
149 |
public static DatatypeFactory newDefaultInstance() { |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
150 |
return new DatatypeFactoryImpl(); |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
151 |
} |
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
152 |
|
4083bc2c3b5b
8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations
dfuchs
parents:
29999
diff
changeset
|
153 |
/** |
29999 | 154 |
* Obtain a new instance of a {@code DatatypeFactory}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
155 |
* |
12005 | 156 |
* <p>The implementation resolution mechanisms are <a href="#DatatypeFactory.newInstance">defined</a> in this |
29999 | 157 |
* {@code Class}'s documentation. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
158 |
* |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
159 |
* @return New instance of a {@code DatatypeFactory} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
160 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
161 |
* @throws DatatypeConfigurationException If the implementation is not |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
162 |
* available or cannot be instantiated. |
12005 | 163 |
* |
164 |
* @see #newInstance(String factoryClassName, ClassLoader classLoader) |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
165 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
166 |
public static DatatypeFactory newInstance() |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
167 |
throws DatatypeConfigurationException { |
12005 | 168 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
169 |
return FactoryFinder.find( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
170 |
/* The default property name according to the JAXP spec */ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
171 |
DatatypeFactory.class, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
172 |
/* The fallback implementation class name */ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
173 |
DATATYPEFACTORY_IMPLEMENTATION_CLASS); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
174 |
} |
12005 | 175 |
|
176 |
/** |
|
29999 | 177 |
* Obtain a new instance of a {@code DatatypeFactory} from class name. |
12005 | 178 |
* This function is useful when there are multiple providers in the classpath. |
179 |
* It gives more control to the application as it can specify which provider |
|
29999 | 180 |
* should be loaded. |
12005 | 181 |
* |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
182 |
* <p>Once an application has obtained a reference to a {@code DatatypeFactory} |
29999 | 183 |
* it can use the factory to configure and obtain datatype instances. |
12005 | 184 |
* |
185 |
* |
|
186 |
* <h2>Tip for Trouble-shooting</h2> |
|
29999 | 187 |
* <p>Setting the {@code jaxp.debug} system property will cause |
12005 | 188 |
* this method to print a lot of debug messages |
29999 | 189 |
* to {@code System.err} about what it is doing and where it is looking at. |
12005 | 190 |
* |
29999 | 191 |
* <p> If you have problems try: |
12005 | 192 |
* <pre> |
193 |
* java -Djaxp.debug=1 YourProgram .... |
|
194 |
* </pre> |
|
195 |
* |
|
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
196 |
* @param factoryClassName fully qualified factory class name that provides implementation of {@code javax.xml.datatype.DatatypeFactory}. |
12005 | 197 |
* |
29999 | 198 |
* @param classLoader {@code ClassLoader} used to load the factory class. If {@code null} |
199 |
* current {@code Thread}'s context classLoader is used to load the factory class. |
|
12005 | 200 |
* |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
27574
diff
changeset
|
201 |
* @return New instance of a {@code DatatypeFactory} |
12005 | 202 |
* |
29999 | 203 |
* @throws DatatypeConfigurationException if {@code factoryClassName} is {@code null}, or |
12005 | 204 |
* the factory class cannot be loaded, instantiated. |
205 |
* |
|
206 |
* @see #newInstance() |
|
207 |
* |
|
208 |
* @since 1.6 |
|
209 |
*/ |
|
210 |
public static DatatypeFactory newInstance(String factoryClassName, ClassLoader classLoader) |
|
211 |
throws DatatypeConfigurationException { |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
212 |
return FactoryFinder.newInstance(DatatypeFactory.class, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
213 |
factoryClassName, classLoader, false); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
214 |
} |
12005 | 215 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
216 |
/** |
29999 | 217 |
* Obtain a new instance of a {@code Duration} |
218 |
* specifying the {@code Duration} as its string representation, "PnYnMnDTnHnMnS", |
|
219 |
* as defined in XML Schema 1.0 section 3.2.6.1. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
220 |
* |
29999 | 221 |
* <p>XML Schema Part 2: Datatypes, 3.2.6 duration, defines {@code duration} as: |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
222 |
* <blockquote> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
223 |
* duration represents a duration of time. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
224 |
* The value space of duration is a six-dimensional space where the coordinates designate the |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
225 |
* Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
226 |
* These components are ordered in their significance by their order of appearance i.e. as |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
227 |
* year, month, day, hour, minute, and second. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
228 |
* </blockquote> |
29999 | 229 |
* <p>All six values are set and available from the created {@link Duration} |
12005 | 230 |
* |
231 |
* <p>The XML Schema specification states that values can be of an arbitrary size. |
|
232 |
* Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values. |
|
233 |
* An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits |
|
29999 | 234 |
* if implementation capacities are exceeded. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
235 |
* |
29999 | 236 |
* @param lexicalRepresentation {@code String} representation of a {@code Duration}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
237 |
* |
29999 | 238 |
* @return New {@code Duration} created from parsing the {@code lexicalRepresentation}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
239 |
* |
29999 | 240 |
* @throws IllegalArgumentException If {@code lexicalRepresentation} is not a valid representation of a {@code Duration}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
241 |
* @throws UnsupportedOperationException If implementation cannot support requested values. |
29999 | 242 |
* @throws NullPointerException if {@code lexicalRepresentation} is {@code null}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
243 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
244 |
public abstract Duration newDuration(final String lexicalRepresentation); |
12005 | 245 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
246 |
/** |
29999 | 247 |
* Obtain a new instance of a {@code Duration} |
248 |
* specifying the {@code Duration} as milliseconds. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
249 |
* |
29999 | 250 |
* <p>XML Schema Part 2: Datatypes, 3.2.6 duration, defines {@code duration} as: |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
251 |
* <blockquote> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
252 |
* duration represents a duration of time. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
253 |
* The value space of duration is a six-dimensional space where the coordinates designate the |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
254 |
* Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
255 |
* These components are ordered in their significance by their order of appearance i.e. as |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
256 |
* year, month, day, hour, minute, and second. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
257 |
* </blockquote> |
12005 | 258 |
* <p>All six values are set by computing their values from the specified milliseconds |
29999 | 259 |
* and are available using the {@code get} methods of the created {@link Duration}. |
260 |
* The values conform to and are defined by: |
|
12005 | 261 |
* <ul> |
262 |
* <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li> |
|
263 |
* <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats"> |
|
264 |
* W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a> |
|
265 |
* </li> |
|
266 |
* <li>{@link XMLGregorianCalendar} Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation</li> |
|
267 |
* </ul> |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
268 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
269 |
* <p>The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e., |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
270 |
* {@link java.util.Calendar#YEAR} = 1970, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
271 |
* {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY}, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
272 |
* {@link java.util.Calendar#DATE} = 1, etc. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
273 |
* This is important as there are variations in the Gregorian Calendar, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
274 |
* e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY} |
29999 | 275 |
* so the result of {@link Duration#getMonths()} and {@link Duration#getDays()} can be influenced. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
276 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
277 |
* @param durationInMilliSeconds Duration in milliseconds to create. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
278 |
* |
29999 | 279 |
* @return New {@code Duration} representing {@code durationInMilliSeconds}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
280 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
281 |
public abstract Duration newDuration(final long durationInMilliSeconds); |
12005 | 282 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
283 |
/** |
29999 | 284 |
* Obtain a new instance of a {@code Duration} |
285 |
* specifying the {@code Duration} as isPositive, years, months, days, hours, minutes, seconds. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
286 |
* |
12005 | 287 |
* <p>The XML Schema specification states that values can be of an arbitrary size. |
288 |
* Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values. |
|
289 |
* An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits |
|
29999 | 290 |
* if implementation capacities are exceeded. |
12005 | 291 |
* |
29999 | 292 |
* <p>A {@code null} value indicates that field is not set. |
12005 | 293 |
* |
29999 | 294 |
* @param isPositive Set to {@code false} to create a negative duration. When the length |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
295 |
* of the duration is zero, this parameter will be ignored. |
29999 | 296 |
* @param years of this {@code Duration} |
297 |
* @param months of this {@code Duration} |
|
298 |
* @param days of this {@code Duration} |
|
299 |
* @param hours of this {@code Duration} |
|
300 |
* @param minutes of this {@code Duration} |
|
301 |
* @param seconds of this {@code Duration} |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
302 |
* |
29999 | 303 |
* @return New {@code Duration} created from the specified values. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
304 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
305 |
* @throws IllegalArgumentException If the values are not a valid representation of a |
29999 | 306 |
* {@code Duration}: if all the fields (years, months, ...) are null or |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
307 |
* if any of the fields is negative. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
308 |
* @throws UnsupportedOperationException If implementation cannot support requested values. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
309 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
310 |
public abstract Duration newDuration( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
311 |
final boolean isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
312 |
final BigInteger years, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
313 |
final BigInteger months, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
314 |
final BigInteger days, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
315 |
final BigInteger hours, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
316 |
final BigInteger minutes, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
317 |
final BigDecimal seconds); |
12005 | 318 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
319 |
/** |
29999 | 320 |
* Obtain a new instance of a {@code Duration} |
321 |
* specifying the {@code Duration} as isPositive, years, months, days, hours, minutes, seconds. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
322 |
* |
29999 | 323 |
* <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set. |
12005 | 324 |
* |
29999 | 325 |
* @param isPositive Set to {@code false} to create a negative duration. When the length |
12005 | 326 |
* of the duration is zero, this parameter will be ignored. |
29999 | 327 |
* @param years of this {@code Duration} |
328 |
* @param months of this {@code Duration} |
|
329 |
* @param days of this {@code Duration} |
|
330 |
* @param hours of this {@code Duration} |
|
331 |
* @param minutes of this {@code Duration} |
|
332 |
* @param seconds of this {@code Duration} |
|
12005 | 333 |
* |
29999 | 334 |
* @return New {@code Duration} created from the specified values. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
335 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
336 |
* @throws IllegalArgumentException If the values are not a valid representation of a |
29999 | 337 |
* {@code Duration}: if any of the fields is negative. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
338 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
339 |
* @see #newDuration( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
340 |
* boolean isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
341 |
* BigInteger years, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
342 |
* BigInteger months, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
343 |
* BigInteger days, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
344 |
* BigInteger hours, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
345 |
* BigInteger minutes, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
346 |
* BigDecimal seconds) |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
347 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
348 |
public Duration newDuration( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
349 |
final boolean isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
350 |
final int years, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
351 |
final int months, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
352 |
final int days, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
353 |
final int hours, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
354 |
final int minutes, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
355 |
final int seconds) { |
12005 | 356 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
357 |
// years may not be set |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
358 |
BigInteger realYears = (years != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) years) : null; |
12005 | 359 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
360 |
// months may not be set |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
361 |
BigInteger realMonths = (months != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) months) : null; |
12005 | 362 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
363 |
// days may not be set |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
364 |
BigInteger realDays = (days != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) days) : null; |
12005 | 365 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
366 |
// hours may not be set |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
367 |
BigInteger realHours = (hours != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) hours) : null; |
12005 | 368 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
369 |
// minutes may not be set |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
370 |
BigInteger realMinutes = (minutes != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) minutes) : null; |
12005 | 371 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
372 |
// seconds may not be set |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
373 |
BigDecimal realSeconds = (seconds != DatatypeConstants.FIELD_UNDEFINED) ? BigDecimal.valueOf((long) seconds) : null; |
12005 | 374 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
375 |
return newDuration( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
376 |
isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
377 |
realYears, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
378 |
realMonths, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
379 |
realDays, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
380 |
realHours, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
381 |
realMinutes, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
382 |
realSeconds |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
383 |
); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
384 |
} |
12005 | 385 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
386 |
/** |
29999 | 387 |
* Create a {@code Duration} of type {@code xdt:dayTimeDuration} |
388 |
* by parsing its {@code String} representation, |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
389 |
* "<em>PnDTnHnMnS</em>", <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration"> |
29999 | 390 |
* XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
391 |
* |
29999 | 392 |
* <p>The datatype {@code xdt:dayTimeDuration} is a subtype of {@code xs:duration} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
393 |
* whose lexical representation contains only day, hour, minute, and second components. |
29999 | 394 |
* This datatype resides in the namespace {@code http://www.w3.org/2003/11/xpath-datatypes}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
395 |
* |
29999 | 396 |
* <p>All four values are set and available from the created {@link Duration} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
397 |
* |
12005 | 398 |
* <p>The XML Schema specification states that values can be of an arbitrary size. |
399 |
* Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values. |
|
400 |
* An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits |
|
29999 | 401 |
* if implementation capacities are exceeded. |
12005 | 402 |
* |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
403 |
* @param lexicalRepresentation Lexical representation of a duration. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
404 |
* |
29999 | 405 |
* @return New {@code Duration} created using the specified {@code lexicalRepresentation}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
406 |
* |
29999 | 407 |
* @throws IllegalArgumentException If {@code lexicalRepresentation} is |
408 |
* not a valid representation of a {@code Duration} expressed only in terms of days and time. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
409 |
* @throws UnsupportedOperationException If implementation cannot support requested values. |
29999 | 410 |
* @throws NullPointerException If {@code lexicalRepresentation} is {@code null}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
411 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
412 |
public Duration newDurationDayTime(final String lexicalRepresentation) { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
413 |
// lexicalRepresentation must be non-null |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
414 |
if (lexicalRepresentation == null) { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
415 |
throw new NullPointerException( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
416 |
"Trying to create an xdt:dayTimeDuration with an invalid" |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
417 |
+ " lexical representation of \"null\""); |
12005 | 418 |
} |
419 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
420 |
// test lexicalRepresentation against spec regex |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
421 |
Matcher matcher = XDTSCHEMA_DTD.matcher(lexicalRepresentation); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
422 |
if (!matcher.matches()) { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
423 |
throw new IllegalArgumentException( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
424 |
"Trying to create an xdt:dayTimeDuration with an invalid" |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
425 |
+ " lexical representation of \"" + lexicalRepresentation |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
426 |
+ "\", data model requires years and months only."); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
427 |
} |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
428 |
|
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
429 |
return newDuration(lexicalRepresentation); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
430 |
} |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
431 |
|
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
432 |
/** |
29999 | 433 |
* Create a {@code Duration} of type {@code xdt:dayTimeDuration} |
434 |
* using the specified milliseconds as defined in |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
435 |
* <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration"> |
29999 | 436 |
* XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
437 |
* |
29999 | 438 |
* <p>The datatype {@code xdt:dayTimeDuration} is a subtype of {@code xs:duration} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
439 |
* whose lexical representation contains only day, hour, minute, and second components. |
29999 | 440 |
* This datatype resides in the namespace {@code http://www.w3.org/2003/11/xpath-datatypes}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
441 |
* |
12005 | 442 |
* <p>All four values are set by computing their values from the specified milliseconds |
29999 | 443 |
* and are available using the {@code get} methods of the created {@link Duration}. |
444 |
* The values conform to and are defined by: |
|
12005 | 445 |
* <ul> |
446 |
* <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li> |
|
447 |
* <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats"> |
|
448 |
* W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a> |
|
449 |
* </li> |
|
450 |
* <li>{@link XMLGregorianCalendar} Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation</li> |
|
451 |
* </ul> |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
452 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
453 |
* <p>The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e., |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
454 |
* {@link java.util.Calendar#YEAR} = 1970, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
455 |
* {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY}, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
456 |
* {@link java.util.Calendar#DATE} = 1, etc. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
457 |
* This is important as there are variations in the Gregorian Calendar, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
458 |
* e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY} |
29999 | 459 |
* so the result of {@link Duration#getDays()} can be influenced. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
460 |
* |
29999 | 461 |
* <p>Any remaining milliseconds after determining the day, hour, minute and second are discarded. |
12005 | 462 |
* |
29999 | 463 |
* @param durationInMilliseconds Milliseconds of {@code Duration} to create. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
464 |
* |
29999 | 465 |
* @return New {@code Duration} created with the specified {@code durationInMilliseconds}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
466 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
467 |
* @see <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration"> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
468 |
* XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
469 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
470 |
public Duration newDurationDayTime(final long durationInMilliseconds) { |
12005 | 471 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
472 |
return newDuration(durationInMilliseconds); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
473 |
} |
12005 | 474 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
475 |
/** |
29999 | 476 |
* Create a {@code Duration} of type {@code xdt:dayTimeDuration} using the specified |
477 |
* {@code day}, {@code hour}, {@code minute} and {@code second} as defined in |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
478 |
* <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration"> |
29999 | 479 |
* XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
480 |
* |
29999 | 481 |
* <p>The datatype {@code xdt:dayTimeDuration} is a subtype of {@code xs:duration} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
482 |
* whose lexical representation contains only day, hour, minute, and second components. |
29999 | 483 |
* This datatype resides in the namespace {@code http://www.w3.org/2003/11/xpath-datatypes}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
484 |
* |
12005 | 485 |
* <p>The XML Schema specification states that values can be of an arbitrary size. |
486 |
* Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values. |
|
487 |
* An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits |
|
29999 | 488 |
* if implementation capacities are exceeded. |
12005 | 489 |
* |
29999 | 490 |
* <p>A {@code null} value indicates that field is not set. |
12005 | 491 |
* |
29999 | 492 |
* @param isPositive Set to {@code false} to create a negative duration. When the length |
12005 | 493 |
* of the duration is zero, this parameter will be ignored. |
29999 | 494 |
* @param day Day of {@code Duration}. |
495 |
* @param hour Hour of {@code Duration}. |
|
496 |
* @param minute Minute of {@code Duration}. |
|
497 |
* @param second Second of {@code Duration}. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
498 |
* |
29999 | 499 |
* @return New {@code Duration} created with the specified {@code day}, {@code hour}, {@code minute} |
500 |
* and {@code second}. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
501 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
502 |
* @throws IllegalArgumentException If the values are not a valid representation of a |
29999 | 503 |
* {@code Duration}: if all the fields (day, hour, ...) are null or |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
504 |
* if any of the fields is negative. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
505 |
* @throws UnsupportedOperationException If implementation cannot support requested values. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
506 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
507 |
public Duration newDurationDayTime( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
508 |
final boolean isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
509 |
final BigInteger day, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
510 |
final BigInteger hour, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
511 |
final BigInteger minute, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
512 |
final BigInteger second) { |
12005 | 513 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
514 |
return newDuration( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
515 |
isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
516 |
null, // years |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
517 |
null, // months |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
518 |
day, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
519 |
hour, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
520 |
minute, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
521 |
(second != null)? new BigDecimal(second):null |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
522 |
); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
523 |
} |
12005 | 524 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
525 |
/** |
29999 | 526 |
* Create a {@code Duration} of type {@code xdt:dayTimeDuration} using the specified |
527 |
* {@code day}, {@code hour}, {@code minute} and {@code second} as defined in |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
528 |
* <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration"> |
29999 | 529 |
* XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
530 |
* |
29999 | 531 |
* <p>The datatype {@code xdt:dayTimeDuration} is a subtype of {@code xs:duration} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
532 |
* whose lexical representation contains only day, hour, minute, and second components. |
29999 | 533 |
* This datatype resides in the namespace {@code http://www.w3.org/2003/11/xpath-datatypes}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
534 |
* |
29999 | 535 |
* <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set. |
12005 | 536 |
* |
29999 | 537 |
* @param isPositive Set to {@code false} to create a negative duration. When the length |
12005 | 538 |
* of the duration is zero, this parameter will be ignored. |
29999 | 539 |
* @param day Day of {@code Duration}. |
540 |
* @param hour Hour of {@code Duration}. |
|
541 |
* @param minute Minute of {@code Duration}. |
|
542 |
* @param second Second of {@code Duration}. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
543 |
* |
29999 | 544 |
* @return New {@code Duration} created with the specified {@code day}, {@code hour}, {@code minute} |
545 |
* and {@code second}. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
546 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
547 |
* @throws IllegalArgumentException If the values are not a valid representation of a |
29999 | 548 |
* {@code Duration}: if any of the fields (day, hour, ...) is negative. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
549 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
550 |
public Duration newDurationDayTime( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
551 |
final boolean isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
552 |
final int day, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
553 |
final int hour, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
554 |
final int minute, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
555 |
final int second) { |
12005 | 556 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
557 |
return newDurationDayTime( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
558 |
isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
559 |
BigInteger.valueOf((long) day), |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
560 |
BigInteger.valueOf((long) hour), |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
561 |
BigInteger.valueOf((long) minute), |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
562 |
BigInteger.valueOf((long) second) |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
563 |
); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
564 |
} |
12005 | 565 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
566 |
/** |
29999 | 567 |
* Create a {@code Duration} of type {@code xdt:yearMonthDuration} |
568 |
* by parsing its {@code String} representation, |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
569 |
* "<em>PnYnM</em>", <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration"> |
29999 | 570 |
* XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
571 |
* |
29999 | 572 |
* <p>The datatype {@code xdt:yearMonthDuration} is a subtype of {@code xs:duration} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
573 |
* whose lexical representation contains only year and month components. |
29999 | 574 |
* This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
575 |
* |
29999 | 576 |
* <p>Both values are set and available from the created {@link Duration} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
577 |
* |
12005 | 578 |
* <p>The XML Schema specification states that values can be of an arbitrary size. |
29999 | 579 |
* Implementations may chose not to or be incapable of supporting |
580 |
* arbitrarily large and/or small values. An {@link UnsupportedOperationException} |
|
581 |
* will be thrown with a message indicating implementation limits |
|
582 |
* if implementation capacities are exceeded. |
|
12005 | 583 |
* |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
584 |
* @param lexicalRepresentation Lexical representation of a duration. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
585 |
* |
29999 | 586 |
* @return New {@code Duration} created using the specified {@code lexicalRepresentation}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
587 |
* |
29999 | 588 |
* @throws IllegalArgumentException If {@code lexicalRepresentation} is not a valid representation of a {@code Duration} expressed only in terms of years and months. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
589 |
* @throws UnsupportedOperationException If implementation cannot support requested values. |
29999 | 590 |
* @throws NullPointerException If {@code lexicalRepresentation} is {@code null}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
591 |
*/ |
12005 | 592 |
public Duration newDurationYearMonth( |
593 |
final String lexicalRepresentation) { |
|
594 |
||
595 |
// lexicalRepresentation must be non-null |
|
596 |
if (lexicalRepresentation == null) { |
|
597 |
throw new NullPointerException( |
|
598 |
"Trying to create an xdt:yearMonthDuration with an invalid" |
|
599 |
+ " lexical representation of \"null\""); |
|
600 |
} |
|
601 |
||
602 |
// test lexicalRepresentation against spec regex |
|
603 |
Matcher matcher = XDTSCHEMA_YMD.matcher(lexicalRepresentation); |
|
604 |
if (!matcher.matches()) { |
|
605 |
throw new IllegalArgumentException( |
|
606 |
"Trying to create an xdt:yearMonthDuration with an invalid" |
|
607 |
+ " lexical representation of \"" + lexicalRepresentation |
|
608 |
+ "\", data model requires days and times only."); |
|
609 |
} |
|
610 |
||
611 |
return newDuration(lexicalRepresentation); |
|
612 |
} |
|
613 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
614 |
/** |
29999 | 615 |
* Create a {@code Duration} of type {@code xdt:yearMonthDuration} |
616 |
* using the specified milliseconds as defined in |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
617 |
* <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration"> |
29999 | 618 |
* XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
619 |
* |
29999 | 620 |
* <p>The datatype {@code xdt:yearMonthDuration} is a subtype of {@code xs:duration} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
621 |
* whose lexical representation contains only year and month components. |
29999 | 622 |
* This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
623 |
* |
12005 | 624 |
* <p>Both values are set by computing their values from the specified milliseconds |
29999 | 625 |
* and are available using the {@code get} methods of the created {@link Duration}. |
626 |
* The values conform to and are defined by: |
|
12005 | 627 |
* <ul> |
628 |
* <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li> |
|
629 |
* <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats"> |
|
630 |
* W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a> |
|
631 |
* </li> |
|
632 |
* <li>{@link XMLGregorianCalendar} Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation</li> |
|
633 |
* </ul> |
|
634 |
* |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
635 |
* <p>The default start instance is defined by {@link GregorianCalendar}'s use of the start of the epoch: i.e., |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
636 |
* {@link java.util.Calendar#YEAR} = 1970, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
637 |
* {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY}, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
638 |
* {@link java.util.Calendar#DATE} = 1, etc. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
639 |
* This is important as there are variations in the Gregorian Calendar, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
640 |
* e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY} |
29999 | 641 |
* so the result of {@link Duration#getMonths()} can be influenced. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
642 |
* |
29999 | 643 |
* <p>Any remaining milliseconds after determining the year and month are discarded. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
644 |
* |
29999 | 645 |
* @param durationInMilliseconds Milliseconds of {@code Duration} to create. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
646 |
* |
29999 | 647 |
* @return New {@code Duration} created using the specified {@code durationInMilliseconds}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
648 |
*/ |
12005 | 649 |
public Duration newDurationYearMonth( |
650 |
final long durationInMilliseconds) { |
|
651 |
||
652 |
// create a Duration that only has sign, year & month |
|
653 |
// Duration is immutable, so need to create a new Duration |
|
654 |
// implementations may override this method in a more efficient way |
|
655 |
Duration fullDuration = newDuration(durationInMilliseconds); |
|
656 |
boolean isPositive = (fullDuration.getSign() == -1) ? false : true; |
|
657 |
BigInteger years = |
|
658 |
(BigInteger) fullDuration.getField(DatatypeConstants.YEARS); |
|
659 |
if (years == null) { years = BigInteger.ZERO; } |
|
660 |
BigInteger months = |
|
661 |
(BigInteger) fullDuration.getField(DatatypeConstants.MONTHS); |
|
662 |
if (months == null) { months = BigInteger.ZERO; } |
|
663 |
||
664 |
return newDurationYearMonth(isPositive, years, months); |
|
665 |
} |
|
666 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
667 |
/** |
29999 | 668 |
* Create a {@code Duration} of type {@code xdt:yearMonthDuration} using the specified |
669 |
* {@code year} and {@code month} as defined in |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
670 |
* <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration"> |
29999 | 671 |
* XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
672 |
* |
12005 | 673 |
* <p>The XML Schema specification states that values can be of an arbitrary size. |
674 |
* Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values. |
|
675 |
* An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits |
|
29999 | 676 |
* if implementation capacities are exceeded. |
12005 | 677 |
* |
29999 | 678 |
* <p>A {@code null} value indicates that field is not set. |
12005 | 679 |
* |
29999 | 680 |
* @param isPositive Set to {@code false} to create a negative duration. When the length |
12005 | 681 |
* of the duration is zero, this parameter will be ignored. |
29999 | 682 |
* @param year Year of {@code Duration}. |
683 |
* @param month Month of {@code Duration}. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
684 |
* |
29999 | 685 |
* @return New {@code Duration} created using the specified {@code year} and {@code month}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
686 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
687 |
* @throws IllegalArgumentException If the values are not a valid representation of a |
29999 | 688 |
* {@code Duration}: if all of the fields (year, month) are null or |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
689 |
* if any of the fields is negative. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
690 |
* @throws UnsupportedOperationException If implementation cannot support requested values. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
691 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
692 |
public Duration newDurationYearMonth( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
693 |
final boolean isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
694 |
final BigInteger year, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
695 |
final BigInteger month) { |
12005 | 696 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
697 |
return newDuration( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
698 |
isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
699 |
year, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
700 |
month, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
701 |
null, // days |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
702 |
null, // hours |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
703 |
null, // minutes |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
704 |
null // seconds |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
705 |
); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
706 |
} |
12005 | 707 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
708 |
/** |
29999 | 709 |
* Create a {@code Duration} of type {@code xdt:yearMonthDuration} using the specified |
710 |
* {@code year} and {@code month} as defined in |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
711 |
* <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration"> |
29999 | 712 |
* XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
713 |
* |
29999 | 714 |
* <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set. |
12005 | 715 |
* |
29999 | 716 |
* @param isPositive Set to {@code false} to create a negative duration. When the length |
12005 | 717 |
* of the duration is zero, this parameter will be ignored. |
29999 | 718 |
* @param year Year of {@code Duration}. |
719 |
* @param month Month of {@code Duration}. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
720 |
* |
29999 | 721 |
* @return New {@code Duration} created using the specified {@code year} and {@code month}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
722 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
723 |
* @throws IllegalArgumentException If the values are not a valid representation of a |
29999 | 724 |
* {@code Duration}: if any of the fields (year, month) is negative. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
725 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
726 |
public Duration newDurationYearMonth( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
727 |
final boolean isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
728 |
final int year, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
729 |
final int month) { |
12005 | 730 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
731 |
return newDurationYearMonth( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
732 |
isPositive, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
733 |
BigInteger.valueOf((long) year), |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
734 |
BigInteger.valueOf((long) month)); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
735 |
} |
12005 | 736 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
737 |
/** |
29999 | 738 |
* Create a new instance of an {@code XMLGregorianCalendar}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
739 |
* |
29999 | 740 |
* <p>All date/time datatype fields set to {@link DatatypeConstants#FIELD_UNDEFINED} or null. |
12005 | 741 |
* |
29999 | 742 |
* @return New {@code XMLGregorianCalendar} with all date/time datatype fields set to |
12005 | 743 |
* {@link DatatypeConstants#FIELD_UNDEFINED} or null. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
744 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
745 |
public abstract XMLGregorianCalendar newXMLGregorianCalendar(); |
12005 | 746 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
747 |
/** |
29999 | 748 |
* Create a new XMLGregorianCalendar by parsing the String as a lexical representation. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
749 |
* |
12005 | 750 |
* <p>Parsing the lexical string representation is defined in |
751 |
* <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">XML Schema 1.0 Part 2, Section 3.2.[7-14].1, |
|
29999 | 752 |
* <em>Lexical Representation</em>.</a> |
12005 | 753 |
* |
29999 | 754 |
* <p>The string representation may not have any leading and trailing whitespaces. |
12005 | 755 |
* |
756 |
* <p>The parsing is done field by field so that |
|
29999 | 757 |
* the following holds for any lexically correct String x: |
12005 | 758 |
* <pre> |
759 |
* newXMLGregorianCalendar(x).toXMLFormat().equals(x) |
|
760 |
* </pre> |
|
761 |
* <p>Except for the noted lexical/canonical representation mismatches |
|
762 |
* listed in <a href="http://www.w3.org/2001/05/xmlschema-errata#e2-45"> |
|
29999 | 763 |
* XML Schema 1.0 errata, Section 3.2.7.2</a>. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
764 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
765 |
* @param lexicalRepresentation Lexical representation of one the eight XML Schema date/time datatypes. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
766 |
* |
29999 | 767 |
* @return {@code XMLGregorianCalendar} created from the {@code lexicalRepresentation}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
768 |
* |
29999 | 769 |
* @throws IllegalArgumentException If the {@code lexicalRepresentation} is not a valid {@code XMLGregorianCalendar}. |
770 |
* @throws NullPointerException If {@code lexicalRepresentation} is {@code null}. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
771 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
772 |
public abstract XMLGregorianCalendar newXMLGregorianCalendar(final String lexicalRepresentation); |
12005 | 773 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
774 |
/** |
29999 | 775 |
* Create an {@code XMLGregorianCalendar} from a {@link GregorianCalendar}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
776 |
* |
45261 | 777 |
* <table class="striped"> |
778 |
* <caption>Field by Field Conversion from |
|
779 |
* {@link GregorianCalendar} to an {@link XMLGregorianCalendar}</caption> |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
780 |
* <thead> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
781 |
* <tr> |
45855 | 782 |
* <th scope="col">{@code java.util.GregorianCalendar} field</th> |
783 |
* <th scope="col">{@code javax.xml.datatype.XMLGregorianCalendar} field</th> |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
784 |
* </tr> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
785 |
* </thead> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
786 |
* <tbody> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
787 |
* <tr> |
45855 | 788 |
* <th scope="row">{@code ERA == GregorianCalendar.BC ? -YEAR : YEAR}</th> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
789 |
* <td>{@link XMLGregorianCalendar#setYear(int year)}</td> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
790 |
* </tr> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
791 |
* <tr> |
45855 | 792 |
* <th scope="row">{@code MONTH + 1}</th> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
793 |
* <td>{@link XMLGregorianCalendar#setMonth(int month)}</td> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
794 |
* </tr> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
795 |
* <tr> |
45855 | 796 |
* <th scope="row">{@code DAY_OF_MONTH}</th> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
797 |
* <td>{@link XMLGregorianCalendar#setDay(int day)}</td> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
798 |
* </tr> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
799 |
* <tr> |
45855 | 800 |
* <th scope="row">{@code HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND}</th> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
801 |
* <td>{@link XMLGregorianCalendar#setTime(int hour, int minute, int second, BigDecimal fractional)}</td> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
802 |
* </tr> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
803 |
* <tr> |
45855 | 804 |
* <th scope="row"> |
29999 | 805 |
* {@code (ZONE_OFFSET + DST_OFFSET) / (60*1000)}<br> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
806 |
* <em>(in minutes)</em> |
45855 | 807 |
* </th> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
808 |
* <td>{@link XMLGregorianCalendar#setTimezone(int offset)}<sup><em>*</em></sup> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
809 |
* </td> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
810 |
* </tr> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
811 |
* </tbody> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
812 |
* </table> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
813 |
* <p><em>*</em>conversion loss of information. It is not possible to represent |
29999 | 814 |
* a {@code java.util.GregorianCalendar} daylight savings timezone id in the |
815 |
* XML Schema 1.0 date/time datatype representation. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
816 |
* |
29999 | 817 |
* <p>To compute the return value's {@code TimeZone} field, |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
818 |
* <ul> |
29999 | 819 |
* <li>when {@code this.getTimezone() != FIELD_UNDEFINED}, |
820 |
* create a {@code java.util.TimeZone} with a custom timezone id |
|
821 |
* using the {@code this.getTimezone()}.</li> |
|
822 |
* <li>else use the {@code GregorianCalendar} default timezone value |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
823 |
* for the host is defined as specified by |
29999 | 824 |
* {@code java.util.TimeZone.getDefault()}.</li> |
825 |
* </ul> |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
826 |
* |
29999 | 827 |
* @param cal {@code java.util.GregorianCalendar} used to create {@code XMLGregorianCalendar} |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
828 |
* |
29999 | 829 |
* @return {@code XMLGregorianCalendar} created from {@code java.util.GregorianCalendar} |
830 |
* |
|
831 |
* @throws NullPointerException If {@code cal} is {@code null}. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
832 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
833 |
public abstract XMLGregorianCalendar newXMLGregorianCalendar(final GregorianCalendar cal); |
12005 | 834 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
835 |
/** |
29999 | 836 |
* Constructor allowing for complete value spaces allowed by |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
837 |
* W3C XML Schema 1.0 recommendation for xsd:dateTime and related |
29999 | 838 |
* builtin datatypes. Note that {@code year} parameter supports |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
839 |
* arbitrarily large numbers and fractionalSecond has infinite |
29999 | 840 |
* precision. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
841 |
* |
29999 | 842 |
* <p>A {@code null} value indicates that field is not set. |
12005 | 843 |
* |
29999 | 844 |
* @param year of {@code XMLGregorianCalendar} to be created. |
845 |
* @param month of {@code XMLGregorianCalendar} to be created. |
|
846 |
* @param day of {@code XMLGregorianCalendar} to be created. |
|
847 |
* @param hour of {@code XMLGregorianCalendar} to be created. |
|
848 |
* @param minute of {@code XMLGregorianCalendar} to be created. |
|
849 |
* @param second of {@code XMLGregorianCalendar} to be created. |
|
850 |
* @param fractionalSecond of {@code XMLGregorianCalendar} to be created. |
|
851 |
* @param timezone of {@code XMLGregorianCalendar} to be created. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
852 |
* |
29999 | 853 |
* @return {@code XMLGregorianCalendar} created from specified values. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
854 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
855 |
* @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
856 |
* as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar} |
29999 | 857 |
* or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
858 |
* as determined by {@link XMLGregorianCalendar#isValid()}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
859 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
860 |
public abstract XMLGregorianCalendar newXMLGregorianCalendar( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
861 |
final BigInteger year, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
862 |
final int month, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
863 |
final int day, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
864 |
final int hour, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
865 |
final int minute, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
866 |
final int second, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
867 |
final BigDecimal fractionalSecond, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
868 |
final int timezone); |
12005 | 869 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
870 |
/** |
29999 | 871 |
* Constructor of value spaces that a |
872 |
* {@code java.util.GregorianCalendar} instance would need to convert to an |
|
873 |
* {@code XMLGregorianCalendar} instance. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
874 |
* |
29999 | 875 |
* <p>{@code XMLGregorianCalendar eon} and |
876 |
* {@code fractionalSecond} are set to {@code null} |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
877 |
* |
29999 | 878 |
* <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set. |
12005 | 879 |
* |
29999 | 880 |
* @param year of {@code XMLGregorianCalendar} to be created. |
881 |
* @param month of {@code XMLGregorianCalendar} to be created. |
|
882 |
* @param day of {@code XMLGregorianCalendar} to be created. |
|
883 |
* @param hour of {@code XMLGregorianCalendar} to be created. |
|
884 |
* @param minute of {@code XMLGregorianCalendar} to be created. |
|
885 |
* @param second of {@code XMLGregorianCalendar} to be created. |
|
886 |
* @param millisecond of {@code XMLGregorianCalendar} to be created. |
|
887 |
* @param timezone of {@code XMLGregorianCalendar} to be created. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
888 |
* |
29999 | 889 |
* @return {@code XMLGregorianCalendar} created from specified values. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
890 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
891 |
* @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
892 |
* as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar} |
29999 | 893 |
* or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
894 |
* as determined by {@link XMLGregorianCalendar#isValid()}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
895 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
896 |
public XMLGregorianCalendar newXMLGregorianCalendar( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
897 |
final int year, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
898 |
final int month, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
899 |
final int day, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
900 |
final int hour, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
901 |
final int minute, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
902 |
final int second, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
903 |
final int millisecond, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
904 |
final int timezone) { |
12005 | 905 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
906 |
// year may be undefined |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
907 |
BigInteger realYear = (year != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) year) : null; |
12005 | 908 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
909 |
// millisecond may be undefined |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
910 |
// millisecond must be >= 0 millisecond <= 1000 |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
911 |
BigDecimal realMillisecond = null; // undefined value |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
912 |
if (millisecond != DatatypeConstants.FIELD_UNDEFINED) { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
913 |
if (millisecond < 0 || millisecond > 1000) { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
914 |
throw new IllegalArgumentException( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
915 |
"javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendar(" |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
916 |
+ "int year, int month, int day, int hour, int minute, int second, int millisecond, int timezone)" |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
917 |
+ "with invalid millisecond: " + millisecond |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
918 |
); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
919 |
} |
12005 | 920 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
921 |
realMillisecond = BigDecimal.valueOf((long) millisecond).movePointLeft(3); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
922 |
} |
12005 | 923 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
924 |
return newXMLGregorianCalendar( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
925 |
realYear, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
926 |
month, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
927 |
day, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
928 |
hour, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
929 |
minute, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
930 |
second, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
931 |
realMillisecond, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
932 |
timezone |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
933 |
); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
934 |
} |
12005 | 935 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
936 |
/** |
29999 | 937 |
* Create a Java representation of XML Schema builtin datatype {@code date} or {@code g*}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
938 |
* |
29999 | 939 |
* <p>For example, an instance of {@code gYear} can be created invoking this factory |
940 |
* with {@code month} and {@code day} parameters set to |
|
941 |
* {@link DatatypeConstants#FIELD_UNDEFINED}. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
942 |
* |
29999 | 943 |
* <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set. |
12005 | 944 |
* |
29999 | 945 |
* @param year of {@code XMLGregorianCalendar} to be created. |
946 |
* @param month of {@code XMLGregorianCalendar} to be created. |
|
947 |
* @param day of {@code XMLGregorianCalendar} to be created. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
948 |
* @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
949 |
* |
29999 | 950 |
* @return {@code XMLGregorianCalendar} created from parameter values. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
951 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
952 |
* @see DatatypeConstants#FIELD_UNDEFINED |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
953 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
954 |
* @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
955 |
* as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar} |
29999 | 956 |
* or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
957 |
* as determined by {@link XMLGregorianCalendar#isValid()}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
958 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
959 |
public XMLGregorianCalendar newXMLGregorianCalendarDate( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
960 |
final int year, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
961 |
final int month, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
962 |
final int day, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
963 |
final int timezone) { |
12005 | 964 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
965 |
return newXMLGregorianCalendar( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
966 |
year, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
967 |
month, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
968 |
day, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
969 |
DatatypeConstants.FIELD_UNDEFINED, // hour |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
970 |
DatatypeConstants.FIELD_UNDEFINED, // minute |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
971 |
DatatypeConstants.FIELD_UNDEFINED, // second |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
972 |
DatatypeConstants.FIELD_UNDEFINED, // millisecond |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
973 |
timezone); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
974 |
} |
12005 | 975 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
976 |
/** |
29999 | 977 |
* Create a Java instance of XML Schema builtin datatype {@code time}. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
978 |
* |
29999 | 979 |
* <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set. |
12005 | 980 |
* |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
981 |
* @param hours number of hours |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
982 |
* @param minutes number of minutes |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
983 |
* @param seconds number of seconds |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
984 |
* @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
985 |
* |
29999 | 986 |
* @return {@code XMLGregorianCalendar} created from parameter values. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
987 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
988 |
* @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
989 |
* as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar} |
29999 | 990 |
* or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
991 |
* as determined by {@link XMLGregorianCalendar#isValid()}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
992 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
993 |
* @see DatatypeConstants#FIELD_UNDEFINED |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
994 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
995 |
public XMLGregorianCalendar newXMLGregorianCalendarTime( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
996 |
final int hours, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
997 |
final int minutes, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
998 |
final int seconds, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
999 |
final int timezone) { |
12005 | 1000 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1001 |
return newXMLGregorianCalendar( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1002 |
DatatypeConstants.FIELD_UNDEFINED, // Year |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1003 |
DatatypeConstants.FIELD_UNDEFINED, // Month |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1004 |
DatatypeConstants.FIELD_UNDEFINED, // Day |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1005 |
hours, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1006 |
minutes, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1007 |
seconds, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1008 |
DatatypeConstants.FIELD_UNDEFINED, //Millisecond |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1009 |
timezone); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1010 |
} |
12005 | 1011 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1012 |
/** |
29999 | 1013 |
* Create a Java instance of XML Schema builtin datatype time. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1014 |
* |
29999 | 1015 |
* <p>A {@code null} value indicates that field is not set. |
1016 |
* <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set. |
|
12005 | 1017 |
* |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1018 |
* @param hours number of hours |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1019 |
* @param minutes number of minutes |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1020 |
* @param seconds number of seconds |
29999 | 1021 |
* @param fractionalSecond value of {@code null} indicates that this optional field is not set. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1022 |
* @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1023 |
* |
29999 | 1024 |
* @return {@code XMLGregorianCalendar} created from parameter values. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1025 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1026 |
* @see DatatypeConstants#FIELD_UNDEFINED |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1027 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1028 |
* @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1029 |
* as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar} |
29999 | 1030 |
* or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1031 |
* as determined by {@link XMLGregorianCalendar#isValid()}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1032 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1033 |
public XMLGregorianCalendar newXMLGregorianCalendarTime( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1034 |
final int hours, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1035 |
final int minutes, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1036 |
final int seconds, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1037 |
final BigDecimal fractionalSecond, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1038 |
final int timezone) { |
12005 | 1039 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1040 |
return newXMLGregorianCalendar( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1041 |
null, // year |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1042 |
DatatypeConstants.FIELD_UNDEFINED, // month |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1043 |
DatatypeConstants.FIELD_UNDEFINED, // day |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1044 |
hours, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1045 |
minutes, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1046 |
seconds, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1047 |
fractionalSecond, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1048 |
timezone); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1049 |
} |
12005 | 1050 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1051 |
/** |
29999 | 1052 |
* Create a Java instance of XML Schema builtin datatype time. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1053 |
* |
29999 | 1054 |
* <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set. |
12005 | 1055 |
* |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1056 |
* @param hours number of hours |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1057 |
* @param minutes number of minutes |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1058 |
* @param seconds number of seconds |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1059 |
* @param milliseconds number of milliseconds |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1060 |
* @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1061 |
* |
29999 | 1062 |
* @return {@code XMLGregorianCalendar} created from parameter values. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1063 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1064 |
* @see DatatypeConstants#FIELD_UNDEFINED |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1065 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1066 |
* @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1067 |
* as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar} |
29999 | 1068 |
* or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1069 |
* as determined by {@link XMLGregorianCalendar#isValid()}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1070 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1071 |
public XMLGregorianCalendar newXMLGregorianCalendarTime( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1072 |
final int hours, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1073 |
final int minutes, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1074 |
final int seconds, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1075 |
final int milliseconds, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1076 |
final int timezone) { |
12005 | 1077 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1078 |
// millisecond may be undefined |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1079 |
// millisecond must be >= 0 millisecond <= 1000 |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1080 |
BigDecimal realMilliseconds = null; // undefined value |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1081 |
if (milliseconds != DatatypeConstants.FIELD_UNDEFINED) { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1082 |
if (milliseconds < 0 || milliseconds > 1000) { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1083 |
throw new IllegalArgumentException( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1084 |
"javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendarTime(" |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1085 |
+ "int hours, int minutes, int seconds, int milliseconds, int timezone)" |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1086 |
+ "with invalid milliseconds: " + milliseconds |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1087 |
); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1088 |
} |
12005 | 1089 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1090 |
realMilliseconds = BigDecimal.valueOf((long) milliseconds).movePointLeft(3); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1091 |
} |
12005 | 1092 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1093 |
return newXMLGregorianCalendarTime( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1094 |
hours, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1095 |
minutes, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1096 |
seconds, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1097 |
realMilliseconds, |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1098 |
timezone |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1099 |
); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
1100 |
} |
12005 | 1101 |
} |