本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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()})
);
}
}
示例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();
}
}
示例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();
}
}
示例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);
}