jaxp/src/java.xml/share/classes/javax/xml/datatype/DatatypeFactory.java
changeset 29999 8493f5fc1052
parent 29419 534054ee6062
child 42390 4083bc2c3b5b
equal deleted inserted replaced
29963:ac3f5a39d4ff 29999:8493f5fc1052
    30 import java.util.GregorianCalendar;
    30 import java.util.GregorianCalendar;
    31 import java.util.regex.Matcher;
    31 import java.util.regex.Matcher;
    32 import java.util.regex.Pattern;
    32 import java.util.regex.Pattern;
    33 
    33 
    34 /**
    34 /**
    35  * Factory that creates new <code>javax.xml.datatype</code> <code>Object</code>s that map XML to/from Java <code>Object</code>s.
    35  * Factory that creates new {@code javax.xml.datatype} {@code Object}s that map XML to/from Java {@code Object}s.
    36  * <p>
    36  * <p>
    37  * A new instance of the {@code DatatypeFactory} is created through the {@link #newInstance()} method
    37  * A new instance of the {@code DatatypeFactory} is created through the {@link #newInstance()} method
    38  * that uses the following implementation resolution mechanisms to determine an implementation:
    38  * that uses the following implementation resolution mechanisms to determine an implementation:
    39  * <p>
       
    40  * <ol>
    39  * <ol>
    41  *    <li>
    40  *    <li>
    42  *      If the system property specified by {@link #DATATYPEFACTORY_PROPERTY}, "{@code javax.xml.datatype.DatatypeFactory}",
    41  *      If the system property specified by {@link #DATATYPEFACTORY_PROPERTY}, "{@code javax.xml.datatype.DatatypeFactory}",
    43  *      exists, a class with the name of the property value is instantiated.
    42  *      exists, a class with the name of the property value is instantiated.
    44  *      Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}.
    43  *      Any Exception thrown during the instantiation process is wrapped as a {@link DatatypeConfigurationException}.
    87  * @since 1.5
    86  * @since 1.5
    88  */
    87  */
    89 public abstract class DatatypeFactory {
    88 public abstract class DatatypeFactory {
    90 
    89 
    91     /**
    90     /**
    92      * <p>Default property name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3.</p>
    91      * Default property name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3.
    93      *
    92      *
    94      * <p>Default value is {@code javax.xml.datatype.DatatypeFactory}.</p>
    93      * <p>Default value is {@code javax.xml.datatype.DatatypeFactory}.
    95      */
    94      */
    96     public static final String DATATYPEFACTORY_PROPERTY =
    95     public static final String DATATYPEFACTORY_PROPERTY =
    97             // We use a String constant here, rather than calling
    96             // We use a String constant here, rather than calling
    98             // DatatypeFactory.class.getName() - in order to make javadoc
    97             // DatatypeFactory.class.getName() - in order to make javadoc
    99             // generate a See Also: Constant Field Value link.
    98             // generate a See Also: Constant Field Value link.
   100             "javax.xml.datatype.DatatypeFactory";
    99             "javax.xml.datatype.DatatypeFactory";
   101 
   100 
   102     /**
   101     /**
   103      * <p>Default implementation class name as defined in
   102      * Default implementation class name as defined in
   104      * <em>JSR 206: Java(TM) API for XML Processing (JAXP) 1.3</em>.</p>
   103      * <em>JSR 206: Java(TM) API for XML Processing (JAXP) 1.3</em>.
   105      *
   104      *
   106      * <p>Implementers should specify the name of an appropriate class
   105      * <p>Implementers should specify the name of an appropriate class
   107      * to be instantiated if no other implementation resolution mechanism
   106      * to be instantiated if no other implementation resolution mechanism
   108      * succeeds.</p>
   107      * succeeds.
   109      *
   108      *
   110      * <p>Users should not refer to this field; it is intended only to
   109      * <p>Users should not refer to this field; it is intended only to
   111      * document a factory implementation detail.
   110      * document a factory implementation detail.
   112      * </p>
       
   113      */
   111      */
   114     public static final String DATATYPEFACTORY_IMPLEMENTATION_CLASS =
   112     public static final String DATATYPEFACTORY_IMPLEMENTATION_CLASS =
   115         // We use new String() here to prevent javadoc from generating
   113         // We use new String() here to prevent javadoc from generating
   116         // a See Also: Constant Field Value link.
   114         // a See Also: Constant Field Value link.
   117         new String("com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl");
   115         new String("com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl");
   128 
   126 
   129     private static final Pattern XDTSCHEMA_DTD =
   127     private static final Pattern XDTSCHEMA_DTD =
   130         Pattern.compile("[^YM]*[DT].*");
   128         Pattern.compile("[^YM]*[DT].*");
   131 
   129 
   132     /**
   130     /**
   133      * <p>Protected constructor to prevent instantiation outside of package.</p>
   131      * Protected constructor to prevent instantiation outside of package.
   134      *
   132      *
   135      * <p>Use {@link #newInstance()} to create a {@code DatatypeFactory}.</p>
   133      * <p>Use {@link #newInstance()} to create a {@code DatatypeFactory}.
   136      */
   134      */
   137     protected DatatypeFactory() {
   135     protected DatatypeFactory() {
   138     }
   136     }
   139 
   137 
   140     /**
   138     /**
   141      * <p>Obtain a new instance of a {@code DatatypeFactory}.</p>
   139      * Obtain a new instance of a {@code DatatypeFactory}.
   142      *
   140      *
   143      * <p>The implementation resolution mechanisms are <a href="#DatatypeFactory.newInstance">defined</a> in this
   141      * <p>The implementation resolution mechanisms are <a href="#DatatypeFactory.newInstance">defined</a> in this
   144      * <code>Class</code>'s documentation.</p>
   142      * {@code Class}'s documentation.
   145      *
   143      *
   146      * @return New instance of a {@code DatatypeFactory}
   144      * @return New instance of a {@code DatatypeFactory}
   147      *
   145      *
   148      * @throws DatatypeConfigurationException If the implementation is not
   146      * @throws DatatypeConfigurationException If the implementation is not
   149      *   available or cannot be instantiated.
   147      *   available or cannot be instantiated.
   159                     /* The fallback implementation class name */
   157                     /* The fallback implementation class name */
   160                     DATATYPEFACTORY_IMPLEMENTATION_CLASS);
   158                     DATATYPEFACTORY_IMPLEMENTATION_CLASS);
   161     }
   159     }
   162 
   160 
   163     /**
   161     /**
   164      * <p>Obtain a new instance of a {@code DatatypeFactory} from class name.
   162      * Obtain a new instance of a {@code DatatypeFactory} from class name.
   165      * This function is useful when there are multiple providers in the classpath.
   163      * This function is useful when there are multiple providers in the classpath.
   166      * It gives more control to the application as it can specify which provider
   164      * It gives more control to the application as it can specify which provider
   167      * should be loaded.</p>
   165      * should be loaded.
   168      *
   166      *
   169      * <p>Once an application has obtained a reference to a {@code DatatypeFactory}
   167      * <p>Once an application has obtained a reference to a {@code DatatypeFactory}
   170      * it can use the factory to configure and obtain datatype instances.</P>
   168      * it can use the factory to configure and obtain datatype instances.
   171      *
   169      *
   172      *
   170      *
   173      * <h2>Tip for Trouble-shooting</h2>
   171      * <h2>Tip for Trouble-shooting</h2>
   174      * <p>Setting the <code>jaxp.debug</code> system property will cause
   172      * <p>Setting the {@code jaxp.debug} system property will cause
   175      * this method to print a lot of debug messages
   173      * this method to print a lot of debug messages
   176      * to <code>System.err</code> about what it is doing and where it is looking at.</p>
   174      * to {@code System.err} about what it is doing and where it is looking at.
   177      *
   175      *
   178      * <p> If you have problems try:</p>
   176      * <p> If you have problems try:
   179      * <pre>
   177      * <pre>
   180      * java -Djaxp.debug=1 YourProgram ....
   178      * java -Djaxp.debug=1 YourProgram ....
   181      * </pre>
   179      * </pre>
   182      *
   180      *
   183      * @param factoryClassName fully qualified factory class name that provides implementation of {@code javax.xml.datatype.DatatypeFactory}.
   181      * @param factoryClassName fully qualified factory class name that provides implementation of {@code javax.xml.datatype.DatatypeFactory}.
   184      *
   182      *
   185      * @param classLoader <code>ClassLoader</code> used to load the factory class. If <code>null</code>
   183      * @param classLoader {@code ClassLoader} used to load the factory class. If {@code null}
   186      *                     current <code>Thread</code>'s context classLoader is used to load the factory class.
   184      *                     current {@code Thread}'s context classLoader is used to load the factory class.
   187      *
   185      *
   188      * @return New instance of a {@code DatatypeFactory}
   186      * @return New instance of a {@code DatatypeFactory}
   189      *
   187      *
   190      * @throws DatatypeConfigurationException if <code>factoryClassName</code> is <code>null</code>, or
   188      * @throws DatatypeConfigurationException if {@code factoryClassName} is {@code null}, or
   191      *                                   the factory class cannot be loaded, instantiated.
   189      *                                   the factory class cannot be loaded, instantiated.
   192      *
   190      *
   193      * @see #newInstance()
   191      * @see #newInstance()
   194      *
   192      *
   195      * @since 1.6
   193      * @since 1.6
   199         return FactoryFinder.newInstance(DatatypeFactory.class,
   197         return FactoryFinder.newInstance(DatatypeFactory.class,
   200                     factoryClassName, classLoader, false);
   198                     factoryClassName, classLoader, false);
   201      }
   199      }
   202 
   200 
   203     /**
   201     /**
   204      * <p>Obtain a new instance of a <code>Duration</code>
   202      * Obtain a new instance of a {@code Duration}
   205      * specifying the <code>Duration</code> as its string representation, "PnYnMnDTnHnMnS",
   203      * specifying the {@code Duration} as its string representation, "PnYnMnDTnHnMnS",
   206      * as defined in XML Schema 1.0 section 3.2.6.1.</p>
   204      * as defined in XML Schema 1.0 section 3.2.6.1.
   207      *
   205      *
   208      * <p>XML Schema Part 2: Datatypes, 3.2.6 duration, defines <code>duration</code> as:</p>
   206      * <p>XML Schema Part 2: Datatypes, 3.2.6 duration, defines {@code duration} as:
   209      * <blockquote>
   207      * <blockquote>
   210      * duration represents a duration of time.
   208      * duration represents a duration of time.
   211      * The value space of duration is a six-dimensional space where the coordinates designate the
   209      * The value space of duration is a six-dimensional space where the coordinates designate the
   212      * Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively.
   210      * Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively.
   213      * These components are ordered in their significance by their order of appearance i.e. as
   211      * These components are ordered in their significance by their order of appearance i.e. as
   214      * year, month, day, hour, minute, and second.
   212      * year, month, day, hour, minute, and second.
   215      * </blockquote>
   213      * </blockquote>
   216      * <p>All six values are set and available from the created {@link Duration}</p>
   214      * <p>All six values are set and available from the created {@link Duration}
   217      *
   215      *
   218      * <p>The XML Schema specification states that values can be of an arbitrary size.
   216      * <p>The XML Schema specification states that values can be of an arbitrary size.
   219      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   217      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   220      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   218      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   221      * if implementation capacities are exceeded.</p>
   219      * if implementation capacities are exceeded.
   222      *
   220      *
   223      * @param lexicalRepresentation <code>String</code> representation of a <code>Duration</code>.
   221      * @param lexicalRepresentation {@code String} representation of a {@code Duration}.
   224      *
   222      *
   225      * @return New <code>Duration</code> created from parsing the <code>lexicalRepresentation</code>.
   223      * @return New {@code Duration} created from parsing the {@code lexicalRepresentation}.
   226      *
   224      *
   227      * @throws IllegalArgumentException If <code>lexicalRepresentation</code> is not a valid representation of a <code>Duration</code>.
   225      * @throws IllegalArgumentException If {@code lexicalRepresentation} is not a valid representation of a {@code Duration}.
   228      * @throws UnsupportedOperationException If implementation cannot support requested values.
   226      * @throws UnsupportedOperationException If implementation cannot support requested values.
   229      * @throws NullPointerException if <code>lexicalRepresentation</code> is <code>null</code>.
   227      * @throws NullPointerException if {@code lexicalRepresentation} is {@code null}.
   230      */
   228      */
   231     public abstract Duration newDuration(final String lexicalRepresentation);
   229     public abstract Duration newDuration(final String lexicalRepresentation);
   232 
   230 
   233     /**
   231     /**
   234      * <p>Obtain a new instance of a <code>Duration</code>
   232      * Obtain a new instance of a {@code Duration}
   235      * specifying the <code>Duration</code> as milliseconds.</p>
   233      * specifying the {@code Duration} as milliseconds.
   236      *
   234      *
   237      * <p>XML Schema Part 2: Datatypes, 3.2.6 duration, defines <code>duration</code> as:</p>
   235      * <p>XML Schema Part 2: Datatypes, 3.2.6 duration, defines {@code duration} as:
   238      * <blockquote>
   236      * <blockquote>
   239      * duration represents a duration of time.
   237      * duration represents a duration of time.
   240      * The value space of duration is a six-dimensional space where the coordinates designate the
   238      * The value space of duration is a six-dimensional space where the coordinates designate the
   241      * Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively.
   239      * Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of [ISO 8601], respectively.
   242      * These components are ordered in their significance by their order of appearance i.e. as
   240      * These components are ordered in their significance by their order of appearance i.e. as
   243      * year, month, day, hour, minute, and second.
   241      * year, month, day, hour, minute, and second.
   244      * </blockquote>
   242      * </blockquote>
   245      * <p>All six values are set by computing their values from the specified milliseconds
   243      * <p>All six values are set by computing their values from the specified milliseconds
   246      * and are available using the <code>get</code> methods of  the created {@link Duration}.
   244      * and are available using the {@code get} methods of  the created {@link Duration}.
   247      * The values conform to and are defined by:</p>
   245      * The values conform to and are defined by:
   248      * <ul>
   246      * <ul>
   249      *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
   247      *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
   250      *   <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats">
   248      *   <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats">
   251      *     W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a>
   249      *     W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a>
   252      *   </li>
   250      *   </li>
   257      * {@link java.util.Calendar#YEAR} = 1970,
   255      * {@link java.util.Calendar#YEAR} = 1970,
   258      * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
   256      * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
   259      * {@link java.util.Calendar#DATE} = 1, etc.
   257      * {@link java.util.Calendar#DATE} = 1, etc.
   260      * This is important as there are variations in the Gregorian Calendar,
   258      * This is important as there are variations in the Gregorian Calendar,
   261      * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
   259      * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
   262      * so the result of {@link Duration#getMonths()} and {@link Duration#getDays()} can be influenced.</p>
   260      * so the result of {@link Duration#getMonths()} and {@link Duration#getDays()} can be influenced.
   263      *
   261      *
   264      * @param durationInMilliSeconds Duration in milliseconds to create.
   262      * @param durationInMilliSeconds Duration in milliseconds to create.
   265      *
   263      *
   266      * @return New <code>Duration</code> representing <code>durationInMilliSeconds</code>.
   264      * @return New {@code Duration} representing {@code durationInMilliSeconds}.
   267      */
   265      */
   268     public abstract Duration newDuration(final long durationInMilliSeconds);
   266     public abstract Duration newDuration(final long durationInMilliSeconds);
   269 
   267 
   270     /**
   268     /**
   271      * <p>Obtain a new instance of a <code>Duration</code>
   269      * Obtain a new instance of a {@code Duration}
   272      * specifying the <code>Duration</code> as isPositive, years, months, days, hours, minutes, seconds.</p>
   270      * specifying the {@code Duration} as isPositive, years, months, days, hours, minutes, seconds.
   273      *
   271      *
   274      * <p>The XML Schema specification states that values can be of an arbitrary size.
   272      * <p>The XML Schema specification states that values can be of an arbitrary size.
   275      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   273      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   276      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   274      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   277      * if implementation capacities are exceeded.</p>
   275      * if implementation capacities are exceeded.
   278      *
   276      *
   279      * <p>A <code>null</code> value indicates that field is not set.</p>
   277      * <p>A {@code null} value indicates that field is not set.
   280      *
   278      *
   281      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
   279      * @param isPositive Set to {@code false} to create a negative duration. When the length
   282      *   of the duration is zero, this parameter will be ignored.
   280      *   of the duration is zero, this parameter will be ignored.
   283      * @param years of this <code>Duration</code>
   281      * @param years of this {@code Duration}
   284      * @param months of this <code>Duration</code>
   282      * @param months of this {@code Duration}
   285      * @param days of this <code>Duration</code>
   283      * @param days of this {@code Duration}
   286      * @param hours of this <code>Duration</code>
   284      * @param hours of this {@code Duration}
   287      * @param minutes of this <code>Duration</code>
   285      * @param minutes of this {@code Duration}
   288      * @param seconds of this <code>Duration</code>
   286      * @param seconds of this {@code Duration}
   289      *
   287      *
   290      * @return New <code>Duration</code> created from the specified values.
   288      * @return New {@code Duration} created from the specified values.
   291      *
   289      *
   292      * @throws IllegalArgumentException If the values are not a valid representation of a
   290      * @throws IllegalArgumentException If the values are not a valid representation of a
   293      * <code>Duration</code>: if all the fields (years, months, ...) are null or
   291      * {@code Duration}: if all the fields (years, months, ...) are null or
   294      * if any of the fields is negative.
   292      * if any of the fields is negative.
   295      * @throws UnsupportedOperationException If implementation cannot support requested values.
   293      * @throws UnsupportedOperationException If implementation cannot support requested values.
   296      */
   294      */
   297     public abstract Duration newDuration(
   295     public abstract Duration newDuration(
   298             final boolean isPositive,
   296             final boolean isPositive,
   302             final BigInteger hours,
   300             final BigInteger hours,
   303             final BigInteger minutes,
   301             final BigInteger minutes,
   304             final BigDecimal seconds);
   302             final BigDecimal seconds);
   305 
   303 
   306     /**
   304     /**
   307      * <p>Obtain a new instance of a <code>Duration</code>
   305      * Obtain a new instance of a {@code Duration}
   308      * specifying the <code>Duration</code> as isPositive, years, months, days, hours, minutes, seconds.</p>
   306      * specifying the {@code Duration} as isPositive, years, months, days, hours, minutes, seconds.
   309      *
   307      *
   310      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
   308      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
   311      *
   309      *
   312      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
   310      * @param isPositive Set to {@code false} to create a negative duration. When the length
   313      *   of the duration is zero, this parameter will be ignored.
   311      *   of the duration is zero, this parameter will be ignored.
   314      * @param years of this <code>Duration</code>
   312      * @param years of this {@code Duration}
   315      * @param months of this <code>Duration</code>
   313      * @param months of this {@code Duration}
   316      * @param days of this <code>Duration</code>
   314      * @param days of this {@code Duration}
   317      * @param hours of this <code>Duration</code>
   315      * @param hours of this {@code Duration}
   318      * @param minutes of this <code>Duration</code>
   316      * @param minutes of this {@code Duration}
   319      * @param seconds of this <code>Duration</code>
   317      * @param seconds of this {@code Duration}
   320      *
   318      *
   321      * @return New <code>Duration</code> created from the specified values.
   319      * @return New {@code Duration} created from the specified values.
   322      *
   320      *
   323      * @throws IllegalArgumentException If the values are not a valid representation of a
   321      * @throws IllegalArgumentException If the values are not a valid representation of a
   324      * <code>Duration</code>: if any of the fields is negative.
   322      * {@code Duration}: if any of the fields is negative.
   325      *
   323      *
   326      * @see #newDuration(
   324      * @see #newDuration(
   327      *   boolean isPositive,
   325      *   boolean isPositive,
   328      *   BigInteger years,
   326      *   BigInteger years,
   329      *   BigInteger months,
   327      *   BigInteger months,
   369                             realSeconds
   367                             realSeconds
   370                     );
   368                     );
   371             }
   369             }
   372 
   370 
   373     /**
   371     /**
   374      * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> by parsing its <code>String</code> representation,
   372      * Create a {@code Duration} of type {@code xdt:dayTimeDuration}
       
   373      * by parsing its {@code String} representation,
   375      * "<em>PnDTnHnMnS</em>", <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
   374      * "<em>PnDTnHnMnS</em>", <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
   376      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
   375      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.
   377      *
   376      *
   378      * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
   377      * <p>The datatype {@code xdt:dayTimeDuration} is a subtype of {@code xs:duration}
   379      * whose lexical representation contains only day, hour, minute, and second components.
   378      * whose lexical representation contains only day, hour, minute, and second components.
   380      * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
   379      * This datatype resides in the namespace {@code http://www.w3.org/2003/11/xpath-datatypes}.
   381      *
   380      *
   382      * <p>All four values are set and available from the created {@link Duration}</p>
   381      * <p>All four values are set and available from the created {@link Duration}
   383      *
   382      *
   384      * <p>The XML Schema specification states that values can be of an arbitrary size.
   383      * <p>The XML Schema specification states that values can be of an arbitrary size.
   385      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   384      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   386      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   385      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   387      * if implementation capacities are exceeded.</p>
   386      * if implementation capacities are exceeded.
   388      *
   387      *
   389      * @param lexicalRepresentation Lexical representation of a duration.
   388      * @param lexicalRepresentation Lexical representation of a duration.
   390      *
   389      *
   391      * @return New <code>Duration</code> created using the specified <code>lexicalRepresentation</code>.
   390      * @return New {@code Duration} created using the specified {@code lexicalRepresentation}.
   392      *
   391      *
   393      * @throws IllegalArgumentException If <code>lexicalRepresentation</code> is not a valid representation of a <code>Duration</code> expressed only in terms of days and time.
   392      * @throws IllegalArgumentException If {@code lexicalRepresentation} is
       
   393      *         not a valid representation of a {@code Duration} expressed only in terms of days and time.
   394      * @throws UnsupportedOperationException If implementation cannot support requested values.
   394      * @throws UnsupportedOperationException If implementation cannot support requested values.
   395      * @throws NullPointerException If <code>lexicalRepresentation</code> is <code>null</code>.
   395      * @throws NullPointerException If {@code lexicalRepresentation} is {@code null}.
   396      */
   396      */
   397     public Duration newDurationDayTime(final String lexicalRepresentation) {
   397     public Duration newDurationDayTime(final String lexicalRepresentation) {
   398         // lexicalRepresentation must be non-null
   398         // lexicalRepresentation must be non-null
   399         if (lexicalRepresentation == null) {
   399         if (lexicalRepresentation == null) {
   400             throw new NullPointerException(
   400             throw new NullPointerException(
   413 
   413 
   414         return newDuration(lexicalRepresentation);
   414         return newDuration(lexicalRepresentation);
   415     }
   415     }
   416 
   416 
   417     /**
   417     /**
   418      * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> using the specified milliseconds as defined in
   418      * Create a {@code Duration} of type {@code xdt:dayTimeDuration}
       
   419      * using the specified milliseconds as defined in
   419      * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
   420      * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
   420      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
   421      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.
   421      *
   422      *
   422      * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
   423      * <p>The datatype {@code xdt:dayTimeDuration} is a subtype of {@code xs:duration}
   423      * whose lexical representation contains only day, hour, minute, and second components.
   424      * whose lexical representation contains only day, hour, minute, and second components.
   424      * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
   425      * This datatype resides in the namespace {@code http://www.w3.org/2003/11/xpath-datatypes}.
   425      *
   426      *
   426      * <p>All four values are set by computing their values from the specified milliseconds
   427      * <p>All four values are set by computing their values from the specified milliseconds
   427      * and are available using the <code>get</code> methods of  the created {@link Duration}.
   428      * and are available using the {@code get} methods of  the created {@link Duration}.
   428      * The values conform to and are defined by:</p>
   429      * The values conform to and are defined by:
   429      * <ul>
   430      * <ul>
   430      *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
   431      *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
   431      *   <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats">
   432      *   <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats">
   432      *     W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a>
   433      *     W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a>
   433      *   </li>
   434      *   </li>
   438      * {@link java.util.Calendar#YEAR} = 1970,
   439      * {@link java.util.Calendar#YEAR} = 1970,
   439      * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
   440      * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
   440      * {@link java.util.Calendar#DATE} = 1, etc.
   441      * {@link java.util.Calendar#DATE} = 1, etc.
   441      * This is important as there are variations in the Gregorian Calendar,
   442      * This is important as there are variations in the Gregorian Calendar,
   442      * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
   443      * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
   443      * so the result of {@link Duration#getDays()} can be influenced.</p>
   444      * so the result of {@link Duration#getDays()} can be influenced.
   444      *
   445      *
   445      * <p>Any remaining milliseconds after determining the day, hour, minute and second are discarded.</p>
   446      * <p>Any remaining milliseconds after determining the day, hour, minute and second are discarded.
   446      *
   447      *
   447      * @param durationInMilliseconds Milliseconds of <code>Duration</code> to create.
   448      * @param durationInMilliseconds Milliseconds of {@code Duration} to create.
   448      *
   449      *
   449      * @return New <code>Duration</code> created with the specified <code>durationInMilliseconds</code>.
   450      * @return New {@code Duration} created with the specified {@code durationInMilliseconds}.
   450      *
   451      *
   451      * @see <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
   452      * @see <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
   452      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>
   453      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>
   453      */
   454      */
   454     public Duration newDurationDayTime(final long durationInMilliseconds) {
   455     public Duration newDurationDayTime(final long durationInMilliseconds) {
   455 
   456 
   456             return newDuration(durationInMilliseconds);
   457             return newDuration(durationInMilliseconds);
   457     }
   458     }
   458 
   459 
   459     /**
   460     /**
   460      * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> using the specified
   461      * Create a {@code Duration} of type {@code xdt:dayTimeDuration} using the specified
   461      * <code>day</code>, <code>hour</code>, <code>minute</code> and <code>second</code> as defined in
   462      * {@code day}, {@code hour}, {@code minute} and {@code second} as defined in
   462      * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
   463      * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
   463      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
   464      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.
   464      *
   465      *
   465      * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
   466      * <p>The datatype {@code xdt:dayTimeDuration} is a subtype of {@code xs:duration}
   466      * whose lexical representation contains only day, hour, minute, and second components.
   467      * whose lexical representation contains only day, hour, minute, and second components.
   467      * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
   468      * This datatype resides in the namespace {@code http://www.w3.org/2003/11/xpath-datatypes}.
   468      *
   469      *
   469      * <p>The XML Schema specification states that values can be of an arbitrary size.
   470      * <p>The XML Schema specification states that values can be of an arbitrary size.
   470      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   471      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   471      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   472      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   472      * if implementation capacities are exceeded.</p>
   473      * if implementation capacities are exceeded.
   473      *
   474      *
   474      * <p>A <code>null</code> value indicates that field is not set.</p>
   475      * <p>A {@code null} value indicates that field is not set.
   475      *
   476      *
   476      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
   477      * @param isPositive Set to {@code false} to create a negative duration. When the length
   477      *   of the duration is zero, this parameter will be ignored.
   478      *   of the duration is zero, this parameter will be ignored.
   478      * @param day Day of <code>Duration</code>.
   479      * @param day Day of {@code Duration}.
   479      * @param hour Hour of <code>Duration</code>.
   480      * @param hour Hour of {@code Duration}.
   480      * @param minute Minute of <code>Duration</code>.
   481      * @param minute Minute of {@code Duration}.
   481      * @param second Second of <code>Duration</code>.
   482      * @param second Second of {@code Duration}.
   482      *
   483      *
   483      * @return New <code>Duration</code> created with the specified <code>day</code>, <code>hour</code>, <code>minute</code>
   484      * @return New {@code Duration} created with the specified {@code day}, {@code hour}, {@code minute}
   484      * and <code>second</code>.
   485      * and {@code second}.
   485      *
   486      *
   486      * @throws IllegalArgumentException If the values are not a valid representation of a
   487      * @throws IllegalArgumentException If the values are not a valid representation of a
   487      * <code>Duration</code>: if all the fields (day, hour, ...) are null or
   488      * {@code Duration}: if all the fields (day, hour, ...) are null or
   488      * if any of the fields is negative.
   489      * if any of the fields is negative.
   489      * @throws UnsupportedOperationException If implementation cannot support requested values.
   490      * @throws UnsupportedOperationException If implementation cannot support requested values.
   490      */
   491      */
   491     public Duration newDurationDayTime(
   492     public Duration newDurationDayTime(
   492             final boolean isPositive,
   493             final boolean isPositive,
   505                     (second != null)? new BigDecimal(second):null
   506                     (second != null)? new BigDecimal(second):null
   506             );
   507             );
   507     }
   508     }
   508 
   509 
   509     /**
   510     /**
   510      * <p>Create a <code>Duration</code> of type <code>xdt:dayTimeDuration</code> using the specified
   511      * Create a {@code Duration} of type {@code xdt:dayTimeDuration} using the specified
   511      * <code>day</code>, <code>hour</code>, <code>minute</code> and <code>second</code> as defined in
   512      * {@code day}, {@code hour}, {@code minute} and {@code second} as defined in
   512      * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
   513      * <a href="http://www.w3.org/TR/xpath-datamodel#dayTimeDuration">
   513      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.</p>
   514      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration</a>.
   514      *
   515      *
   515      * <p>The datatype <code>xdt:dayTimeDuration</code> is a subtype of <code>xs:duration</code>
   516      * <p>The datatype {@code xdt:dayTimeDuration} is a subtype of {@code xs:duration}
   516      * whose lexical representation contains only day, hour, minute, and second components.
   517      * whose lexical representation contains only day, hour, minute, and second components.
   517      * This datatype resides in the namespace <code>http://www.w3.org/2003/11/xpath-datatypes</code>.</p>
   518      * This datatype resides in the namespace {@code http://www.w3.org/2003/11/xpath-datatypes}.
   518      *
   519      *
   519      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
   520      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
   520      *
   521      *
   521      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
   522      * @param isPositive Set to {@code false} to create a negative duration. When the length
   522      *   of the duration is zero, this parameter will be ignored.
   523      *   of the duration is zero, this parameter will be ignored.
   523      * @param day Day of <code>Duration</code>.
   524      * @param day Day of {@code Duration}.
   524      * @param hour Hour of <code>Duration</code>.
   525      * @param hour Hour of {@code Duration}.
   525      * @param minute Minute of <code>Duration</code>.
   526      * @param minute Minute of {@code Duration}.
   526      * @param second Second of <code>Duration</code>.
   527      * @param second Second of {@code Duration}.
   527      *
   528      *
   528      * @return New <code>Duration</code> created with the specified <code>day</code>, <code>hour</code>, <code>minute</code>
   529      * @return New {@code Duration} created with the specified {@code day}, {@code hour}, {@code minute}
   529      * and <code>second</code>.
   530      * and {@code second}.
   530      *
   531      *
   531      * @throws IllegalArgumentException If the values are not a valid representation of a
   532      * @throws IllegalArgumentException If the values are not a valid representation of a
   532      * <code>Duration</code>: if any of the fields (day, hour, ...) is negative.
   533      * {@code Duration}: if any of the fields (day, hour, ...) is negative.
   533      */
   534      */
   534     public Duration newDurationDayTime(
   535     public Duration newDurationDayTime(
   535             final boolean isPositive,
   536             final boolean isPositive,
   536             final int day,
   537             final int day,
   537             final int hour,
   538             final int hour,
   546                             BigInteger.valueOf((long) second)
   547                             BigInteger.valueOf((long) second)
   547                             );
   548                             );
   548             }
   549             }
   549 
   550 
   550     /**
   551     /**
   551      * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> by parsing its <code>String</code> representation,
   552      * Create a {@code Duration} of type {@code xdt:yearMonthDuration}
       
   553      * by parsing its {@code String} representation,
   552      * "<em>PnYnM</em>", <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
   554      * "<em>PnYnM</em>", <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
   553      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
   555      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.
   554      *
   556      *
   555      * <p>The datatype <code>xdt:yearMonthDuration</code> is a subtype of <code>xs:duration</code>
   557      * <p>The datatype {@code xdt:yearMonthDuration} is a subtype of {@code xs:duration}
   556      * whose lexical representation contains only year and month components.
   558      * whose lexical representation contains only year and month components.
   557      * This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}.</p>
   559      * This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}.
   558      *
   560      *
   559      * <p>Both values are set and available from the created {@link Duration}</p>
   561      * <p>Both values are set and available from the created {@link Duration}
   560      *
   562      *
   561      * <p>The XML Schema specification states that values can be of an arbitrary size.
   563      * <p>The XML Schema specification states that values can be of an arbitrary size.
   562      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   564      * Implementations may chose not to or be incapable of supporting
   563      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   565      * arbitrarily large and/or small values. An {@link UnsupportedOperationException}
   564      * if implementation capacities are exceeded.</p>
   566      * will be thrown with a message indicating implementation limits
       
   567      * if implementation capacities are exceeded.
   565      *
   568      *
   566      * @param lexicalRepresentation Lexical representation of a duration.
   569      * @param lexicalRepresentation Lexical representation of a duration.
   567      *
   570      *
   568      * @return New <code>Duration</code> created using the specified <code>lexicalRepresentation</code>.
   571      * @return New {@code Duration} created using the specified {@code lexicalRepresentation}.
   569      *
   572      *
   570      * @throws IllegalArgumentException If <code>lexicalRepresentation</code> is not a valid representation of a <code>Duration</code> expressed only in terms of years and months.
   573      * @throws IllegalArgumentException If {@code lexicalRepresentation} is not a valid representation of a {@code Duration} expressed only in terms of years and months.
   571      * @throws UnsupportedOperationException If implementation cannot support requested values.
   574      * @throws UnsupportedOperationException If implementation cannot support requested values.
   572      * @throws NullPointerException If <code>lexicalRepresentation</code> is <code>null</code>.
   575      * @throws NullPointerException If {@code lexicalRepresentation} is {@code null}.
   573      */
   576      */
   574     public Duration newDurationYearMonth(
   577     public Duration newDurationYearMonth(
   575             final String lexicalRepresentation) {
   578             final String lexicalRepresentation) {
   576 
   579 
   577         // lexicalRepresentation must be non-null
   580         // lexicalRepresentation must be non-null
   592 
   595 
   593         return newDuration(lexicalRepresentation);
   596         return newDuration(lexicalRepresentation);
   594     }
   597     }
   595 
   598 
   596     /**
   599     /**
   597      * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> using the specified milliseconds as defined in
   600      * Create a {@code Duration} of type {@code xdt:yearMonthDuration}
       
   601      * using the specified milliseconds as defined in
   598      * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
   602      * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
   599      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
   603      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.
   600      *
   604      *
   601      * <p>The datatype <code>xdt:yearMonthDuration</code> is a subtype of <code>xs:duration</code>
   605      * <p>The datatype {@code xdt:yearMonthDuration} is a subtype of {@code xs:duration}
   602      * whose lexical representation contains only year and month components.
   606      * whose lexical representation contains only year and month components.
   603      * This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}.</p>
   607      * This datatype resides in the namespace {@link javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI}.
   604      *
   608      *
   605      * <p>Both values are set by computing their values from the specified milliseconds
   609      * <p>Both values are set by computing their values from the specified milliseconds
   606      * and are available using the <code>get</code> methods of  the created {@link Duration}.
   610      * and are available using the {@code get} methods of  the created {@link Duration}.
   607      * The values conform to and are defined by:</p>
   611      * The values conform to and are defined by:
   608      * <ul>
   612      * <ul>
   609      *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
   613      *   <li>ISO 8601:2000(E) Section 5.5.3.2 Alternative format</li>
   610      *   <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats">
   614      *   <li><a href="http://www.w3.org/TR/xmlschema-2/#isoformats">
   611      *     W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a>
   615      *     W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats</a>
   612      *   </li>
   616      *   </li>
   617      * {@link java.util.Calendar#YEAR} = 1970,
   621      * {@link java.util.Calendar#YEAR} = 1970,
   618      * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
   622      * {@link java.util.Calendar#MONTH} = {@link java.util.Calendar#JANUARY},
   619      * {@link java.util.Calendar#DATE} = 1, etc.
   623      * {@link java.util.Calendar#DATE} = 1, etc.
   620      * This is important as there are variations in the Gregorian Calendar,
   624      * This is important as there are variations in the Gregorian Calendar,
   621      * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
   625      * e.g. leap years have different days in the month = {@link java.util.Calendar#FEBRUARY}
   622      * so the result of {@link Duration#getMonths()} can be influenced.</p>
   626      * so the result of {@link Duration#getMonths()} can be influenced.
   623      *
   627      *
   624      * <p>Any remaining milliseconds after determining the year and month are discarded.</p>
   628      * <p>Any remaining milliseconds after determining the year and month are discarded.
   625      *
   629      *
   626      * @param durationInMilliseconds Milliseconds of <code>Duration</code> to create.
   630      * @param durationInMilliseconds Milliseconds of {@code Duration} to create.
   627      *
   631      *
   628      * @return New <code>Duration</code> created using the specified <code>durationInMilliseconds</code>.
   632      * @return New {@code Duration} created using the specified {@code durationInMilliseconds}.
   629      */
   633      */
   630     public Duration newDurationYearMonth(
   634     public Duration newDurationYearMonth(
   631             final long durationInMilliseconds) {
   635             final long durationInMilliseconds) {
   632 
   636 
   633         // create a Duration that only has sign, year & month
   637         // create a Duration that only has sign, year & month
   644 
   648 
   645         return newDurationYearMonth(isPositive, years, months);
   649         return newDurationYearMonth(isPositive, years, months);
   646     }
   650     }
   647 
   651 
   648     /**
   652     /**
   649      * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> using the specified
   653      * Create a {@code Duration} of type {@code xdt:yearMonthDuration} using the specified
   650      * <code>year</code> and <code>month</code> as defined in
   654      * {@code year} and {@code month} as defined in
   651      * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
   655      * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
   652      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
   656      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.
   653      *
   657      *
   654      * <p>The XML Schema specification states that values can be of an arbitrary size.
   658      * <p>The XML Schema specification states that values can be of an arbitrary size.
   655      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   659      * Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
   656      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   660      * An {@link UnsupportedOperationException} will be thrown with a message indicating implementation limits
   657      * if implementation capacities are exceeded.</p>
   661      * if implementation capacities are exceeded.
   658      *
   662      *
   659      * <p>A <code>null</code> value indicates that field is not set.</p>
   663      * <p>A {@code null} value indicates that field is not set.
   660      *
   664      *
   661      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
   665      * @param isPositive Set to {@code false} to create a negative duration. When the length
   662      *   of the duration is zero, this parameter will be ignored.
   666      *   of the duration is zero, this parameter will be ignored.
   663      * @param year Year of <code>Duration</code>.
   667      * @param year Year of {@code Duration}.
   664      * @param month Month of <code>Duration</code>.
   668      * @param month Month of {@code Duration}.
   665      *
   669      *
   666      * @return New <code>Duration</code> created using the specified <code>year</code> and <code>month</code>.
   670      * @return New {@code Duration} created using the specified {@code year} and {@code month}.
   667      *
   671      *
   668      * @throws IllegalArgumentException If the values are not a valid representation of a
   672      * @throws IllegalArgumentException If the values are not a valid representation of a
   669      * <code>Duration</code>: if all of the fields (year, month) are null or
   673      * {@code Duration}: if all of the fields (year, month) are null or
   670      * if any of the fields is negative.
   674      * if any of the fields is negative.
   671      * @throws UnsupportedOperationException If implementation cannot support requested values.
   675      * @throws UnsupportedOperationException If implementation cannot support requested values.
   672      */
   676      */
   673     public Duration newDurationYearMonth(
   677     public Duration newDurationYearMonth(
   674             final boolean isPositive,
   678             final boolean isPositive,
   685                     null  // seconds
   689                     null  // seconds
   686             );
   690             );
   687     }
   691     }
   688 
   692 
   689     /**
   693     /**
   690      * <p>Create a <code>Duration</code> of type <code>xdt:yearMonthDuration</code> using the specified
   694      * Create a {@code Duration} of type {@code xdt:yearMonthDuration} using the specified
   691      * <code>year</code> and <code>month</code> as defined in
   695      * {@code year} and {@code month} as defined in
   692      * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
   696      * <a href="http://www.w3.org/TR/xpath-datamodel#yearMonthDuration">
   693      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.</p>
   697      *   XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration</a>.
   694      *
   698      *
   695      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
   699      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
   696      *
   700      *
   697      * @param isPositive Set to <code>false</code> to create a negative duration. When the length
   701      * @param isPositive Set to {@code false} to create a negative duration. When the length
   698      *   of the duration is zero, this parameter will be ignored.
   702      *   of the duration is zero, this parameter will be ignored.
   699      * @param year Year of <code>Duration</code>.
   703      * @param year Year of {@code Duration}.
   700      * @param month Month of <code>Duration</code>.
   704      * @param month Month of {@code Duration}.
   701      *
   705      *
   702      * @return New <code>Duration</code> created using the specified <code>year</code> and <code>month</code>.
   706      * @return New {@code Duration} created using the specified {@code year} and {@code month}.
   703      *
   707      *
   704      * @throws IllegalArgumentException If the values are not a valid representation of a
   708      * @throws IllegalArgumentException If the values are not a valid representation of a
   705      * <code>Duration</code>: if any of the fields (year, month) is negative.
   709      * {@code Duration}: if any of the fields (year, month) is negative.
   706      */
   710      */
   707     public Duration newDurationYearMonth(
   711     public Duration newDurationYearMonth(
   708             final boolean isPositive,
   712             final boolean isPositive,
   709             final int year,
   713             final int year,
   710             final int month) {
   714             final int month) {
   714                     BigInteger.valueOf((long) year),
   718                     BigInteger.valueOf((long) year),
   715                     BigInteger.valueOf((long) month));
   719                     BigInteger.valueOf((long) month));
   716             }
   720             }
   717 
   721 
   718     /**
   722     /**
   719      * <p>Create a new instance of an <code>XMLGregorianCalendar</code>.</p>
   723      * Create a new instance of an {@code XMLGregorianCalendar}.
   720      *
   724      *
   721      * <p>All date/time datatype fields set to {@link DatatypeConstants#FIELD_UNDEFINED} or null.</p>
   725      * <p>All date/time datatype fields set to {@link DatatypeConstants#FIELD_UNDEFINED} or null.
   722      *
   726      *
   723      * @return New <code>XMLGregorianCalendar</code> with all date/time datatype fields set to
   727      * @return New {@code XMLGregorianCalendar} with all date/time datatype fields set to
   724      *   {@link DatatypeConstants#FIELD_UNDEFINED} or null.
   728      *   {@link DatatypeConstants#FIELD_UNDEFINED} or null.
   725      */
   729      */
   726     public abstract XMLGregorianCalendar newXMLGregorianCalendar();
   730     public abstract XMLGregorianCalendar newXMLGregorianCalendar();
   727 
   731 
   728     /**
   732     /**
   729      * <p>Create a new XMLGregorianCalendar by parsing the String as a lexical representation.</p>
   733      * Create a new XMLGregorianCalendar by parsing the String as a lexical representation.
   730      *
   734      *
   731      * <p>Parsing the lexical string representation is defined in
   735      * <p>Parsing the lexical string representation is defined in
   732      * <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">XML Schema 1.0 Part 2, Section 3.2.[7-14].1,
   736      * <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">XML Schema 1.0 Part 2, Section 3.2.[7-14].1,
   733      * <em>Lexical Representation</em>.</a></p>
   737      * <em>Lexical Representation</em>.</a>
   734      *
   738      *
   735      * <p>The string representation may not have any leading and trailing whitespaces.</p>
   739      * <p>The string representation may not have any leading and trailing whitespaces.
   736      *
   740      *
   737      * <p>The parsing is done field by field so that
   741      * <p>The parsing is done field by field so that
   738      * the following holds for any lexically correct String x:</p>
   742      * the following holds for any lexically correct String x:
   739      * <pre>
   743      * <pre>
   740      * newXMLGregorianCalendar(x).toXMLFormat().equals(x)
   744      * newXMLGregorianCalendar(x).toXMLFormat().equals(x)
   741      * </pre>
   745      * </pre>
   742      * <p>Except for the noted lexical/canonical representation mismatches
   746      * <p>Except for the noted lexical/canonical representation mismatches
   743      * listed in <a href="http://www.w3.org/2001/05/xmlschema-errata#e2-45">
   747      * listed in <a href="http://www.w3.org/2001/05/xmlschema-errata#e2-45">
   744      * XML Schema 1.0 errata, Section 3.2.7.2</a>.</p>
   748      * XML Schema 1.0 errata, Section 3.2.7.2</a>.
   745      *
   749      *
   746      * @param lexicalRepresentation Lexical representation of one the eight XML Schema date/time datatypes.
   750      * @param lexicalRepresentation Lexical representation of one the eight XML Schema date/time datatypes.
   747      *
   751      *
   748      * @return <code>XMLGregorianCalendar</code> created from the <code>lexicalRepresentation</code>.
   752      * @return {@code XMLGregorianCalendar} created from the {@code lexicalRepresentation}.
   749      *
   753      *
   750      * @throws IllegalArgumentException If the <code>lexicalRepresentation</code> is not a valid <code>XMLGregorianCalendar</code>.
   754      * @throws IllegalArgumentException If the {@code lexicalRepresentation} is not a valid {@code XMLGregorianCalendar}.
   751      * @throws NullPointerException If <code>lexicalRepresentation</code> is <code>null</code>.
   755      * @throws NullPointerException If {@code lexicalRepresentation} is {@code null}.
   752      */
   756      */
   753     public abstract XMLGregorianCalendar newXMLGregorianCalendar(final String lexicalRepresentation);
   757     public abstract XMLGregorianCalendar newXMLGregorianCalendar(final String lexicalRepresentation);
   754 
   758 
   755     /**
   759     /**
   756      * <p>Create an <code>XMLGregorianCalendar</code> from a {@link GregorianCalendar}.</p>
   760      * Create an {@code XMLGregorianCalendar} from a {@link GregorianCalendar}.
   757      *
   761      *
   758      * <table border="2" rules="all" cellpadding="2">
   762      * <table border="2" rules="all" cellpadding="2">
   759      *   <thead>
   763      *   <thead>
   760      *     <tr>
   764      *     <tr>
   761      *       <th align="center" colspan="2">
   765      *       <th align="center" colspan="2">
   762      *          Field by Field Conversion from
   766      *          Field by Field Conversion from
   763      *          {@link GregorianCalendar} to an {@link XMLGregorianCalendar}
   767      *          {@link GregorianCalendar} to an {@link XMLGregorianCalendar}
   764      *       </th>
   768      *       </th>
   765      *     </tr>
   769      *     </tr>
   766      *     <tr>
   770      *     <tr>
   767      *        <th><code>java.util.GregorianCalendar</code> field</th>
   771      *        <th>{@code java.util.GregorianCalendar} field</th>
   768      *        <th><code>javax.xml.datatype.XMLGregorianCalendar</code> field</th>
   772      *        <th>{@code javax.xml.datatype.XMLGregorianCalendar} field</th>
   769      *     </tr>
   773      *     </tr>
   770      *   </thead>
   774      *   </thead>
   771      *   <tbody>
   775      *   <tbody>
   772      *     <tr>
   776      *     <tr>
   773      *       <td><code>ERA == GregorianCalendar.BC ? -YEAR : YEAR</code></td>
   777      *       <td>{@code ERA == GregorianCalendar.BC ? -YEAR : YEAR}</td>
   774      *       <td>{@link XMLGregorianCalendar#setYear(int year)}</td>
   778      *       <td>{@link XMLGregorianCalendar#setYear(int year)}</td>
   775      *     </tr>
   779      *     </tr>
   776      *     <tr>
   780      *     <tr>
   777      *       <td><code>MONTH + 1</code></td>
   781      *       <td>{@code MONTH + 1}</td>
   778      *       <td>{@link XMLGregorianCalendar#setMonth(int month)}</td>
   782      *       <td>{@link XMLGregorianCalendar#setMonth(int month)}</td>
   779      *     </tr>
   783      *     </tr>
   780      *     <tr>
   784      *     <tr>
   781      *       <td><code>DAY_OF_MONTH</code></td>
   785      *       <td>{@code DAY_OF_MONTH}</td>
   782      *       <td>{@link XMLGregorianCalendar#setDay(int day)}</td>
   786      *       <td>{@link XMLGregorianCalendar#setDay(int day)}</td>
   783      *     </tr>
   787      *     </tr>
   784      *     <tr>
   788      *     <tr>
   785      *       <td><code>HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND</code></td>
   789      *       <td>{@code HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND}</td>
   786      *       <td>{@link XMLGregorianCalendar#setTime(int hour, int minute, int second, BigDecimal fractional)}</td>
   790      *       <td>{@link XMLGregorianCalendar#setTime(int hour, int minute, int second, BigDecimal fractional)}</td>
   787      *     </tr>
   791      *     </tr>
   788      *     <tr>
   792      *     <tr>
   789      *       <td>
   793      *       <td>
   790      *         <code>(ZONE_OFFSET + DST_OFFSET) / (60*1000)</code><br/>
   794      *         {@code (ZONE_OFFSET + DST_OFFSET) / (60*1000)}<br>
   791      *         <em>(in minutes)</em>
   795      *         <em>(in minutes)</em>
   792      *       </td>
   796      *       </td>
   793      *       <td>{@link XMLGregorianCalendar#setTimezone(int offset)}<sup><em>*</em></sup>
   797      *       <td>{@link XMLGregorianCalendar#setTimezone(int offset)}<sup><em>*</em></sup>
   794      *       </td>
   798      *       </td>
   795      *     </tr>
   799      *     </tr>
   796      *   </tbody>
   800      *   </tbody>
   797      * </table>
   801      * </table>
   798      * <p><em>*</em>conversion loss of information. It is not possible to represent
   802      * <p><em>*</em>conversion loss of information. It is not possible to represent
   799      * a <code>java.util.GregorianCalendar</code> daylight savings timezone id in the
   803      * a {@code java.util.GregorianCalendar} daylight savings timezone id in the
   800      * XML Schema 1.0 date/time datatype representation.</p>
   804      * XML Schema 1.0 date/time datatype representation.
   801      *
   805      *
   802      * <p>To compute the return value's <code>TimeZone</code> field,
   806      * <p>To compute the return value's {@code TimeZone} field,
   803      * <ul>
   807      * <ul>
   804      * <li>when <code>this.getTimezone() != FIELD_UNDEFINED</code>,
   808      * <li>when {@code this.getTimezone() != FIELD_UNDEFINED},
   805      * create a <code>java.util.TimeZone</code> with a custom timezone id
   809      * create a {@code java.util.TimeZone} with a custom timezone id
   806      * using the <code>this.getTimezone()</code>.</li>
   810      * using the {@code this.getTimezone()}.</li>
   807      * <li>else use the <code>GregorianCalendar</code> default timezone value
   811      * <li>else use the {@code GregorianCalendar} default timezone value
   808      * for the host is defined as specified by
   812      * for the host is defined as specified by
   809      * <code>java.util.TimeZone.getDefault()</code>.</li></p>
   813      * {@code java.util.TimeZone.getDefault()}.</li>
   810      *
   814      * </ul>
   811      * @param cal <code>java.util.GregorianCalendar</code> used to create <code>XMLGregorianCalendar</code>
   815      *
   812      *
   816      * @param cal {@code java.util.GregorianCalendar} used to create {@code XMLGregorianCalendar}
   813      * @return <code>XMLGregorianCalendar</code> created from <code>java.util.GregorianCalendar</code>
   817      *
   814      *
   818      * @return {@code XMLGregorianCalendar} created from {@code java.util.GregorianCalendar}
   815      * @throws NullPointerException If <code>cal</code> is <code>null</code>.
   819      *
       
   820      * @throws NullPointerException If {@code cal} is {@code null}.
   816      */
   821      */
   817     public abstract XMLGregorianCalendar newXMLGregorianCalendar(final GregorianCalendar cal);
   822     public abstract XMLGregorianCalendar newXMLGregorianCalendar(final GregorianCalendar cal);
   818 
   823 
   819     /**
   824     /**
   820      * <p>Constructor allowing for complete value spaces allowed by
   825      * Constructor allowing for complete value spaces allowed by
   821      * W3C XML Schema 1.0 recommendation for xsd:dateTime and related
   826      * W3C XML Schema 1.0 recommendation for xsd:dateTime and related
   822      * builtin datatypes. Note that <code>year</code> parameter supports
   827      * builtin datatypes. Note that {@code year} parameter supports
   823      * arbitrarily large numbers and fractionalSecond has infinite
   828      * arbitrarily large numbers and fractionalSecond has infinite
   824      * precision.</p>
   829      * precision.
   825      *
   830      *
   826      * <p>A <code>null</code> value indicates that field is not set.</p>
   831      * <p>A {@code null} value indicates that field is not set.
   827      *
   832      *
   828      * @param year of <code>XMLGregorianCalendar</code> to be created.
   833      * @param year of {@code XMLGregorianCalendar} to be created.
   829      * @param month of <code>XMLGregorianCalendar</code> to be created.
   834      * @param month of {@code XMLGregorianCalendar} to be created.
   830      * @param day of <code>XMLGregorianCalendar</code> to be created.
   835      * @param day of {@code XMLGregorianCalendar} to be created.
   831      * @param hour of <code>XMLGregorianCalendar</code> to be created.
   836      * @param hour of {@code XMLGregorianCalendar} to be created.
   832      * @param minute of <code>XMLGregorianCalendar</code> to be created.
   837      * @param minute of {@code XMLGregorianCalendar} to be created.
   833      * @param second of <code>XMLGregorianCalendar</code> to be created.
   838      * @param second of {@code XMLGregorianCalendar} to be created.
   834      * @param fractionalSecond of <code>XMLGregorianCalendar</code> to be created.
   839      * @param fractionalSecond of {@code XMLGregorianCalendar} to be created.
   835      * @param timezone of <code>XMLGregorianCalendar</code> to be created.
   840      * @param timezone of {@code XMLGregorianCalendar} to be created.
   836      *
   841      *
   837      * @return <code>XMLGregorianCalendar</code> created from specified values.
   842      * @return {@code XMLGregorianCalendar} created from specified values.
   838      *
   843      *
   839      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
   844      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
   840      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
   845      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
   841      *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
   846      *   or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance
   842      *   as determined by {@link XMLGregorianCalendar#isValid()}.
   847      *   as determined by {@link XMLGregorianCalendar#isValid()}.
   843      */
   848      */
   844     public abstract XMLGregorianCalendar newXMLGregorianCalendar(
   849     public abstract XMLGregorianCalendar newXMLGregorianCalendar(
   845             final BigInteger year,
   850             final BigInteger year,
   846             final int month,
   851             final int month,
   850             final int second,
   855             final int second,
   851             final BigDecimal fractionalSecond,
   856             final BigDecimal fractionalSecond,
   852             final int timezone);
   857             final int timezone);
   853 
   858 
   854     /**
   859     /**
   855      * <p>Constructor of value spaces that a
   860      * Constructor of value spaces that a
   856      * <code>java.util.GregorianCalendar</code> instance would need to convert to an
   861      * {@code java.util.GregorianCalendar} instance would need to convert to an
   857      * <code>XMLGregorianCalendar</code> instance.</p>
   862      * {@code XMLGregorianCalendar} instance.
   858      *
   863      *
   859      * <p><code>XMLGregorianCalendar eon</code> and
   864      * <p>{@code XMLGregorianCalendar eon} and
   860      * <code>fractionalSecond</code> are set to <code>null</code></p>
   865      * {@code fractionalSecond} are set to {@code null}
   861      *
   866      *
   862      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
   867      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
   863      *
   868      *
   864      * @param year of <code>XMLGregorianCalendar</code> to be created.
   869      * @param year of {@code XMLGregorianCalendar} to be created.
   865      * @param month of <code>XMLGregorianCalendar</code> to be created.
   870      * @param month of {@code XMLGregorianCalendar} to be created.
   866      * @param day of <code>XMLGregorianCalendar</code> to be created.
   871      * @param day of {@code XMLGregorianCalendar} to be created.
   867      * @param hour of <code>XMLGregorianCalendar</code> to be created.
   872      * @param hour of {@code XMLGregorianCalendar} to be created.
   868      * @param minute of <code>XMLGregorianCalendar</code> to be created.
   873      * @param minute of {@code XMLGregorianCalendar} to be created.
   869      * @param second of <code>XMLGregorianCalendar</code> to be created.
   874      * @param second of {@code XMLGregorianCalendar} to be created.
   870      * @param millisecond of <code>XMLGregorianCalendar</code> to be created.
   875      * @param millisecond of {@code XMLGregorianCalendar} to be created.
   871      * @param timezone of <code>XMLGregorianCalendar</code> to be created.
   876      * @param timezone of {@code XMLGregorianCalendar} to be created.
   872      *
   877      *
   873      * @return <code>XMLGregorianCalendar</code> created from specified values.
   878      * @return {@code XMLGregorianCalendar} created from specified values.
   874      *
   879      *
   875      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
   880      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
   876      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
   881      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
   877      *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
   882      *   or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance
   878      *   as determined by {@link XMLGregorianCalendar#isValid()}.
   883      *   as determined by {@link XMLGregorianCalendar#isValid()}.
   879      */
   884      */
   880     public XMLGregorianCalendar newXMLGregorianCalendar(
   885     public XMLGregorianCalendar newXMLGregorianCalendar(
   881             final int year,
   886             final int year,
   882             final int month,
   887             final int month,
   916                     timezone
   921                     timezone
   917             );
   922             );
   918     }
   923     }
   919 
   924 
   920     /**
   925     /**
   921      * <p>Create a Java representation of XML Schema builtin datatype <code>date</code> or <code>g*</code>.</p>
   926      * Create a Java representation of XML Schema builtin datatype {@code date} or {@code g*}.
   922      *
   927      *
   923      * <p>For example, an instance of <code>gYear</code> can be created invoking this factory
   928      * <p>For example, an instance of {@code gYear} can be created invoking this factory
   924      * with <code>month</code> and <code>day</code> parameters set to
   929      * with {@code month} and {@code day} parameters set to
   925      * {@link DatatypeConstants#FIELD_UNDEFINED}.</p>
   930      * {@link DatatypeConstants#FIELD_UNDEFINED}.
   926      *
   931      *
   927      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
   932      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
   928      *
   933      *
   929      * @param year of <code>XMLGregorianCalendar</code> to be created.
   934      * @param year of {@code XMLGregorianCalendar} to be created.
   930      * @param month of <code>XMLGregorianCalendar</code> to be created.
   935      * @param month of {@code XMLGregorianCalendar} to be created.
   931      * @param day of <code>XMLGregorianCalendar</code> to be created.
   936      * @param day of {@code XMLGregorianCalendar} to be created.
   932      * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
   937      * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
   933      *
   938      *
   934      * @return <code>XMLGregorianCalendar</code> created from parameter values.
   939      * @return {@code XMLGregorianCalendar} created from parameter values.
   935      *
   940      *
   936      * @see DatatypeConstants#FIELD_UNDEFINED
   941      * @see DatatypeConstants#FIELD_UNDEFINED
   937      *
   942      *
   938      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
   943      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
   939      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
   944      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
   940      *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
   945      *   or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance
   941      *   as determined by {@link XMLGregorianCalendar#isValid()}.
   946      *   as determined by {@link XMLGregorianCalendar#isValid()}.
   942      */
   947      */
   943     public XMLGregorianCalendar newXMLGregorianCalendarDate(
   948     public XMLGregorianCalendar newXMLGregorianCalendarDate(
   944             final int year,
   949             final int year,
   945             final int month,
   950             final int month,
   956                     DatatypeConstants.FIELD_UNDEFINED, // millisecond
   961                     DatatypeConstants.FIELD_UNDEFINED, // millisecond
   957                     timezone);
   962                     timezone);
   958             }
   963             }
   959 
   964 
   960     /**
   965     /**
   961      * <p>Create a Java instance of XML Schema builtin datatype <code>time</code>.</p>
   966      * Create a Java instance of XML Schema builtin datatype {@code time}.
   962      *
   967      *
   963      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
   968      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
   964      *
   969      *
   965      * @param hours number of hours
   970      * @param hours number of hours
   966      * @param minutes number of minutes
   971      * @param minutes number of minutes
   967      * @param seconds number of seconds
   972      * @param seconds number of seconds
   968      * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
   973      * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
   969      *
   974      *
   970      * @return <code>XMLGregorianCalendar</code> created from parameter values.
   975      * @return {@code XMLGregorianCalendar} created from parameter values.
   971      *
   976      *
   972      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
   977      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
   973      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
   978      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
   974      *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
   979      *   or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance
   975      *   as determined by {@link XMLGregorianCalendar#isValid()}.
   980      *   as determined by {@link XMLGregorianCalendar#isValid()}.
   976      *
   981      *
   977      * @see DatatypeConstants#FIELD_UNDEFINED
   982      * @see DatatypeConstants#FIELD_UNDEFINED
   978      */
   983      */
   979     public XMLGregorianCalendar newXMLGregorianCalendarTime(
   984     public XMLGregorianCalendar newXMLGregorianCalendarTime(
   992                     DatatypeConstants.FIELD_UNDEFINED, //Millisecond
   997                     DatatypeConstants.FIELD_UNDEFINED, //Millisecond
   993                     timezone);
   998                     timezone);
   994     }
   999     }
   995 
  1000 
   996     /**
  1001     /**
   997      * <p>Create a Java instance of XML Schema builtin datatype time.</p>
  1002      * Create a Java instance of XML Schema builtin datatype time.
   998      *
  1003      *
   999      * <p>A <code>null</code> value indicates that field is not set.</p>
  1004      * <p>A {@code null} value indicates that field is not set.
  1000      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
  1005      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
  1001      *
  1006      *
  1002      * @param hours number of hours
  1007      * @param hours number of hours
  1003      * @param minutes number of minutes
  1008      * @param minutes number of minutes
  1004      * @param seconds number of seconds
  1009      * @param seconds number of seconds
  1005      * @param fractionalSecond value of <code>null</code> indicates that this optional field is not set.
  1010      * @param fractionalSecond value of {@code null} indicates that this optional field is not set.
  1006      * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
  1011      * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
  1007      *
  1012      *
  1008      * @return <code>XMLGregorianCalendar</code> created from parameter values.
  1013      * @return {@code XMLGregorianCalendar} created from parameter values.
  1009      *
  1014      *
  1010      * @see DatatypeConstants#FIELD_UNDEFINED
  1015      * @see DatatypeConstants#FIELD_UNDEFINED
  1011      *
  1016      *
  1012      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
  1017      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
  1013      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
  1018      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
  1014      *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
  1019      *   or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance
  1015      *   as determined by {@link XMLGregorianCalendar#isValid()}.
  1020      *   as determined by {@link XMLGregorianCalendar#isValid()}.
  1016      */
  1021      */
  1017     public XMLGregorianCalendar newXMLGregorianCalendarTime(
  1022     public XMLGregorianCalendar newXMLGregorianCalendarTime(
  1018             final int hours,
  1023             final int hours,
  1019             final int minutes,
  1024             final int minutes,
  1031                     fractionalSecond,
  1036                     fractionalSecond,
  1032                     timezone);
  1037                     timezone);
  1033             }
  1038             }
  1034 
  1039 
  1035     /**
  1040     /**
  1036      * <p>Create a Java instance of XML Schema builtin datatype time.</p>
  1041      * Create a Java instance of XML Schema builtin datatype time.
  1037      *
  1042      *
  1038      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.</p>
  1043      * <p>A {@link DatatypeConstants#FIELD_UNDEFINED} value indicates that field is not set.
  1039      *
  1044      *
  1040      * @param hours number of hours
  1045      * @param hours number of hours
  1041      * @param minutes number of minutes
  1046      * @param minutes number of minutes
  1042      * @param seconds number of seconds
  1047      * @param seconds number of seconds
  1043      * @param milliseconds number of milliseconds
  1048      * @param milliseconds number of milliseconds
  1044      * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
  1049      * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
  1045      *
  1050      *
  1046      * @return <code>XMLGregorianCalendar</code> created from parameter values.
  1051      * @return {@code XMLGregorianCalendar} created from parameter values.
  1047      *
  1052      *
  1048      * @see DatatypeConstants#FIELD_UNDEFINED
  1053      * @see DatatypeConstants#FIELD_UNDEFINED
  1049      *
  1054      *
  1050      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
  1055      * @throws IllegalArgumentException If any individual parameter's value is outside the maximum value constraint for the field
  1051      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
  1056      *   as determined by the Date/Time Data Mapping table in {@link XMLGregorianCalendar}
  1052      *   or if the composite values constitute an invalid <code>XMLGregorianCalendar</code> instance
  1057      *   or if the composite values constitute an invalid {@code XMLGregorianCalendar} instance
  1053      *   as determined by {@link XMLGregorianCalendar#isValid()}.
  1058      *   as determined by {@link XMLGregorianCalendar#isValid()}.
  1054      */
  1059      */
  1055     public XMLGregorianCalendar newXMLGregorianCalendarTime(
  1060     public XMLGregorianCalendar newXMLGregorianCalendarTime(
  1056             final int hours,
  1061             final int hours,
  1057             final int minutes,
  1062             final int minutes,