本文整理匯總了Java中org.yaml.snakeyaml.nodes.Tag.FLOAT屬性的典型用法代碼示例。如果您正苦於以下問題:Java Tag.FLOAT屬性的具體用法?Java Tag.FLOAT怎麽用?Java Tag.FLOAT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.yaml.snakeyaml.nodes.Tag
的用法示例。
在下文中一共展示了Tag.FLOAT屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: representData
public Node representData(Object data) {
Tag tag;
String value;
if (data instanceof Byte || data instanceof Short || data instanceof Integer
|| data instanceof Long || data instanceof BigInteger) {
tag = Tag.INT;
value = data.toString();
} else {
Number number = (Number) data;
tag = Tag.FLOAT;
if (number.equals(Double.NaN)) {
value = ".NaN";
} else if (number.equals(Double.POSITIVE_INFINITY)) {
value = ".inf";
} else if (number.equals(Double.NEGATIVE_INFINITY)) {
value = "-.inf";
} else {
value = number.toString();
}
}
return representScalar(getTag(data.getClass(), tag), value);
}
示例2: representNumber
public final Node representNumber(Number data)
{
Tag tag;
String value;
if ((data instanceof Byte) || (data instanceof Short) || (data instanceof Integer) || (data instanceof Long) || (data instanceof BigInteger))
{
tag = Tag.INT;
value = data.toString();
}
else
{
tag = Tag.FLOAT;
if (data.equals(Double.NaN))
{
value = ".NaN";
}
else if (data.equals(Double.POSITIVE_INFINITY))
{
value = ".inf";
}
else if (data.equals(Double.NEGATIVE_INFINITY))
{
value = "-.inf";
}
else
{
value = data.toString();
}
}
return this.representer.representScalar(this.representer.getTag(data.getClass(), tag), value);
}