anvil.core
Class Any

java.lang.Object
  |
  +--anvil.core.Any
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable
Direct Known Subclasses:
AnyAbstractClass, AnyBoolean, AnyInfinity, AnyMap, AnyNegativeInfinity, AnyNull, AnyNumber, AnyPattern, AnyRange, AnyRef, AnySequence, AnyUndefined, Array

public class Any
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable

class Any

Author:
Jani Lehtimäki

Field Summary
static NativeClass _class
           
static Any[] ARRAY0
           
static Any DOUBLE_MINUS_ONE
           
static Any DOUBLE_ONE
           
static Any DOUBLE_ZERO
           
static Any EMPTY_STRING
           
static AnyTuple EMPTY_TUPLE
           
static Any FALSE
           
static Any INF
           
static int IS_ARRAY
           
static int IS_BINARY
           
static int IS_BOOLEAN
           
static int IS_BUFFER
           
static int IS_CLASS
           
static int IS_DOUBLE
           
static int IS_ENUMERATION
           
static int IS_INF
           
static int IS_INT
           
static int IS_LIST
           
static int IS_MAP
           
static int IS_NEG_INF
           
static int IS_NULL
           
static int IS_PATTERN
           
static int IS_RANGE
           
static int IS_STRING
           
static int IS_TUPLE
           
static int IS_UNDEFINED
           
static Any MINUS_ONE
           
static Any NAN
           
static Any NEG_INF
           
static Any NULL
           
static Any ONE
           
static java.lang.Object[] p_compareTo
           
static java.lang.Object[] p_each
           
static java.lang.Object[] p_equals
           
static java.lang.Object[] p_pipe
           
static java.lang.Object[] p_select
           
static Any THREE
           
static Any TRUE
           
static Any TWO
           
static Any UNDEFINED
           
static Any ZERO
           
 
Constructor Summary
protected Any()
          Constructs Any containing IS_NULL.
 
Method Summary
protected  void _clone(Any source)
           
protected  void _copy(Any source)
           
 Any _invoke(Context context, int methodIndex)
           
 Any _invoke(Context context, int methodIndex, Any param1)
           
 Any _invoke(Context context, int methodIndex, Any[] parameters)
           
 Any _invoke(Context context, int methodIndex, Any param1, Any param2)
           
 Any _invoke(Context context, int methodIndex, Any param1, Any param2, Any param3)
           
 Any _invoke(Context context, int methodIndex, Any param1, Any param2, Any param3, Any param4)
           
protected  void _serialize(Serializer serializer)
           
protected  void _unserialize(Unserializer unserializer)
           
protected  void _wakeup(Context context)
           
 Any add(Any other)
          Adds two Any's together.
 java.lang.String classNameOf()
          Returns the classname of contained object
 ClassType classOf()
          Returns the type of this Any.
 java.lang.Object clone()
          Returns shallow copy from this any.
 Any coerce()
           
protected  int compare(Any other)
           
 int compareTo(java.lang.Object obj)
          Compares two Any's.
 Any concat(Any any)
          Concatenated two Any's together.
 boolean contains(Any value)
           
 Any copy()
          Returns deep copy from this any.
static Any create()
          Constructs Any containing IS_NULL.
static Any create(Any any)
          Constructs Any from another Any instance
static Any create(boolean bool)
          Constructs Any containing IS_BOOLEAN
static Any create(java.lang.Boolean bool)
          Constructs Any containing IS_BOOLEAN
static Any create(char ch)
          Constructs Any containing IS_STRING with length == 1 and charAt(0) == ch.
static Any create(double dbl)
          Constructs Any containing IS_DOUBLE
static Any create(java.lang.Double dbl)
          Constructs Any containing IS_DOUBLE
static Any create(int integer)
          Constructs Any containing IS_INT
static Any create(java.lang.Integer integer)
          Constructs Any containing IS_INT
static Any create(int type, java.lang.String value)
          Constructs Any with spefified type and value
static Any create(long lng)
          Constructs Any containing IS_INT
static Any create(java.lang.Object object)
           
