src/java.xml/share/classes/javax/xml/datatype/DatatypeFactory.java
author joehw
Thu, 21 Dec 2017 17:08:05 -0800
changeset 48412 d4412e380f6b
parent 47216 71c04702a3d5
child 54342 07212a29787a
permissions -rw-r--r--
8184431: References to @sun.com Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     1
/*
45261
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 42390
diff changeset
     2
 * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     4
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    10
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    15
 * accompanied this code).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    16
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    20
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    23
 * questions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    24
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    25
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    26
package javax.xml.datatype;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    27
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
    28
import java.math.BigDecimal;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    29
import java.math.BigInteger;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    30
import java.util.GregorianCalendar;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    31
import java.util.regex.Matcher;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    34
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    35
/**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
    36
 * Factory that creates new {@code javax.xml.datatype} {@code Object}s that map XML to/from Java {@code Object}s.
46069
e649630dec00 8185464: Link issues in java.xml module
jjg
parents: 45855
diff changeset
    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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    40
 * <ol>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    44
 *      Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    45
 *    </li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    59
 *    </li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    74
 *    </li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    78
 *      {@link #DATATYPEFACTORY_IMPLEMENTATION_CLASS}.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    79
 *      Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    80
 *    </li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    81
 * </ol>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    82
 *
48412
d4412e380f6b 8184431: References to @sun.com
joehw
parents: 47216
diff changeset
    83
 * @author Joseph Fialli
d4412e380f6b 8184431: References to @sun.com
joehw
parents: 47216
diff changeset
    84
 * @author Jeff Suttor
d4412e380f6b 8184431: References to @sun.com
joehw
parents: 47216
diff changeset
    85
 * @author Neeraj Bajaj
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    86
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    87
 * @since 1.5
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    88
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    89
public abstract class DatatypeFactory {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    90
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
    91
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
    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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
    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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   101
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   102
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   103
     * Default implementation class name as defined in
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   117
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   118
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   119
     * http://www.w3.org/TR/xpath-datamodel/#xdtschema defines two regexps
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   120
     * to constrain the value space of dayTimeDuration ([^YM]*[DT].*)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   121
     * and yearMonthDuration ([^DT]*). Note that these expressions rely on
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   122
     * the fact that the value must be an xs:Duration, they simply exclude
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   123
     * some Durations.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   124
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   125
    private static final Pattern XDTSCHEMA_YMD =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   126
        Pattern.compile("[^DT]*");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   127
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   128
    private static final Pattern XDTSCHEMA_DTD =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   129
        Pattern.compile("[^YM]*[DT].*");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   130
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   131
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   156
     * <p>The implementation resolution mechanisms are <a href="#DatatypeFactory.newInstance">defined</a> in this
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   163
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   175
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   176
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   177
     * Obtain a new instance of a {@code DatatypeFactory} from class name.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   178
     * This function is useful when there are multiple providers in the classpath.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   179
     * It gives more control to the application as it can specify which provider
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   180
     * should be loaded.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   183
     * it can use the factory to configure and obtain datatype instances.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   184
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   185
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   186
     * <h2>Tip for Trouble-shooting</h2>
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   187
     * <p>Setting the {@code jaxp.debug} system property will cause
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   188
     * this method to print a lot of debug messages
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   189
     * to {@code System.err} about what it is doing and where it is looking at.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   190
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   191
     * <p> If you have problems try:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   192
     * <pre>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   193
     * java -Djaxp.debug=1 YourProgram ....
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   194
     * </pre>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   197
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   198
     * @param classLoader {@code ClassLoader} used to load the factory class. If {@code null}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   199
     *                     current {@code Thread}'s context classLoader is used to load the factory class.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   202
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   203
     * @throws DatatypeConfigurationException if {@code factoryClassName} is {@code null}, or
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   204
     *                                   the factory class cannot be loaded, instantiated.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   205
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   206
     * @see #newInstance()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   207
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   208
     * @since 1.6
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   209
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   210
    public static DatatypeFactory newInstance(String factoryClassName, ClassLoader classLoader)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   215
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   216
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   217
     * Obtain a new instance of a {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   218
     * specifying the {@code Duration} as its string representation, "PnYnMnDTnHnMnS",
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   229
     * <p>All six values are set and available from the created {@link Duration}
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   230
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   231
     * <p>The XML Schema specification states that values can be of an arbitrary size.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   232
     * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   233
     * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   234
     * if implementation capacities are exceeded.
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   235
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   245
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   246
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   247
     * Obtain a new instance of a {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   258
     * <p>All six values are set by computing their values from the specified milliseconds
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   259
     * and are available using the {@code get} methods of  the created {@link Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   260
     * The values conform to and are defined by:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   261
     * <ul>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   262
     *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   263
     *   <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats">
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   264
     *     W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   265
     *   </li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   266
     *   <li>{@link XMLGregorianCalendar}  Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation</li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   282
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   283
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   284
     * Obtain a new instance of a {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   287
     * <p>The XML Schema specification states that values can be of an arbitrary size.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   288
     * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   289
     * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   290
     * if implementation capacities are exceeded.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   291
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   292
     * <p>A {@code null} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   293
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   296
     * @param years of this {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   297
     * @param months of this {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   298
     * @param days of this {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   299
     * @param hours of this {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   300
     * @param minutes of this {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   318
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   319
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   320
     * Obtain a new instance of a {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   323
     * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   324
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   325
     * @param isPositive Set to {@code false} to create a negative duration. When the length
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   326
     *   of the duration is zero, this parameter will be ignored.
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   327
     * @param years of this {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   328
     * @param months of this {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   329
     * @param days of this {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   330
     * @param hours of this {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   331
     * @param minutes of this {@code Duration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   332
     * @param seconds of this {@code Duration}
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   333
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   385
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   386
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   387
     * Create a {@code Duration} of type {@code xdt:dayTimeDuration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   398
     * <p>The XML Schema specification states that values can be of an arbitrary size.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   399
     * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   400
     * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   401
     * if implementation capacities are exceeded.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   407
     * @throws IllegalArgumentException If {@code lexicalRepresentation} is
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   418
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   433
     * Create a {@code Duration} of type {@code xdt:dayTimeDuration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   442
     * <p>All four values are set by computing their values from the specified milliseconds
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   443
     * and are available using the {@code get} methods of  the created {@link Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   444
     * The values conform to and are defined by:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   445
     * <ul>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   446
     *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   447
     *   <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats">
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   448
     *     W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   449
     *   </li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   450
     *   <li>{@link XMLGregorianCalendar}  Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation</li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   461
     * <p>Any remaining milliseconds after determining the day, hour, minute and second are discarded.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   462
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   474
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   475
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   476
     * Create a {@code Duration} of type {@code xdt:dayTimeDuration} using the specified
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   485
     * <p>The XML Schema specification states that values can be of an arbitrary size.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   486
     * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   487
     * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   488
     * if implementation capacities are exceeded.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   489
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   490
     * <p>A {@code null} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   491
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   492
     * @param isPositive Set to {@code false} to create a negative duration. When the length
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   493
     *   of the duration is zero, this parameter will be ignored.
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   494
     * @param day Day of {@code Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   495
     * @param hour Hour of {@code Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   496
     * @param minute Minute of {@code Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   499
     * @return New {@code Duration} created with the specified {@code day}, {@code hour}, {@code minute}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   524
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   525
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   526
     * Create a {@code Duration} of type {@code xdt:dayTimeDuration} using the specified
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   535
     * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   536
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   537
     * @param isPositive Set to {@code false} to create a negative duration. When the length
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   538
     *   of the duration is zero, this parameter will be ignored.
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   539
     * @param day Day of {@code Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   540
     * @param hour Hour of {@code Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   541
     * @param minute Minute of {@code Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   544
     * @return New {@code Duration} created with the specified {@code day}, {@code hour}, {@code minute}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   565
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   566
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   567
     * Create a {@code Duration} of type {@code xdt:yearMonthDuration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   578
     * <p>The XML Schema specification states that values can be of an arbitrary size.
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   579
     * Implementations may chose not to or be incapable of supporting
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   580
     * arbitrarily large and/or small values. An {@link UnsupportedOperationException}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   581
     * will be thrown with a message indicating implementation limits
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   582
     * if implementation capacities are exceeded.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   592
    public Duration newDurationYearMonth(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   593
            final String lexicalRepresentation) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   594
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   595
        // lexicalRepresentation must be non-null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   596
        if (lexicalRepresentation == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   597
            throw new NullPointerException(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   598
                    "Trying to create an xdt:yearMonthDuration with an invalid"
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   599
                    + " lexical representation of \"null\"");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   600
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   601
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   602
        // test lexicalRepresentation against spec regex
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   603
        Matcher matcher = XDTSCHEMA_YMD.matcher(lexicalRepresentation);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   604
        if (!matcher.matches()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   605
            throw new IllegalArgumentException(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   606
                    "Trying to create an xdt:yearMonthDuration with an invalid"
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   607
                    + " lexical representation of \"" + lexicalRepresentation
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   608
                    + "\", data model requires days and times only.");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   609
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   610
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   611
        return newDuration(lexicalRepresentation);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   612
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   613
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   614
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   615
     * Create a {@code Duration} of type {@code xdt:yearMonthDuration}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   624
     * <p>Both values are set by computing their values from the specified milliseconds
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   625
     * and are available using the {@code get} methods of  the created {@link Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   626
     * The values conform to and are defined by:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   627
     * <ul>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   628
     *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   629
     *   <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats">
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   630
     *     W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   631
     *   </li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   632
     *   <li>{@link XMLGregorianCalendar}  Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation</li>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   633
     * </ul>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   649
    public Duration newDurationYearMonth(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   650
            final long durationInMilliseconds) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   651
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   652
        // create a Duration that only has sign, year & month
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   653
        // Duration is immutable, so need to create a new Duration
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   654
        // implementations may override this method in a more efficient way
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   655
        Duration fullDuration = newDuration(durationInMilliseconds);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   656
        boolean isPositive = (fullDuration.getSign() == -1) ? false : true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   657
        BigInteger years =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   658
            (BigInteger) fullDuration.getField(DatatypeConstants.YEARS);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   659
        if (years == null) { years = BigInteger.ZERO; }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   660
        BigInteger months =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   661
            (BigInteger) fullDuration.getField(DatatypeConstants.MONTHS);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   662
        if (months == null) { months = BigInteger.ZERO; }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   663
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   664
        return newDurationYearMonth(isPositive, years, months);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   665
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   666
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   667
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   668
     * Create a {@code Duration} of type {@code xdt:yearMonthDuration} using the specified
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   673
     * <p>The XML Schema specification states that values can be of an arbitrary size.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   674
     * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   675
     * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   676
     * if implementation capacities are exceeded.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   677
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   678
     * <p>A {@code null} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   679
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   680
     * @param isPositive Set to {@code false} to create a negative duration. When the length
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   681
     *   of the duration is zero, this parameter will be ignored.
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   682
     * @param year Year of {@code Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   707
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   708
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   709
     * Create a {@code Duration} of type {@code xdt:yearMonthDuration} using the specified
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   714
     * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   715
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   716
     * @param isPositive Set to {@code false} to create a negative duration. When the length
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   717
     *   of the duration is zero, this parameter will be ignored.
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   718
     * @param year Year of {@code Duration}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   736
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   737
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   740
     * <p>All date/time datatype fields set to {@link DatatypeConstants#FIELD_UNDEFINED} or null.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   741
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   742
     * @return New {@code XMLGregorianCalendar} with all date/time datatype fields set to
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   746
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   747
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   750
     * <p>Parsing the lexical string representation is defined in
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   752
     * <em>Lexical Representation</em>.</a>
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   753
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   754
     * <p>The string representation may not have any leading and trailing whitespaces.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   755
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   756
     * <p>The parsing is done field by field so that
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   757
     * the following holds for any lexically correct String x:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   758
     * <pre>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   759
     * newXMLGregorianCalendar(x).toXMLFormat().equals(x)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   760
     * </pre>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   761
     * <p>Except for the noted lexical/canonical representation mismatches
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   762
     * listed in <a href="http://www.w3.org/2001/05/xmlschema-errata#e2-45">
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   769
     * @throws IllegalArgumentException If the {@code lexicalRepresentation} is not a valid {@code XMLGregorianCalendar}.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   773
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   774
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 42390
diff changeset
   777
     * <table class="striped">
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 42390
diff changeset
   778
     *   <caption>Field by Field Conversion from
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 42390
diff changeset
   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
46c3f654e80f 8184021: Fix tables in doc comments to be accessible
jjg
parents: 45261
diff changeset
   782
     *        <th scope="col">{@code java.util.GregorianCalendar} field</th>
46c3f654e80f 8184021: Fix tables in doc comments to be accessible
jjg
parents: 45261
diff changeset
   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
46c3f654e80f 8184021: Fix tables in doc comments to be accessible
jjg
parents: 45261
diff changeset
   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
46c3f654e80f 8184021: Fix tables in doc comments to be accessible
jjg
parents: 45261
diff changeset
   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
46c3f654e80f 8184021: Fix tables in doc comments to be accessible
jjg
parents: 45261
diff changeset
   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
46c3f654e80f 8184021: Fix tables in doc comments to be accessible
jjg
parents: 45261
diff changeset
   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
46c3f654e80f 8184021: Fix tables in doc comments to be accessible
jjg
parents: 45261
diff changeset
   804
     *       <th scope="row">
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
46c3f654e80f 8184021: Fix tables in doc comments to be accessible
jjg
parents: 45261
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   814
     * a {@code java.util.GregorianCalendar} daylight savings timezone id in the
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   819
     * <li>when {@code this.getTimezone() != FIELD_UNDEFINED},
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   820
     * create a {@code java.util.TimeZone} with a custom timezone id
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   821
     * using the {@code this.getTimezone()}.</li>
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   824
     * {@code java.util.TimeZone.getDefault()}.</li>
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   825
     * </ul>
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   826
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   829
     * @return {@code XMLGregorianCalendar} created from {@code java.util.GregorianCalendar}
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   830
     *
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   834
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   835
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   840
     * precision.
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   841
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   842
     * <p>A {@code null} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   843
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   844
     * @param year of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   845
     * @param month of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   846
     * @param day of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   847
     * @param hour of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   848
     * @param minute of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   849
     * @param second of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   850
     * @param fractionalSecond of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   869
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   870
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   871
     * Constructor of value spaces that a
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   872
     * {@code java.util.GregorianCalendar} instance would need to convert to an
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   873
     * {@code XMLGregorianCalendar} instance.
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   874
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   875
     * <p>{@code XMLGregorianCalendar eon} and
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   878
     * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   879
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   880
     * @param year of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   881
     * @param month of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   882
     * @param day of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   883
     * @param hour of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   884
     * @param minute of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   885
     * @param second of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   886
     * @param millisecond of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   935
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   936
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   939
     * <p>For example, an instance of {@code gYear} can be created invoking this factory
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   940
     * with {@code month} and {@code day} parameters set to
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   941
     * {@link DatatypeConstants#FIELD_UNDEFINED}.
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   942
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   943
     * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   944
     *
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   945
     * @param year of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   946
     * @param month of {@code XMLGregorianCalendar} to be created.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   975
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
   976
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   979
     * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
   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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1011
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
  1012
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
  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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
  1015
     * <p>A {@code null} value indicates that field is not set.
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
  1016
     * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
  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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
  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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
  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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1050
17264
3aff554ad461 8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents: 12457
diff changeset
  1051
    /**
29999
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
  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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
  1054
     * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
  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
8493f5fc1052 8077332: tidy warnings from javax/xml
avstepan
parents: 29419
diff changeset
  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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1101
}