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


Java DatatypeMessageFormatter类代码示例

本文整理汇总了Java中com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter的典型用法代码示例。如果您正苦于以下问题:Java DatatypeMessageFormatter类的具体用法?Java DatatypeMessageFormatter怎么用?Java DatatypeMessageFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DatatypeMessageFormatter类属于com.sun.org.apache.xerces.internal.util包,在下文中一共展示了DatatypeMessageFormatter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkMaxValue

import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; //导入依赖的package包/类
/**
 * Check if a field exceeds the maximum value
 * @param field the value of a field
 * @param fieldType type of the field, e.g. year, month, day, hour, minute or second.
 */
private void checkMaxValue(Number field, DatatypeConstants.Field fieldType) {
    BigInteger fieldValue = null;
    if (fieldType != DatatypeConstants.SECONDS) {
        fieldValue = (BigInteger) field;
    } else {
        BigDecimal rhsSecondsAsBigDecimal = (BigDecimal) field;
        if ( rhsSecondsAsBigDecimal != null ) {
            fieldValue =  rhsSecondsAsBigDecimal.toBigInteger();
        }
    }

    if (fieldValue != null && fieldValue.compareTo(MaxIntAsBigInt) == 1) {
        throw new UnsupportedOperationException(
                DatatypeMessageFormatter.formatMessage(null, "TooLarge",
                new Object[]{this.getClass().getName() + "#compare(Duration duration)"
                + fieldType, field.toString()})
        );
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:25,代码来源:DurationImpl.java

示例2: setFractionalSecond

import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; //导入依赖的package包/类
public void setFractionalSecond(BigDecimal fractional) {
    if (fractional != null) {
        if ((fractional.compareTo(DECIMAL_ZERO) < 0) ||
                (fractional.compareTo(DECIMAL_ONE) > 0)) {
            throw new IllegalArgumentException(DatatypeMessageFormatter.formatMessage(null,
                    "InvalidFractional", new Object[]{fractional}));
        }
    }
    this.fractionalSecond = fractional;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:XMLGregorianCalendarImpl.java

示例3: DurationImpl

import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; //导入依赖的package包/类
/**
 * <p>Constructs a new Duration object by specifying each field individually.</p>
 *
 * <p>All the parameters are optional as long as at least one field is present.
 * If specified, parameters have to be zero or positive.</p>
 *
 * @param isPositive Set to <code>false</code> to create a negative duration. When the length
 *   of the duration is zero, this parameter will be ignored.
 * @param years of this <code>Duration</code>
 * @param months of this <code>Duration</code>
 * @param days of this <code>Duration</code>
 * @param hours of this <code>Duration</code>
 * @param minutes of this <code>Duration</code>
 * @param seconds of this <code>Duration</code>
 *
 * @throws IllegalArgumentException
 *    If years, months, days, hours, minutes and
 *    seconds parameters are all <code>null</code>. Or if any
 *    of those parameters are negative.
 */
protected DurationImpl(
    boolean isPositive,
    BigInteger years,
    BigInteger months,
    BigInteger days,
    BigInteger hours,
    BigInteger minutes,
    BigDecimal seconds) {

    this.years = years;
    this.months = months;
    this.days = days;
    this.hours = hours;
    this.minutes = minutes;
    this.seconds = seconds;

    this.signum = calcSignum(isPositive);

    // sanity check
    if (years == null
        && months == null
        && days == null
        && hours == null
        && minutes == null
        && seconds == null) {
        throw new IllegalArgumentException(
        //"all the fields are null"
        DatatypeMessageFormatter.formatMessage(null, "AllFieldsNull", null)
        );
    }
    testNonNegative(years, DatatypeConstants.YEARS);
    testNonNegative(months, DatatypeConstants.MONTHS);
    testNonNegative(days, DatatypeConstants.DAYS);
    testNonNegative(hours, DatatypeConstants.HOURS);
    testNonNegative(minutes, DatatypeConstants.MINUTES);
    testNonNegative(seconds, DatatypeConstants.SECONDS);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:58,代码来源:DurationImpl.java

示例4: testNonNegative

import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; //导入依赖的package包/类
/**
 * <p>Makes sure that the given number is non-negative. If it is not,
 * throw {@link IllegalArgumentException}.</p>
 *
 * @param n Number to test.
 * @param f Field to test.
 */
protected static void testNonNegative(BigInteger n, DatatypeConstants.Field f) {
    if (n != null && n.signum() < 0) {
        throw new IllegalArgumentException(
            DatatypeMessageFormatter.formatMessage(null, "NegativeField", new Object[]{f.toString()})
        );
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:DurationImpl.java

示例5: XMLGregorianCalendarImpl

import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; //导入依赖的package包/类
/**
 * <p>Private constructor allowing for complete value spaces allowed by
 * W3C XML Schema 1.0 recommendation for xsd:dateTime and related
 * builtin datatypes. Note that <code>year</code> parameter supports
 * arbitrarily large numbers and fractionalSecond has infinite
 * precision.</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 fractionalSecond of <code>XMLGregorianCalendar</code> to be created.
 * @param timezone of <code>XMLGregorianCalendar</code> to be created.
 *
 */
protected XMLGregorianCalendarImpl(
    BigInteger year,
    int month,
    int day,
    int hour,
    int minute,
    int second,
    BigDecimal fractionalSecond,
    int timezone) {

    setYear(year);
    setMonth(month);
    setDay(day);
    setTime(hour, minute, second, fractionalSecond);
    setTimezone(timezone);

    // check for validity
    if (!isValid()) {

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

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

示例6: setFractionalSecond

import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; //导入依赖的package包/类
public final void setFractionalSecond(BigDecimal fractional) {
    if (fractional != null) {
        if ((fractional.compareTo(DECIMAL_ZERO) < 0) ||
                (fractional.compareTo(DECIMAL_ONE) > 0)) {
            throw new IllegalArgumentException(DatatypeMessageFormatter.formatMessage(null,
                    "InvalidFractional", new Object[]{fractional}));
        }
    }
    this.fractionalSecond = fractional;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:XMLGregorianCalendarImpl.java

示例7: XMLGregorianCalendarImpl

import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; //导入依赖的package包/类
/**
 * <p>Private constructor allowing for complete value spaces allowed by
 * W3C XML Schema 1.0 recommendation for xsd:dateTime and related
 * builtin datatypes. Note that <code>year</code> parameter supports
 * arbitrarily large numbers and fractionalSecond has infinite
 * precision.</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 fractionalSecond of <code>XMLGregorianCalendar</code> to be created.
 * @param timezone of <code>XMLGregorianCalendar</code> to be created.
 *
 */
protected XMLGregorianCalendarImpl(
    BigInteger year,
    int month,
    int day,
    int hour,
    int minute,
    int second,
    BigDecimal fractionalSecond,
    int timezone) {

            setYear(year);
    setMonth(month);
    setDay(day);
    setTime(hour, minute, second, fractionalSecond);
            setTimezone(timezone);

            // check for validity
            if (!isValid()) {

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

                    /**
            String yearString = "null";
            if (year != null) {
                yearString = year.toString();
            }
            String fractionalSecondString = "null";
            if (fractionalSecond != null) {
                fractionalSecondString = fractionalSecond.toString();
            }

            throw new IllegalArgumentException(
                "year = " + yearString
                + ", month = " + month
                + ", day = " + day
                + ", hour = " + hour
                + ", minute = " + minute
                + ", second = " + second
                + ", fractionalSecond = " + fractionalSecondString
                + ", timezone = " + timezone
                + ", is not a valid representation of an XML Gregorian Calendar value."
            );
            */

            }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:71,代码来源:XMLGregorianCalendarImpl.java

示例8: invalidFieldValue

import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; //导入依赖的package包/类
private void invalidFieldValue(int field, int value) {
    throw new IllegalArgumentException(
        DatatypeMessageFormatter.formatMessage(null, "InvalidFieldValue",
            new Object[]{ new Integer(value), FIELD_NAME[field]})
    );
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:XMLGregorianCalendarImpl.java

示例9: invalidFieldValue

import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; //导入依赖的package包/类
private void invalidFieldValue(int field, int value) {
    throw new IllegalArgumentException(
        DatatypeMessageFormatter.formatMessage(null, "InvalidFieldValue",
            new Object[]{ value, FIELD_NAME[field]})
    );
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XMLGregorianCalendarImpl.java

示例10: XMLGregorianCalendarImpl

import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; //导入依赖的package包/类
/**
 * <p>Private constructor allowing for complete value spaces allowed by
 * W3C XML Schema 1.0 recommendation for xsd:dateTime and related
 * builtin datatypes. Note that <code>year</code> parameter supports
 * arbitrarily large numbers and fractionalSecond has infinite
 * precision.</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 fractionalSecond of <code>XMLGregorianCalendar</code> to be created.
 * @param timezone of <code>XMLGregorianCalendar</code> to be created.
 *
 */
protected XMLGregorianCalendarImpl(
    BigInteger year,
    int month,
    int day,
    int hour,
    int minute,
    int second,
    BigDecimal fractionalSecond,
    int timezone) {

    setYear(year);
    setMonth(month);
    setDay(day);
    setTime(hour, minute, second, fractionalSecond);
    setTimezone(timezone);

    // check for validity
    if (!isValid()) {

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

                    /**
            String yearString = "null";
            if (year != null) {
                yearString = year.toString();
            }
            String fractionalSecondString = "null";
            if (fractionalSecond != null) {
                fractionalSecondString = fractionalSecond.toString();
            }

            throw new IllegalArgumentException(
                "year = " + yearString
                + ", month = " + month
                + ", day = " + day
                + ", hour = " + hour
                + ", minute = " + minute
                + ", second = " + second
                + ", fractionalSecond = " + fractionalSecondString
                + ", timezone = " + timezone
                + ", is not a valid representation of an XML Gregorian Calendar value."
            );
            */

    }

    save();
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:72,代码来源:XMLGregorianCalendarImpl.java


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