当前位置: 首页>>代码示例>>Java>>正文


Java DatatypeConstants.FIELD_UNDEFINED属性代码示例

本文整理汇总了Java中javax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED属性的典型用法代码示例。如果您正苦于以下问题:Java DatatypeConstants.FIELD_UNDEFINED属性的具体用法?Java DatatypeConstants.FIELD_UNDEFINED怎么用?Java DatatypeConstants.FIELD_UNDEFINED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.xml.datatype.DatatypeConstants的用法示例。


在下文中一共展示了DatatypeConstants.FIELD_UNDEFINED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEonAndYear

/**
 * <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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:XMLGregorianCalendarImpl.java

示例2: DurationImpl

/**
 * <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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:DurationImpl.java

示例3: createDateTime

/**
 * <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
    );
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:XMLGregorianCalendarImpl.java

示例4: hashCode

/**
 * <p>Returns a hash code consistent with the definition of the equals method.</p>
 *
 * @return hash code of this object.
 */
public int hashCode() {

    // Following two dates compare to EQUALS since in different timezones.
    // 2000-01-15T12:00:00-05:00 == 2000-01-15T13:00:00-04:00
    //
    // Must ensure both instances generate same hashcode by normalizing
    // this to UTC timezone.
    int timezone = getTimezone();
    if (timezone == DatatypeConstants.FIELD_UNDEFINED) {
        timezone = 0;
    }
    XMLGregorianCalendar gc = this;
    if (timezone != 0) {
        gc = this.normalizeToTimezone(getTimezone());
    }
    return gc.getYear() + gc.getMonth() + gc.getDay() +
            gc.getHour() + gc.getMinute() + gc.getSecond();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:XMLGregorianCalendarImpl.java

示例5: clear

/**
 * <p>Unset all fields to undefined.</p>
 *
 * <p>Set all int fields to {@link DatatypeConstants#FIELD_UNDEFINED} and reference fields
 * to null.</p>
 */
public void clear() {
    eon = null;
    year = DatatypeConstants.FIELD_UNDEFINED;
    month = DatatypeConstants.FIELD_UNDEFINED;
    day = DatatypeConstants.FIELD_UNDEFINED;
    timezone = DatatypeConstants.FIELD_UNDEFINED;  // in minutes
    hour = DatatypeConstants.FIELD_UNDEFINED;
    minute = DatatypeConstants.FIELD_UNDEFINED;
    second = DatatypeConstants.FIELD_UNDEFINED;
    fractionalSecond = null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:XMLGregorianCalendarImpl.java

示例6: getSeconds

/**
 * @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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:XMLGregorianCalendarImpl.java

示例7: createDate

/**
 * <p>Create a Java representation of XML Schema builtin datatype <code>date</code> or <code>g*</code>.</p>
 *
 * <p>For example, an instance of <code>gYear</code> can be created invoking this factory
 * with <code>month</code> and <code>day</code> parameters set to
 * {@link DatatypeConstants#FIELD_UNDEFINED}.</p>
 *
 * @param year of <code>XMLGregorianCalendar</code> to be created.
 * @param month of <code>XMLGregorianCalendar</code> to be created.
 * @param day of <code>XMLGregorianCalendar</code> to be created.
 * @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 createDate(
    int year,
    int month,
    int day,
    int timezone) {

    return new XMLGregorianCalendarImpl(
        year,
        month,
        day,
        DatatypeConstants.FIELD_UNDEFINED, // hour
        DatatypeConstants.FIELD_UNDEFINED, // minute
        DatatypeConstants.FIELD_UNDEFINED, // second
            DatatypeConstants.FIELD_UNDEFINED, // millisecond
        timezone);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:XMLGregorianCalendarImpl.java

示例8: DurationDayTimeImpl

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));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:DurationDayTimeImpl.java

示例9: wrap

/**
     * TODO: Javadoc
     *
     * @param i int to convert to BigInteger.
     *
     * @return BigInteger representation of int.
     */
protected static BigInteger wrap(final int i) {

    // field may not be set
    if (i == DatatypeConstants.FIELD_UNDEFINED) {
            return null;
    }

    // int -> BigInteger
    return new BigInteger(String.valueOf(i));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:DurationImpl.java

示例10: setMillisecond

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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:XMLGregorianCalendarImpl.java

示例11: XMLGregorianCalendarImpl

/**
 * <p>Private constructor of value spaces that a
 * <code>java.util.GregorianCalendar</code> instance would need to convert to an
 * <code>XMLGregorianCalendar</code> instance.</p>
 *
 * <p><code>XMLGregorianCalendar eon</code> and
 * <code>fractionalSecond</code> are set to <code>null</code></p>
 *
 * @param year of <code>XMLGregorianCalendar</code> to be created.
 * @param month of <code>XMLGregorianCalendar</code> to be created.
 * @param day of <code>XMLGregorianCalendar</code> to be created.
 * @param hour of <code>XMLGregorianCalendar</code> to be created.
 * @param minute of <code>XMLGregorianCalendar</code> to be created.
 * @param second of <code>XMLGregorianCalendar</code> to be created.
 * @param millisecond of <code>XMLGregorianCalendar</code> to be created.
 * @param timezone of <code>XMLGregorianCalendar</code> to be created.
 */
private XMLGregorianCalendarImpl(
    int year,
    int month,
    int day,
    int hour,
    int minute,
    int second,
    int millisecond,
    int timezone) {

    setYear(year);
    setMonth(month);
    setDay(day);
    setTime(hour, minute, second);
    setTimezone(timezone);
    BigDecimal realMilliseconds = null;
    if (millisecond != DatatypeConstants.FIELD_UNDEFINED) {
        realMilliseconds = BigDecimal.valueOf(millisecond, 3);
    }
    setFractionalSecond(realMilliseconds);

    if (!isValid()) {

        throw new IllegalArgumentException(
            DatatypeMessageFormatter.formatMessage(null,
            "InvalidXGCValue-milli",
            new Object[] { year, month, day,
            hour, minute, second,
            millisecond, timezone})
                    );
    }

    save();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:XMLGregorianCalendarImpl.java

示例12: testSetTime

@Test
public final void testSetTime() {

    /**
     * Hour, minute, second values to test and expected result.
     */
    final int[] TEST_VALUES = { 24, 0, 0, TEST_VALUE_PASS, 24, 1, 0, TEST_VALUE_FAIL, 24, 0, 1, TEST_VALUE_FAIL, 24, DatatypeConstants.FIELD_UNDEFINED, 0,
            TEST_VALUE_FAIL, 24, 0, DatatypeConstants.FIELD_UNDEFINED, TEST_VALUE_FAIL };

    // create DatatypeFactory
    DatatypeFactory datatypeFactory = null;
    try {
        datatypeFactory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException datatypeConfigurationException) {
        Assert.fail(datatypeConfigurationException.toString());
    }

    if (DEBUG) {
        System.err.println("DatatypeFactory created: " + datatypeFactory.toString());
    }

    // create XMLGregorianCalendar
    XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar();

    // test each value
    for (int onTestValue = 0; onTestValue < TEST_VALUES.length; onTestValue = onTestValue + 4) {

        if (DEBUG) {
            System.err.println("testing values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2]
                    + ") expected (0=fail, 1=pass): " + TEST_VALUES[onTestValue + 3]);
        }

        try {
            // set time
            xmlGregorianCalendar.setTime(TEST_VALUES[onTestValue], TEST_VALUES[onTestValue + 1], TEST_VALUES[onTestValue + 2]);

            if (DEBUG) {
                System.err.println("XMLGregorianCalendar created: \"" + xmlGregorianCalendar.toString() + "\"");
            }

            // was this expected to fail?
            if (TEST_VALUES[onTestValue + 3] == TEST_VALUE_FAIL) {
                Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2]
                        + ") are invalid, " + "yet it created the XMLGregorianCalendar \"" + xmlGregorianCalendar.toString() + "\"");
            }
        } catch (Exception exception) {

            if (DEBUG) {
                System.err.println("Exception in creating XMLGregorianCalendar: \"" + exception.toString() + "\"");
            }

            // was this expected to succed?
            if (TEST_VALUES[onTestValue + 3] == TEST_VALUE_PASS) {
                Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2]
                        + ") are valid yet it failed with \"" + exception.toString() + "\"");
            }
            // expected failure
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:60,代码来源:XMLGregorianCalendarTest.java

示例13: setMinute

public void setMinute(int minute) {
    if(minute<0 || 59<minute)
        if(minute!=DatatypeConstants.FIELD_UNDEFINED)
            invalidFieldValue(MINUTE, minute);
    this.minute = minute;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:XMLGregorianCalendarImpl.java

示例14: setSecond

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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:XMLGregorianCalendarImpl.java

示例15: testSetHour

@Test
public final void testSetHour() {

    /**
     * Hour values to test and expected result.
     */
    final int[] TEST_VALUES = {
            // setTime(H, M, S), hour override, expected result
            0, 0, 0, 0, TEST_VALUE_PASS, 0, 0, 0, 23, TEST_VALUE_PASS, 0, 0, 0, 24, TEST_VALUE_PASS,
            // creates invalid state
            0, 0, 0, DatatypeConstants.FIELD_UNDEFINED, TEST_VALUE_FAIL,
            // violates Schema Errata
            0, 0, 1, 24, TEST_VALUE_FAIL };

    // create DatatypeFactory
    DatatypeFactory datatypeFactory = null;
    try {
        datatypeFactory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException datatypeConfigurationException) {
        Assert.fail(datatypeConfigurationException.toString());
    }

    if (DEBUG) {
        System.err.println("DatatypeFactory created: " + datatypeFactory.toString());
    }

    // create XMLGregorianCalendar
    XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar();

    // test each value
    for (int onTestValue = 0; onTestValue < TEST_VALUES.length; onTestValue = onTestValue + 5) {

        if (DEBUG) {
            System.err.println("testing values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2]
                    + ", " + TEST_VALUES[onTestValue + 3] + ") expected (0=fail, 1=pass): " + TEST_VALUES[onTestValue + 4]);
        }

        try {
            // set time to known valid value
            xmlGregorianCalendar.setTime(TEST_VALUES[onTestValue], TEST_VALUES[onTestValue + 1], TEST_VALUES[onTestValue + 2]);
            // now explicitly set hour
            xmlGregorianCalendar.setHour(TEST_VALUES[onTestValue + 3]);

            if (DEBUG) {
                System.err.println("XMLGregorianCalendar created: \"" + xmlGregorianCalendar.toString() + "\"");
            }

            // was this expected to fail?
            if (TEST_VALUES[onTestValue + 4] == TEST_VALUE_FAIL) {
                Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2] + ", "
                        + TEST_VALUES[onTestValue + 3] + ") are invalid, " + "yet it created the XMLGregorianCalendar \"" + xmlGregorianCalendar.toString()
                        + "\"");
            }
        } catch (Exception exception) {

            if (DEBUG) {
                System.err.println("Exception in creating XMLGregorianCalendar: \"" + exception.toString() + "\"");
            }

            // was this expected to succed?
            if (TEST_VALUES[onTestValue + 4] == TEST_VALUE_PASS) {
                Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2] + ", "
                        + TEST_VALUES[onTestValue + 3] + ") are valid yet it failed with \"" + exception.toString() + "\"");
            }
            // expected failure
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:68,代码来源:XMLGregorianCalendarTest.java


注:本文中的javax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。