Java Code Examples for javax.xml.datatype.DatatypeConstants#FIELD_UNDEFINED

The following examples show how to use javax.xml.datatype.DatatypeConstants#FIELD_UNDEFINED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLGregorianCalendarImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <p>Create a Java instance of XML Schema builtin datatype time.</p>
 *
 * @param hours number of hours
 * @param minutes number of minutes
 * @param seconds number of seconds
 * @param fractionalSecond value of <code>null</code> indicates that this optional field is not set.
 * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
 *
 * @return <code>XMLGregorianCalendar</code> created from parameter values.
 *
 * @see DatatypeConstants#FIELD_UNDEFINED
 *
 * @throws IllegalArgumentException if any parameter is outside value
 * constraints for the field as specified in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.
 */
public static XMLGregorianCalendar createTime(
    int hours,
    int minutes,
    int seconds,
    BigDecimal fractionalSecond,
    int timezone) {

    return new XMLGregorianCalendarImpl(
        null,            // Year
        DatatypeConstants.FIELD_UNDEFINED, // month
        DatatypeConstants.FIELD_UNDEFINED, // day
        hours,
        minutes,
        seconds,
        fractionalSecond,
        timezone);
}
 
Example 2
Source File: DurationImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <p>Constructs a new Duration object by specifying each field
 * individually.</p>
 *
 * <p>This method is functionally equivalent to
 * invoking another constructor by wrapping
 * all non-zero parameters into {@link BigInteger} and {@link BigDecimal}.
 * Zero value of int parameter is equivalent of null value of
 * the corresponding field.</p>
 *
 * @see #DurationImpl(boolean, BigInteger, BigInteger, BigInteger, BigInteger,
 *   BigInteger, BigDecimal)
 */
protected DurationImpl(
    final boolean isPositive,
    final int years,
    final int months,
    final int days,
    final int hours,
    final int minutes,
    final int seconds) {
    this(
        isPositive,
        wrap(years),
        wrap(months),
        wrap(days),
        wrap(hours),
        wrap(minutes),
        seconds != DatatypeConstants.FIELD_UNDEFINED ? new BigDecimal(String.valueOf(seconds)) : null);
}
 
Example 3
Source File: XMLGregorianCalendarImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a Java instance of XML Schema builtin datatype <code>time</code>.
 * @param hours number of hours
 * @param minutes number of minutes
 * @param seconds number of seconds
 * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
 *
 * @return <code>XMLGregorianCalendar</code> created from parameter values.
 *
 * @see DatatypeConstants#FIELD_UNDEFINED
 *
 * @throws IllegalArgumentException if any parameter is outside value
 * constraints for the field as specified in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.
 */
public static XMLGregorianCalendar createTime(
    int hours,
    int minutes,
    int seconds,
            int timezone) {

            return new XMLGregorianCalendarImpl(
                    DatatypeConstants.FIELD_UNDEFINED, // Year
                    DatatypeConstants.FIELD_UNDEFINED, // Month
                    DatatypeConstants.FIELD_UNDEFINED, // Day
                    hours,
                    minutes,
                    seconds,
                    DatatypeConstants.FIELD_UNDEFINED, //Millisecond
                    timezone);
}
 
Example 4
Source File: XMLGregorianCalendarImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <p>Return XML Schema 1.0 dateTime datatype field for
 * <code>year</code>.</p>
 *
 * <p>Value constraints for this value are summarized in
 * <a href="#datetimefield-year">year field of date/time field mapping table</a>.</p>
 *
 * @return sum of <code>eon</code> and <code>BigInteger.valueOf(year)</code>
 * when both fields are defined. When only <code>year</code> is defined,
 * return it. When both <code>eon</code> and <code>year</code> are not
 * defined, return <code>null</code>.
 *
 * @see #getEon()
 * @see #getYear()
 */
public BigInteger getEonAndYear() {

            // both are defined
            if (year != DatatypeConstants.FIELD_UNDEFINED
                    && eon != null) {

                    return eon.add(BigInteger.valueOf((long) year));
            }

            // only year is defined
            if (year != DatatypeConstants.FIELD_UNDEFINED
                    && eon == null) {

                    return BigInteger.valueOf((long) year);
            }

    // neither are defined
    // or only eon is defined which is not valid without a year
            return null;
}
 
Example 5
Source File: XMLGregorianCalendarImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Create a Java instance of XML Schema builtin datatype <code>time</code>.
 * @param hours number of hours
 * @param minutes number of minutes
 * @param seconds number of seconds
 * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
 *
 * @return <code>XMLGregorianCalendar</code> created from parameter values.
 *
 * @see DatatypeConstants#FIELD_UNDEFINED
 *
 * @throws IllegalArgumentException if any parameter is outside value
 * constraints for the field as specified in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.
 */
