com.caucho.es
Class ESNumber
java.lang.Object
|
+--com.caucho.es.ESBase
|
+--com.caucho.es.ESNumber
- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable, VfsWriteObject
- public class ESNumber
- extends ESBase
- implements VfsWriteObject, java.io.Externalizable
Implementation class for JavaScript numbers. Essentially, these are
equivalent to Java doubles.
- See Also:
- Serialized Form
Constructor Summary |
ESNumber()
Null-arg constructor for serialization. |
Methods inherited from class com.caucho.es.ESBase |
call, call, construct, delete, getProperty, greaterThan, hasProperty, isBoolean, isString, keys, setProperty, setProperty, setProperty, toInt32, toJavaString, toPrimitive, toPrimitive, toSource, valueOf |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
ZERO
public static ESNumber ZERO
ONE
public static ESNumber ONE
NaN
public static ESNumber NaN
ESNumber
public ESNumber()
- Null-arg constructor for serialization.
create
public static ESNumber create(double value)
toBoolean
public boolean toBoolean()
- Any non-zero number is true.
XXX: NaN and inf?
- Overrides:
toBoolean
in class ESBase
isNum
public boolean isNum()
- Overrides:
isNum
in class ESBase
toNum
public double toNum()
- Overrides:
toNum
in class ESBase
toObject
public ESObject toObject()
throws ESException
- Overrides:
toObject
in class ESBase
toJavaObject
public java.lang.Object toJavaObject()
- Overrides:
toJavaObject
in class ESBase
typeof
public ESBase typeof()
throws ESException
- Overrides:
typeof
in class ESBase
getJavaType
public java.lang.Class getJavaType()
- Overrides:
getJavaType
in class ESBase
getProperty
public ESBase getProperty(ESString key)
throws java.lang.Exception
- Overrides:
getProperty
in class ESBase
toStr
public ESString toStr()
- Overrides:
toStr
in class ESBase
toString
public java.lang.String toString()
- Returns the string representation of the number.
Notes: the spec says
1) -0 should be printed at 0.
2) 20 decimal digit integers should be printed as integers.
This is insane since the double can only almost a 16 digit decimal.
3) The exponent should be lower case.
- Overrides:
toString
in class ESBase
print
public void print(WriteStream os)
throws java.io.IOException
- Specified by:
print
in interface VfsWriteObject
hashCode
public int hashCode()
- Overrides:
hashCode
in class java.lang.Object
equals
public boolean equals(java.lang.Object b)
- Overrides:
equals
in class java.lang.Object
ecmaEquals
public boolean ecmaEquals(ESBase b)
throws java.lang.Exception
- Overrides:
ecmaEquals
in class ESBase
lessThan
public boolean lessThan(ESBase b,
boolean neg)
throws java.lang.Exception
- Overrides:
lessThan
in class ESBase
plus
public ESBase plus(ESBase b)
throws java.lang.Exception
- Overrides:
plus
in class ESBase
writeExternal
public void writeExternal(java.io.ObjectOutput os)
throws java.io.IOException
- Save the external representation.
- Specified by:
writeExternal
in interface java.io.Externalizable
readExternal
public void readExternal(java.io.ObjectInput is)
throws java.io.IOException
- Restore the external representation.
- Specified by:
readExternal
in interface java.io.Externalizable