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