public static XMLGregorianCalendar createTime(
    int hours,
    int minutes,
    int seconds,
            int timezone) {

            return new XMLGregorianCalendarImpl(
                    DatatypeConstants.FIELD_UNDEFINED, // Year
                    DatatypeConstants.FIELD_UNDEFINED, // Month
                    DatatypeConstants.FIELD_UNDEFINED, // Day
                    hours,
                    minutes,
                    seconds,
                    DatatypeConstants.FIELD_UNDEFINED, //Millisecond
                    timezone);
}
 
Example 6
Source File: XMLGregorianCalendarImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <p>Create a Java instance of XML Schema builtin datatype time.</p>
 *
 * @param hours number of hours
 * @param minutes number of minutes
 * @param seconds number of seconds
 * @param milliseconds number of milliseconds
 * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
 *
 * @return <code>XMLGregorianCalendar</code> created from parameter values.
 *
 * @see DatatypeConstants#FIELD_UNDEFINED
 *
 * @throws IllegalArgumentException if any parameter is outside value
 * constraints for the field as specified in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.
 */
public static XMLGregorianCalendar createTime(
    int hours,
    int minutes,
    int seconds,
    int milliseconds,
    int timezone) {

    return new XMLGregorianCalendarImpl(
            DatatypeConstants.FIELD_UNDEFINED, // year
            DatatypeConstants.FIELD_UNDEFINED, // month
            DatatypeConstants.FIELD_UNDEFINED, // day
            hours,
            minutes,
            seconds,
            milliseconds,
            timezone);
}
 
Example 7
Source File: XMLGregorianCalendarImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * <p>Create a Java instance of XML Schema builtin datatype dateTime.</p>
 *
 * @param year represents both high-order eons and low-order year.
 * @param month of <code>dateTime</code>
 * @param day of <code>dateTime</code>
 * @param hour of <code>dateTime</code>
 * @param minute of <code>dateTime</code>
 * @param second of <code>dateTime</code>
 *
 * @return <code>XMLGregorianCalendar</code> created from parameter values.
 *
 * @throws IllegalArgumentException if any parameter is outside value constraints for the field as specified in
 *   <a href="#datetimefieldmapping">date/time field mapping table</a>.
 *
 * @see DatatypeConstants#FIELD_UNDEFINED
 */
public static XMLGregorianCalendar createDateTime(
    int year,
    int month,
    int day,
    int hour,
    int minute,
    int second) {

    return new XMLGregorianCalendarImpl(
        year,
        month,
        day,
        hour,
        minute,
        second,
        DatatypeConstants.FIELD_UNDEFINED,  //millisecond
            DatatypeConstants.FIELD_UNDEFINED //timezone
    );
}
 
Example 8
Source File: FEELXMLGregorianCalendar.java    From jdmn with Apache License 2.0 5 votes vote down vote up
@Override
public void setMinute(int minute) {
    if (minute < 0 || 59 < minute)
        if (minute != DatatypeConstants.FIELD_UNDEFINED)
            invalidFieldValue(MINUTE, minute);
    this.minute = minute;
}
 
Example 9
Source File: XMLGregorianCalendarImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return result of adding second and fractional second field
 */
private BigDecimal getSeconds() {
    if (second == DatatypeConstants.FIELD_UNDEFINED) {
        return DECIMAL_ZERO;
    }
    BigDecimal result = BigDecimal.valueOf((long) second);
    if (fractionalSecond != null) {
        return result.add(fractionalSecond);
    } else {
        return result;
    }
}
 
Example 10
Source File: DurationDayTimeImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public DurationDayTimeImpl(
    boolean isPositive,
    int days,
    int hours,
    int minutes,
    int seconds) {

    this(
        isPositive,
        wrap(days),
        wrap(hours),
        wrap(minutes),
        (seconds != DatatypeConstants.FIELD_UNDEFINED ? new BigDecimal(String.valueOf(seconds)) : null));
}
 
Example 11
Source File: XMLGregorianCalendarImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void setMillisecond(int millisecond) {
    if (millisecond == DatatypeConstants.FIELD_UNDEFINED) {
        fractionalSecond = null;
    } else {
        if(millisecond<0 || 999<millisecond)
            if(millisecond!=DatatypeConstants.FIELD_UNDEFINED)
                invalidFieldValue(MILLISECOND, millisecond);
        fractionalSecond = new BigDecimal((long) millisecond).movePointLeft(3);
    }
}
 
Example 12
Source File: XMLGregorianCalendarImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * @return result of adding second and fractional second field
 */