static Any create(java.lang.String string)
          Constructs Any containing IS_STRING
static Any create(java.lang.String[] array)
           
 Any decrease()
          Decrease the value by one.
 boolean deleteAttribute(Context context, java.lang.String attribute)
           
 boolean deleteReference(Context context, Any index)
           
 Any divide(Any b)
          Divide two Any's.
 boolean equals(java.lang.Object obj)
          Tests for equality.
 Any execute(Context context)
           
 Any execute(Context context, Any param1)
           
 Any execute(Context context, Any[] parameters)
           
 Any execute(Context context, Any param1, Any param2)
           
 Any execute(Context context, Any param1, Any param2, Any param3)
           
 Any execute(Context context, Any param1, Any param2, Any param3, Any param4)
           
 Any getAttribute(Context context, java.lang.String attribute)
           
 Any getRef()
           
 Any getReference(Context context, Any index)
           
 boolean has(java.lang.String methodName)
           
 Any increase()
          Increase the value by one.
 Any invoke(Context context, int methodIndex)
           
 Any invoke(Context context, int methodIndex, Any param1)
           
 Any invoke(Context context, int methodIndex, Any[] parameters)
           
 Any invoke(Context context, int methodIndex, Any param1, Any param2)
           
 Any invoke(Context context, int methodIndex, Any param1, Any param2, Any param3)
           
 Any invoke(Context context, int methodIndex, Any param1, Any param2, Any param3, Any param4)
           
 Any invoke(Context context, java.lang.String methodName)
           
 Any invoke(Context context, java.lang.String methodName, Any param1)
           
 Any invoke(Context context, java.lang.String methodName, Any[] parameters)
           
 Any invoke(Context context, java.lang.String methodName, Any param1, Any param2)
           
 Any invoke(Context context, java.lang.String methodName, Any param1, Any param2, Any param3)
           
 Any invoke(Context context, java.lang.String methodName, Any param1, Any param2, Any param3, Any param4)
           
 boolean isArray()
          Checks if this any is array.
 boolean isBinary()
          Checks if this any is binary.
 boolean isBoolean()
          Checks if this any is boolean.
 boolean isBuffer()
          Checks if this any is buffer.
 boolean isDefined()
          Checks if this any is defined.
 boolean isDouble()
          Checks if this any is float.
 boolean isInstanceOf(Type ofType)
          Checks if this any is of given type.
 boolean isInt()
          Checks if this any is int.
 boolean isIterator()
          Checks if this any is iterator.
 boolean isList()
          Checks if this any is list.
 boolean isMap()
          Checks if this any is map.
 boolean isMutable()
           
 boolean isNull()
          Checks if this any is null.
 boolean isPattern()
          Checks if this any is pattern.
 boolean isRange()
          Checks if this any is range.
 boolean isRef()
           
 boolean isSequence()
           
 boolean isString()
          Checks if this any is string.
 boolean isTuple()
          Checks if this any is tuple.
 boolean isUndefined()
          Checks if this any is undefined.
 BindingIterator iterator()
           
 Any m_clone()
           
 Any m_compareTo(Any other)
           
 Any m_copy()
          Exposed methods
 Any m_each(Context context, Any callback)
           
 Any m_equals(Any other)
           
 Any m_hashCode()
           
 Any m_pipe(Context context, Any converter)
           
 Any m_select(Context context, Any selector)
           
 Any m_toBoolean()
           
 Any m_toString()
           
 Any minus()
          Negate the sign.
 Any modulo(Any b)
          Calculate the remainder.
 Any multiply(Any b)
          Multiply two Any's.
 Any not()
           
 Any plus()
          Remove the sign.
 void serialize(Serializer serializer)
           
 Any setAttribute(Context context, java.lang.String attribute, Any value)
           
 Any setRef(Any value)
           
 Any setReference(Context context, Any value)
           
 Any setReference(Context context, Any index, Any value)
           
 int sizeOf()
          Returns the logical size of this any.
 Any subtract(Any b)
          Substract two Any's.
 java.lang.String toAnvil()
          Converts contained value into value anvil code.
 java.io.Writer toAnvil(java.io.Writer writer)
           
 Any toAnyBoolean()
          Gets the contained value as AnyTrue or AnyFalse
 Any toAnyDouble()
          Gets the contained value as AnyDouble.
 Any toAnyInt()
          Gets the contained value as AnyInt.
 Any toAnyString()
          Converts contained value into AnyString.
 Array toArray()
          Gets the contained vaelue as Array.
 byte[] toBinary()
          Gets the contained value as byte[].
 boolean toBoolean()
          Gets the contained value as boolean.
 java.lang.StringBuffer toBuffer()
           
 byte toByte()
           
 char toChar()
          Gets the contained value as char.
 Code toCode(Code code)
           
 double toDouble()
          Gets the contained value as double.
 int toInt()
          Gets the contained value as int.
 Any[] toList()
           
 long toLong()
          Gets the contained value as long.
 AnyMap toMap()
           
 java.lang.Object toObject()
          Gets the contained value as java.lang.Object.
 java.util.regex.Pattern toPattern()
           
 AnyRange toRange()
           
 java.lang.String toString()
          Converts contained value into String.
 Any[] toTuple()
          Gets the contained value as Any[].
 Type type()
           
 int typeOf()
          Returns the type of contained value.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final transient Any NULL

