本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.CANNOT_FORMAT_INSTANCE_AS_COMPLEX属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.CANNOT_FORMAT_INSTANCE_AS_COMPLEX属性的具体用法?Java LocalizedFormats.CANNOT_FORMAT_INSTANCE_AS_COMPLEX怎么用?Java LocalizedFormats.CANNOT_FORMAT_INSTANCE_AS_COMPLEX使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.CANNOT_FORMAT_INSTANCE_AS_COMPLEX属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
/**
* Formats a object to produce a string. {@code obj} must be either a
* {@link Complex} object or a {@link Number} object. Any other type of
* object will result in an {@link IllegalArgumentException} being thrown.
*
* @param obj the object to format.
* @param toAppendTo where the text is to be appended
* @param pos On input: an alignment field, if desired. On output: the
* offsets of the alignment field
* @return the value passed in as toAppendTo.
* @see java.text.Format#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
* @throws MathIllegalArgumentException is {@code obj} is not a valid type.
*/
public StringBuffer format(Object obj, StringBuffer toAppendTo,
FieldPosition pos)
throws MathIllegalArgumentException {
StringBuffer ret = null;
if (obj instanceof Complex) {
ret = format( (Complex)obj, toAppendTo, pos);
} else if (obj instanceof Number) {
ret = format(new Complex(((Number)obj).doubleValue(), 0.0),
toAppendTo, pos);
} else {
throw new MathIllegalArgumentException(LocalizedFormats.CANNOT_FORMAT_INSTANCE_AS_COMPLEX,
obj.getClass().getName());
}
return ret;
}