當前位置: 首頁>>代碼示例>>Java>>正文


Java DatatypeConstants.Field方法代碼示例

本文整理匯總了Java中javax.xml.datatype.DatatypeConstants.Field方法的典型用法代碼示例。如果您正苦於以下問題:Java DatatypeConstants.Field方法的具體用法?Java DatatypeConstants.Field怎麽用?Java DatatypeConstants.Field使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.datatype.DatatypeConstants的用法示例。


在下文中一共展示了DatatypeConstants.Field方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFieldAsBigDecimal

import javax.xml.datatype.DatatypeConstants; //導入方法依賴的package包/類
/**
 * <p>Gets the value of the field as a {@link BigDecimal}.</p>
 *
 * <p>If the field is unset, return 0.</p>
 *
 * @param f Field to get value for.
 *
 * @return  non-null valid {@link BigDecimal}.
 */
private BigDecimal getFieldAsBigDecimal(DatatypeConstants.Field f) {
    if (f == DatatypeConstants.SECONDS) {
        if (seconds != null) {
            return seconds;
        } else {
            return ZERO;
        }
    } else {
        BigInteger bi = (BigInteger) getField(f);
        if (bi == null) {
            return ZERO;
        } else {
            return new BigDecimal(bi);
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:DurationImpl.java

示例2: getFieldAsBigDecimal

import javax.xml.datatype.DatatypeConstants; //導入方法依賴的package包/類
/**
 * <p>Gets the value of the field as a {@link BigDecimal}.</p>
 *
 * <p>If the field is unset, return 0.</p>
 *
 * @param f Field to get value for.
 *
 * @return  non-null valid {@link BigDecimal}.
 */
private BigDecimal getFieldAsBigDecimal(DatatypeConstants.Field f) {
    if (f == DatatypeConstants.SECONDS) {
        if (seconds != null) {
            return seconds;
        }
        else {
            return ZERO;
        }
    }
    else {
        BigInteger bi = (BigInteger) getField(f);
        if (bi == null) {
            return ZERO;
        }
        else {
            return new BigDecimal(bi);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:DurationImpl.java

示例3: testNonNegative

import javax.xml.datatype.DatatypeConstants; //導入方法依賴的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

示例4: getInt

import javax.xml.datatype.DatatypeConstants; //導入方法依賴的package包/類
/**
 * <p>Return the requested field value as an int.</p>
 *
 * <p>If field is not set, i.e. == null, 0 is returned.</p>
 *
 * @param field To get value for.
 *
 * @return int value of field or 0 if field is not set.
 */
private int getInt(DatatypeConstants.Field field) {
    Number n = getField(field);
    if (n == null) {
        return 0;
    }
    else {
        return n.intValue();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:DurationImpl.java

示例5: getInt

import javax.xml.datatype.DatatypeConstants; //導入方法依賴的package包/類
/**
 * <p>Return the requested field value as an int.</p>
 *
 * <p>If field is not set, i.e. == null, 0 is returned.</p>
 *
 * @param field To get value for.
 *
 * @return int value of field or 0 if field is not set.
 */
private int getInt(DatatypeConstants.Field field) {
    Number n = getField(field);
    if (n == null) {
        return 0;
    } else {
        return n.intValue();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:DurationImpl.java

示例6: compare

import javax.xml.datatype.DatatypeConstants; //導入方法依賴的package包/類
/**
 * <p>Partial order relation comparison with this <code>Duration</code> instance.</p>
 *
 * <p>Comparison result must be in accordance with
 * <a href="http://www.w3.org/TR/xmlschema-2/#duration-order">W3C XML Schema 1.0 Part 2, Section 3.2.7.6.2,
 * <i>Order relation on duration</i></a>.</p>
 *
 * <p>Return:</p>
 * <ul>
 *   <li>{@link DatatypeConstants#LESSER} if this <code>Duration</code> is shorter than <code>duration</code> parameter</li>
 *   <li>{@link DatatypeConstants#EQUAL} if this <code>Duration</code> is equal to <code>duration</code> parameter</li>
 *   <li>{@link DatatypeConstants#GREATER} if this <code>Duration</code> is longer than <code>duration</code> parameter</li>
 *   <li>{@link DatatypeConstants#INDETERMINATE} if a conclusive partial order relation cannot be determined</li>
 * </ul>
 *
 * @param duration to compare
 *
 * @return the relationship between <code>this</code> <code>Duration</code>and <code>duration</code> parameter as
 *   {@link DatatypeConstants#LESSER}, {@link DatatypeConstants#EQUAL}, {@link DatatypeConstants#GREATER}
 *   or {@link DatatypeConstants#INDETERMINATE}.
 *
 * @throws UnsupportedOperationException If the underlying implementation
 *   cannot reasonably process the request, e.g. W3C XML Schema allows for
 *   arbitrarily large/small/precise values, the request may be beyond the
 *   implementations capability.
 * @throws NullPointerException if <code>duration</code> is <code>null</code>.
 *
 * @see #isShorterThan(Duration)
 * @see #isLongerThan(Duration)
 */
public int compare(Duration rhs) {
    /** check if any field in the Durations is too large for the operation
     * that uses XMLGregorianCalendar for comparison
    */
    for (DatatypeConstants.Field field : FIELDS) {
        checkMaxValue(getField(field), field);
        checkMaxValue(rhs.getField(field), field);
    }

    return compareDates(this, rhs);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:42,代碼來源:DurationImpl.java


注:本文中的javax.xml.datatype.DatatypeConstants.Field方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。