UNDEFINED

public static final transient Any UNDEFINED

FALSE

public static final transient Any FALSE

TRUE

public static final transient Any TRUE

ZERO

public static final transient Any ZERO

ONE

public static final transient Any ONE

TWO

public static final transient Any TWO

THREE

public static final transient Any THREE

MINUS_ONE

public static final transient Any MINUS_ONE

DOUBLE_ZERO

public static final transient Any DOUBLE_ZERO

DOUBLE_ONE

public static final transient Any DOUBLE_ONE

DOUBLE_MINUS_ONE

public static final transient Any DOUBLE_MINUS_ONE

INF

public static final transient Any INF

NEG_INF

public static final transient Any NEG_INF

NAN

public static final transient Any NAN

EMPTY_STRING

public static final transient Any EMPTY_STRING

ARRAY0

public static final transient Any[] ARRAY0

EMPTY_TUPLE

public static final transient AnyTuple EMPTY_TUPLE

IS_NEG_INF

public static final transient int IS_NEG_INF
See Also:
Constant Field Values

IS_UNDEFINED

public static final transient int IS_UNDEFINED
See Also:
Constant Field Values

IS_NULL

public static final transient int IS_NULL
See Also:
Constant Field Values

IS_BOOLEAN

public static final transient int IS_BOOLEAN
See Also:
Constant Field Values

IS_INT

public static final transient int IS_INT
See Also:
Constant Field Values

IS_DOUBLE

public static final transient int IS_DOUBLE
See Also:
Constant Field Values

IS_STRING

public static final transient int IS_STRING
See Also:
Constant Field Values

IS_BUFFER

public static final transient int IS_BUFFER
See Also:
Constant Field Values

IS_BINARY

public static final transient int IS_BINARY
See Also:
Constant Field Values

IS_PATTERN

public static final transient int IS_PATTERN
See Also:
Constant Field Values

IS_MAP

public static final transient int IS_MAP
See Also:
Constant Field Values

IS_RANGE

public static final transient int IS_RANGE
See Also:
Constant Field Values

IS_ENUMERATION

public static final transient int IS_ENUMERATION
See Also:
Constant Field Values

IS_TUPLE

public static final transient int IS_TUPLE
See Also:
Constant Field Values

IS_LIST

public static final transient int IS_LIST
See Also:
Constant Field Values

IS_ARRAY

public static final transient int IS_ARRAY
See Also:
Constant Field Values

IS_CLASS

public static final transient int IS_CLASS
See Also:
Constant Field Values

IS_INF

public static final transient int IS_INF
See Also:
Constant Field Values

p_equals

public static final java.lang.Object[] p_equals

p_compareTo

public static final java.lang.Object[] p_compareTo