private BigDecimal getSeconds() {
    if (second == DatatypeConstants.FIELD_UNDEFINED) {
        return DECIMAL_ZERO;
    }
    BigDecimal result = BigDecimal.valueOf((long) second);
    if (fractionalSecond != null) {
        return result.add(fractionalSecond);
    } else {
        return result;
    }
}
 
Example 13
Source File: XMLGregorianCalendarImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void setSecond(int second) {
    if(second<0 || 60<second)   // leap second allows for 60
        if(second!=DatatypeConstants.FIELD_UNDEFINED)
            invalidFieldValue(SECOND, second);
    this.second  = second;
}
 
Example 14
Source File: XMLGregorianCalendarImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void setMinute(int minute) {
    if(minute<0 || 59<minute)
        if(minute!=DatatypeConstants.FIELD_UNDEFINED)
            invalidFieldValue(MINUTE, minute);
    this.minute = minute;
}
 
Example 15
Source File: XMLGregorianCalendarImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void setMinute(int minute) {
    if(minute<0 || 59<minute)
        if(minute!=DatatypeConstants.FIELD_UNDEFINED)
            invalidFieldValue(MINUTE, minute);
    this.minute = minute;
}
 
Example 16
Source File: XMLGregorianCalendarImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * <p>Compare two instances of W3C XML Schema 1.0 date/time datatypes
 * according to partial order relation defined in
 * <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">W3C XML Schema 1.0 Part 2, Section 3.2.7.3,
 * <i>Order relation on dateTime</i></a>.</p>
 *
 * <p><code>xsd:dateTime</code> datatype field mapping to accessors of
 * this class are defined in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.</p>
 *
 * @param rhs instance of <code>XMLGregorianCalendar</code> to compare
 *
 * @return the relationship between <code>lhs</code> and <code>rhs</code> as
 *   {@link DatatypeConstants#LESSER},
 *   {@link DatatypeConstants#EQUAL},
 *   {@link DatatypeConstants#GREATER} or
 *   {@link DatatypeConstants#INDETERMINATE}.
 *
 * @throws NullPointerException if <code>lhs</code> or <code>rhs</code>
 * parameters are null.
 */
public int compare(XMLGregorianCalendar rhs) {

    XMLGregorianCalendar lhs = this;

    int result = DatatypeConstants.INDETERMINATE;
    XMLGregorianCalendarImpl P = (XMLGregorianCalendarImpl) lhs;
    XMLGregorianCalendarImpl Q = (XMLGregorianCalendarImpl) rhs;

    if (P.getTimezone() == Q.getTimezone()) {
        // Optimization:
        // both instances are in same timezone or
        // both are FIELD_UNDEFINED.
        // Avoid costly normalization of timezone to 'Z' time.
        return internalCompare(P, Q);

    } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED &&
            Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) {

        // Both instances have different timezones.
        // Normalize to UTC time and compare.
        P = (XMLGregorianCalendarImpl) P.normalize();
        Q = (XMLGregorianCalendarImpl) Q.normalize();
        return internalCompare(P, Q);
    } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) {

        if (P.getTimezone() != 0) {
            P = (XMLGregorianCalendarImpl) P.normalize();
        }

        // C. step 1
        XMLGregorianCalendar MinQ = Q.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET);
        result = internalCompare(P, MinQ);
        if (result == DatatypeConstants.LESSER) {
            return result;
        }

        // C. step 2
        XMLGregorianCalendar MaxQ = Q.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET);
        result = internalCompare(P, MaxQ);
        if (result == DatatypeConstants.GREATER) {
            return result;
        } else {
            // C. step 3
            return DatatypeConstants.INDETERMINATE;
        }
    } else { // Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED
        // P has no timezone and Q does.
        if (Q.getTimezone() != 0) {
            Q = (XMLGregorianCalendarImpl) Q.normalizeToTimezone(Q.getTimezone());
        }

        // D. step 1
        XMLGregorianCalendar MaxP = P.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET);
        result = internalCompare(MaxP, Q);
        if (result == DatatypeConstants.LESSER) {
            return result;
        }

        // D. step 2
        XMLGregorianCalendar MinP = P.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET);
        result = internalCompare(MinP, Q);
        if (result == DatatypeConstants.GREATER) {
            return result;
        } else {
            // D. step 3
            return DatatypeConstants.INDETERMINATE;
        }
    }
}
 
