List of usage examples for jdk.nashorn.internal.objects NativeNumber constructor
@Constructor(arity = 1) public static Object constructor(final boolean newObj, final Object self, final Object... args)
From source file:com.mongodb.jvm.json.nashorn.NativeNumberTransformer.java
License:Apache License
public Object transform(Object object, JsonImplementation implementation) { if (object instanceof ScriptObject) { Object numberLong = ((ScriptObject) object).get("$numberLong"); if ((numberLong != null) && (numberLong.getClass() != Undefined.class)) { // Might throw a NumberFormatException Long asLong = Long.parseLong(numberLong.toString()); Double asDouble = asLong.doubleValue(); if (JsonUtil.numberToString(asLong).equals(JsonUtil.numberToString(asDouble))) // Converting to double doesn't lose accuracy return NativeNumber.constructor(true, null, asDouble); }/*www .j a va 2s. c om*/ } return null; }
From source file:com.threecrickets.jvm.json.nashorn.NashornJsonImplementation.java
License:Mozilla Public License
public Object createDouble(double value) { return NativeNumber.constructor(true, null, value); }
From source file:com.threecrickets.jvm.json.nashorn.util.NashornNativeUtil.java
License:Mozilla Public License
public static NativeNumber toNumber(Object value) { return (NativeNumber) NativeNumber.constructor(true, null, value); }
From source file:org.bson.jvm.nashorn.NativeNumberCodec.java
License:Apache License
public NativeNumber decode(BsonReader reader, DecoderContext decoderContext) { return (NativeNumber) NativeNumber.constructor(true, null, reader.readDouble()); }