p_each

public static final java.lang.Object[] p_each

p_pipe

public static final java.lang.Object[] p_pipe

p_select

public static final java.lang.Object[] p_select

_class

public static final NativeClass _class
Constructor Detail

Any

protected Any()
Constructs Any containing IS_NULL.

Method Detail

create

public static Any create()
Constructs Any containing IS_NULL.


create

public static Any create(char ch)
Constructs Any containing IS_STRING with length == 1 and charAt(0) == ch.


create

public static Any create(java.lang.String string)
Constructs Any containing IS_STRING

Parameters:
string - String value

create

public static Any create(java.lang.String[] array)

create

public static Any create(int integer)
Constructs Any containing IS_INT

Parameters:
integer - int value

create

public static Any create(long lng)
Constructs Any containing IS_INT

Parameters:
lng - long value

create

public static Any create(java.lang.Integer integer)
Constructs Any containing IS_INT


create

public static Any create(double dbl)
Constructs Any containing IS_DOUBLE

Parameters:
dbl - double value

create

public static Any create(java.lang.Double dbl)
Constructs Any containing IS_DOUBLE

Parameters:
dbl - java.lang.Double value

create

public static Any create(boolean bool)
Constructs Any containing IS_BOOLEAN

Parameters:
bool - boolean value

create

public static Any create(java.lang.Boolean bool)
Constructs Any containing IS_BOOLEAN

Parameters:
bool - java.lang.Boolean value

create

public static Any create(int type,
                         java.lang.String value)
Constructs Any with spefified type and value

Parameters:
type - type of value
value - string presentation of value of given type

create

public static Any create(java.lang.Object object)

create

public static Any create(Any any)
Constructs Any from another Any instance

Parameters:
any - Any value

clone

public java.lang.Object clone()
Returns shallow copy from this any.

Overrides:
clone in class java.lang.Object
Returns:
Shallow copy

_clone

protected void _clone(Any source)

copy

public Any copy()
Returns deep copy from this any.


_copy

protected void _copy(Any source)

sizeOf

public int sizeOf()
Returns the logical size of this any.

Returns:
Logical size

classOf

public ClassType classOf()
Returns the type of this Any.


type

public Type type()

typeOf

public int typeOf()
Returns the type of contained value.

Returns:
Type of this any as int.

classNameOf

public final java.lang.String classNameOf()
Returns the classname of contained object


isInstanceOf

public boolean isInstanceOf(Type ofType)
Checks if this any is of given type.

Returns:
true if this any if of given type.

isDefined

public boolean isDefined()
Checks if this any is defined. Only undefined returns false for this method.

Returns:
true if this is other than undefined

isUndefined

public boolean isUndefined()
Checks if this any is undefined.

Returns:
true if this is undefined

isNull

public boolean isNull()
Checks if this any is null.

Returns:
true if this is null

isBoolean

public boolean isBoolean()
Checks if this any is boolean.

Returns:
true if this is boolean

isInt

public boolean isInt()
Checks if this any is int.

Returns:
true if this is int

isDouble

public boolean isDouble()
Checks if this any is float. In script the float is used, but the implementation uses double.

Returns:
true if this is float

isMutable

public boolean isMutable()

isSequence

public boolean isSequence()

isString

public boolean isString()
Checks if this any is string.

Returns:
true if this is string

isBinary

public boolean isBinary()
Checks if this any is binary.

Returns:
true if this is binary

isTuple

public boolean isTuple()
Checks if this any is tuple.

Returns:
true if this is tuple

isList

public boolean isList()
Checks if this any is list.

Returns:
true if this is list

isArray

public boolean isArray()
Checks if this any is array.

Returns:
true if this is array

isPattern

public boolean isPattern()
Checks if this any is pattern.

Returns:
true if this is pattern

isRange

public boolean isRange()
Checks if this any is range.

Returns:
true if this is range

isMap

public boolean isMap()
Checks if this any is map.

Returns:
true if this is map

isBuffer

public boolean isBuffer()
Checks if this any is buffer.

Returns:
true if this is buffer