Example 17
Source File: XMLGregorianCalendarImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * <p>Compare two instances of W3C XML Schema 1.0 date/time datatypes
 * according to partial order relation defined in
 * <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">W3C XML Schema 1.0 Part 2, Section 3.2.7.3,
 * <i>Order relation on dateTime</i></a>.</p>
 *
 * <p><code>xsd:dateTime</code> datatype field mapping to accessors of
 * this class are defined in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.</p>
 *
 * @param rhs instance of <code>XMLGregorianCalendar</code> to compare
 *
 * @return the relationship between <code>lhs</code> and <code>rhs</code> as
 *   {@link DatatypeConstants#LESSER},
 *   {@link DatatypeConstants#EQUAL},
 *   {@link DatatypeConstants#GREATER} or
 *   {@link DatatypeConstants#INDETERMINATE}.
 *
 * @throws NullPointerException if <code>lhs</code> or <code>rhs</code>
 * parameters are null.
 */
public int compare(XMLGregorianCalendar rhs) {

    XMLGregorianCalendar lhs = this;

    int result = DatatypeConstants.INDETERMINATE;
    XMLGregorianCalendarImpl P = (XMLGregorianCalendarImpl) lhs;
    XMLGregorianCalendarImpl Q = (XMLGregorianCalendarImpl) rhs;

    if (P.getTimezone() == Q.getTimezone()) {
        // Optimization:
        // both instances are in same timezone or
        // both are FIELD_UNDEFINED.
        // Avoid costly normalization of timezone to 'Z' time.
        return internalCompare(P, Q);

    } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED &&
            Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) {

        // Both instances have different timezones.
        // Normalize to UTC time and compare.
        P = (XMLGregorianCalendarImpl) P.normalize();
        Q = (XMLGregorianCalendarImpl) Q.normalize();
        return internalCompare(P, Q);
    } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) {

        if (P.getTimezone() != 0) {
            P = (XMLGregorianCalendarImpl) P.normalize();
        }

        // C. step 1
        XMLGregorianCalendar MinQ = Q.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET);
        result = internalCompare(P, MinQ);
        if (result == DatatypeConstants.LESSER) {
            return result;
        }

        // C. step 2
        XMLGregorianCalendar MaxQ = Q.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET);
        result = internalCompare(P, MaxQ);
        if (result == DatatypeConstants.GREATER) {
            return result;
        } else {
            // C. step 3
            return DatatypeConstants.INDETERMINATE;
        }
    } else { // Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED
        // P has no timezone and Q does.
        if (Q.getTimezone() != 0) {
            Q = (XMLGregorianCalendarImpl) Q.normalizeToTimezone(Q.getTimezone());
        }

        // D. step 1
        XMLGregorianCalendar MaxP = P.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET);
        result = internalCompare(MaxP, Q);
        if (result == DatatypeConstants.LESSER) {
            return result;
        }

        // D. step 2
        XMLGregorianCalendar MinP = P.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET);
        result = internalCompare(MinP, Q);
        if (result == DatatypeConstants.GREATER) {
            return result;
        } else {
            // D. step 3
            return DatatypeConstants.INDETERMINATE;
        }
    }
}
 
Example 18
Source File: XMLGregorianCalendarImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void setMinute(int minute) {
    if(minute<0 || 59<minute)
        if(minute!=DatatypeConstants.FIELD_UNDEFINED)
            invalidFieldValue(MINUTE, minute);
    this.minute = minute;
}
 
Example 19
Source File: XMLGregorianCalendarImpl.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * <p>Set low and high order component of XSD <code>dateTime</code> year field.</p>
 *
 * <p>Unset this field by invoking the setter with a parameter value of <code>null</code>.</p>
 *
 * @param year value constraints summarized in <a href="#datetimefield-year">year field of date/time field mapping table</a>.
 *
 * @throws IllegalArgumentException if <code>year</code> parameter is
 * outside value constraints for the field as specified in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.
 */
public void setYear(BigInteger year) {
    if (year == null) {
        this.eon = null;
        this.year = DatatypeConstants.FIELD_UNDEFINED;
    } else {
        BigInteger temp = year.remainder(BILLION);
        this.year = temp.intValue();
        setEon(year.subtract(temp));
    }
}
 
Example 20
Source File: XMLGregorianCalendarImpl.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <p>Set the number of minutes in the timezone offset.</p>
 *
 * <p>Unset this field by invoking the setter with a parameter value of {@link DatatypeConstants#FIELD_UNDEFINED}.</p>
 *
 * @param offset value constraints summarized in <a href="#datetimefield-timezone">
 *   timezone field of date/time field mapping table</a>.
 *
 * @throws IllegalArgumentException if <code>offset</code> parameter is
 * outside value constraints for the field as specified in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.
 */
public void setTimezone(int offset) {
        if(offset<-14*60 || 14*60<offset)
        if(offset!=DatatypeConstants.FIELD_UNDEFINED)
            invalidFieldValue(TIMEZONE,offset);
    this.timezone = offset;
}