isIterator

public boolean isIterator()
Checks if this any is iterator.

Returns:
true if this is iterator

isRef

public boolean isRef()

setRef

public Any setRef(Any value)

getRef

public Any getRef()

toObject

public java.lang.Object toObject()
Gets the contained value as java.lang.Object.

Returns:
Value as Object.

toInt

public int toInt()
Gets the contained value as int.

Returns:
Value as int or zero if it can't be transformed.

toByte

public byte toByte()

toLong

public long toLong()
Gets the contained value as long.

Returns:
Value as long or zero if it can't be transformed.

toDouble

public double toDouble()
Gets the contained value as double.

Returns:
Value as double or 0.0 if it can't be transformed.

toBoolean

public boolean toBoolean()
Gets the contained value as boolean. Integer is considered true if it is different from 0. Double is considered true if it is different from 0.0. String is considered true if it contains "true", "on", "yes" or "1".

Returns:
Value as boolean or false if it can't be transformed.

toChar

public char toChar()
Gets the contained value as char. Value is converted to string and first character is returned.

Returns:
Value as char

toString

public java.lang.String toString()
Converts contained value into String.

Overrides:
toString in class java.lang.Object
Returns:
Value as String.

toBuffer

public java.lang.StringBuffer toBuffer()

toAnvil

public java.lang.String toAnvil()
Converts contained value into value anvil code.

Returns:
Value as anvil code.

toAnvil

public java.io.Writer toAnvil(java.io.Writer writer)
                       throws java.io.IOException
java.io.IOException

toCode

public Code toCode(Code code)

toArray

public Array toArray()
Gets the contained vaelue as Array.

Returns:
Value as Array or null if this instance doesn't contain Array.

toBinary

public byte[] toBinary()
Gets the contained value as byte[].

Returns:
Value as byte[] or null if this instance isn't AnyBinary.

toTuple

public Any[] toTuple()
Gets the contained value as Any[].

Returns:
Value as Any[] or null if this instance isn't AnyTuple.

toList

public Any[] toList()

toPattern

public java.util.regex.Pattern toPattern()

toMap

public AnyMap toMap()

toRange

public AnyRange toRange()

toAnyBoolean

public Any toAnyBoolean()
Gets the contained value as AnyTrue or AnyFalse

Returns:
Value as AnyBoolean.

toAnyInt

public Any toAnyInt()
Gets the contained value as AnyInt.

Returns:
Value as AnyInt.

toAnyDouble

public Any toAnyDouble()
Gets the contained value as AnyDouble.

Returns:
Value as AnyDouble.

toAnyString

public Any toAnyString()
Converts contained value into AnyString.

Returns:
Value as AnyString.

concat

public Any concat(Any any)
Concatenated two Any's together. Returned type will be IS_STRING.

Parameters:
any - Value of add
Returns:
Calculated value

add

public Any add(Any other)
Adds two Any's together.

Returns:
Calculated value

subtract

public Any subtract(Any b)
Substract two Any's.

Returns:
Calculated value

multiply

public Any multiply(Any b)
Multiply two Any's. Returned type will be the same as of this instance. Will only work with integer and double.

Returns:
Calculated value

divide

public Any divide(Any b)
Divide two Any's.

Returns:
Calculated value

modulo

public Any modulo(Any b)
Calculate the remainder.

Returns:
Calculated value

increase

public Any increase()
Increase the value by one.

Returns:
Increased value

decrease

public Any decrease()
Decrease the value by one.

Returns:
Decreased value

minus

public Any minus()
Negate the sign.

Returns:
Negated value

plus

public Any plus()
Remove the sign.

Returns:
Value, with sign removed

not

public Any not()

equals

public boolean equals(java.lang.Object obj)
Tests for equality.

Overrides:
equals in class java.lang.Object
Returns:
true if equal, false otherwise.

compareTo

public final int compareTo(java.lang.Object obj)
Compares two Any's. Will not work with Hashtable.

Specified by:
compareTo in interface java.lang.Comparable
Returns:
-1 if this is less than paramter. 0 if equal. 1 if this if greater than parameter.

compare

protected int compare(Any other)

coerce

public Any coerce()

serialize

public void serialize(Serializer serializer)
               throws java.io.IOException
java.io.IOException

_serialize

protected void _serialize(Serializer serializer)
                   throws java.io.IOException
java.io.IOException

_wakeup

protected void _wakeup(Context context)

_unserialize

protected void _unserialize(Unserializer unserializer)
                     throws UnserializationException
UnserializationException

contains

public boolean contains(Any value)

getAttribute

public Any getAttribute(Context context,
                        java.lang.String attribute)

setAttribute

public Any setAttribute(Context context,
                        java.lang.String attribute,
                        Any value)

deleteAttribute

public boolean deleteAttribute(Context context,
                               java.lang.String attribute)

getReference

public Any getReference(Context context,
                        Any index)

setReference

public Any setReference(Context context,
                        Any index,
                        Any value)

setReference

public Any setReference(Context context,
                        Any value)

deleteReference

public boolean deleteReference(Context context,
                               Any index)

iterator

public BindingIterator iterator()

execute

public Any execute(Context context,
                   Any[] parameters)

execute

public Any execute(Context context)

execute

public Any execute(Context context,
                   Any param1)

execute

public Any execute(Context context,
                   Any param1,
                   Any param2)

execute

public Any execute(Context context,
                   Any param1,
                   Any param2,
                   Any param3)

execute

public Any execute(Context context,
                   Any param1,
                   Any param2,
                   Any param3,
                   Any param4)

has

public boolean has(java.lang.String methodName)

invoke

public Any invoke(Context context,
                  int methodIndex,
                  Any[] parameters)

invoke

public Any invoke(Context context,
                  int methodIndex)

invoke

public Any invoke(Context context,
                  int methodIndex,
                  Any param1)

invoke

public Any invoke(Context context,
                  int methodIndex,
                  Any param1,
                  Any param2)

invoke

public Any invoke(Context context,
                  int methodIndex,
                  Any param1,
                  Any param2,
                  Any param3)

invoke

public Any invoke(Context context,
                  int methodIndex,
                  Any param1,
                  Any param2,
                  Any param3,
                  Any param4)

invoke

public Any invoke(Context context,
                  java.lang.String methodName,
                  Any[] parameters)

invoke

public Any invoke(Context context,
                  java.lang.String methodName)

invoke

public Any invoke(Context context,
                  java.lang.String methodName,
                  Any param1)

invoke

public Any invoke(Context context,
                  java.lang.String methodName,
                  Any param1,
                  Any param2)

invoke

public Any invoke(Context context,
                  java.lang.String methodName,
                  Any param1,
                  Any param2,
                  Any param3)

invoke

public Any invoke(Context context,
                  java.lang.String methodName,
                  Any param1,
                  Any param2,
                  Any param3,
                  Any param4)

_invoke

public Any _invoke(Context context,
                   int methodIndex,
                   Any[] parameters)

_invoke

public Any _invoke(Context context,
                   int methodIndex)

_invoke

public Any _invoke(Context context,
                   int methodIndex,
                   Any param1)

_invoke

public Any _invoke(Context context,
                   int methodIndex,
                   Any param1,
                   Any param2)

_invoke

public Any _invoke(Context context,
                   int methodIndex,
                   Any param1,
                   Any param2,
                   Any param3)

_invoke

public Any _invoke(Context context,
                   int methodIndex,
                   Any param1,
                   Any param2,
                   Any param3,
                   Any param4)

m_copy

public Any m_copy()
Exposed methods


m_clone

public Any m_clone()

m_toBoolean

public Any m_toBoolean()

m_toString

public Any m_toString()

m_hashCode

public Any m_hashCode()

m_equals

public Any m_equals(Any other)

m_compareTo

public Any m_compareTo(Any other)

m_each

public Any m_each(Context context,
                  Any callback)

m_pipe

public Any m_pipe(Context context,
                  Any converter)

m_select

public Any m_select(Context context,
                    Any selector)