com.caucho.quercus.env
Class JavaAdapter

java.lang.Object
  extended by com.caucho.quercus.env.Value
      extended by com.caucho.quercus.env.ArrayValue
          extended by com.caucho.quercus.env.JavaAdapter
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
JavaCollectionAdapter, JavaMapAdapter

public abstract class JavaAdapter
extends ArrayValue
implements java.io.Serializable

Interface for marshalled Java data structures.

See Also:
Serialized Form

Nested Class Summary
 class JavaAdapter.KeySet
           
 
Nested classes/interfaces inherited from class com.caucho.quercus.env.ArrayValue
ArrayValue.AbstractGet, ArrayValue.Entry, ArrayValue.EntryIterator, ArrayValue.EntrySet, ArrayValue.GetKey, ArrayValue.GetValue, ArrayValue.KeyComparator, ArrayValue.KeyIterator, ArrayValue.ValueCollection, ArrayValue.ValueComparator, ArrayValue.ValueIterator
 
Field Summary
 
Fields inherited from class com.caucho.quercus.env.ArrayValue
ARRAY, GET_KEY, GET_VALUE, KEY, VALUE
 
Fields inherited from class com.caucho.quercus.env.Value
L, NULL_ARGS, NULL_VALUE_ARRAY, SCALAR_V
 
Constructor Summary
protected JavaAdapter(java.lang.Object object, JavaClassDef def)
           
 
Method Summary
 ArrayValue append(Value key, Value value)
          Appends as an argument - only called from compiled code XXX: change name to appendArg
 Value callMethod(Env env, StringValue methodName, int hash)
          Evaluates a method.
 Value callMethod(Env env, StringValue methodName, int hash, Value a1)
          Evaluates a method.
 Value callMethod(Env env, StringValue methodName, int hash, Value[] args)
          Evaluates a method.
 Value callMethod(Env env, StringValue methodName, int hash, Value a1, Value a2)
          Evaluates a method.
 Value callMethod(Env env, StringValue methodName, int hash, Value a1, Value a2, Value a3)
          Evaluates a method.
 Value callMethod(Env env, StringValue methodName, int hash, Value a1, Value a2, Value a3, Value a4)
          Evaluates a method.
 Value callMethod(Env env, StringValue methodName, int hash, Value a1, Value a2, Value a3, Value a4, Value a5)
          Evaluates a method.
 Value callMethodRef(Env env, StringValue methodName, int hash)
          Evaluates a method.
 Value callMethodRef(Env env, StringValue methodName, int hash, Value a1)
          Evaluates a method.
 Value callMethodRef(Env env, StringValue methodName, int hash, Value[] args)
          Evaluates a method.
 Value callMethodRef(Env env, StringValue methodName, int hash, Value a1, Value a2)
          Evaluates a method.
 Value callMethodRef(Env env, StringValue methodName, int hash, Value a1, Value a2, Value a3)
          Evaluates a method.
 Value callMethodRef(Env env, StringValue methodName, int hash, Value a1, Value a2, Value a3, Value a4)
          Evaluates a method.
 Value callMethodRef(Env env, StringValue methodName, int hash, Value a1, Value a2, Value a3, Value a4, Value a5)
          Evaluates a method.
abstract  void clear()
          Clears the array
 Value contains(Value value)
          Returns the corresponding key if this array contains the given value
 Value containsKey(Value key)
          Returns the corresponding valeu if this array contains the given key
 Value containsStrict(Value value)
          Returns the corresponding key if this array contains the given value
abstract  Value copy()
          Copy for assignment.
abstract  Value copy(Env env, java.util.IdentityHashMap<Value,Value> map)
          Copy for serialization
abstract  Value createTailKey()
          Creatse a tail index.
 Value current()
          Returns the current value.
 Value each()
          The each iterator
 Value end()
          Returns the last value.
abstract  java.util.Set<java.util.Map.Entry<Value,Value>> entrySet()
          Returns a set of all the entries.
 AbstractFunction findFunction(StringValue methodName)
          Returns the method.
abstract  Value get(Value key)
          Gets a new value.
 Value getArg(Value index, boolean isTop)
          Returns the value as an argument which may be a reference.
 JavaClassDef getClassDef()
           
 Env getEnv()
           
 Value getField(Env env, StringValue name)
          Returns the field value
 ArrayValue.Entry getHead()
          Returns the head.
 java.util.Collection<Value> getIndices()
          Returns the field values.
 java.lang.String getName()
          Returns the class name.
abstract  int getSize()
          Returns the size.
protected  ArrayValue.Entry getTail()
          Returns the tail.
 Var getVar(Value index)
          Returns the array ref.
 boolean hasCurrent()
          Returns true if there are more elements.
 boolean isA(java.lang.String name)
          Returns true for an implementation of a class
 Value key()
          Returns the current key
 boolean keyReset(long base, boolean strict)
          Resets all numerical keys with the first index as base
 java.util.Set<Value> keySet()
          Returns an iterator of the entries.
 Value next()
          Returns the next value.
abstract  java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> objectEntrySet()
          Returns a java object set of all the entries.
 Value pop(Env env)
          Pops the top value.
 Value prev()
          Returns the previous value.
protected  void printRImpl(Env env, WriteStream out, int depth, java.util.IdentityHashMap<Value,java.lang.String> valueSet)
           
 Value put(Value value)
          Adds a new value.
 Value put(Value key, Value value)
          Adds a new value.
 Value putField(Env env, StringValue name, Value value)
          Returns the field ref.
abstract  Value putImpl(Value key, Value value)
          Adds a new value.
 Var putVar()
          Sets the array ref.
abstract  Value remove(Value key)
          Removes a value.
 Value reset()
          Returns the first value.
 void serialize(Env env, java.lang.StringBuilder sb)
          Serializes the value.
 Value shuffle()
          Shuffles the array
 void sort(java.util.Comparator<java.util.Map.Entry<Value,Value>> comparator, boolean resetKeys, boolean strict)
          Sorts this array based using the passed Comparator
 ArrayValue splice(int begin, int end, ArrayValue replace)
          Splices.
 java.util.Map.Entry<Value,Value>[] toEntryArray()
          Returns an object array of this array.
 java.util.Collection toJavaCollection(Env env, java.lang.Class type)
          Converts to a java List object.
 java.util.List toJavaList(Env env, java.lang.Class type)
          Converts to a java List object.
 java.util.Map toJavaMap(Env env, java.lang.Class type)
          Converts to a java object.
 java.lang.Object toJavaObject()
          Converts to a Java object.
 java.lang.Object toJavaObjectNotNull(Env env, java.lang.Class type)
          Converts to a java object.
 java.lang.Object toObject()
          Converts to an object.
 Value toObject(Env env)
          Converts to an object.
 java.lang.String toString()
          Converts to a string.
 ArrayValue unshift(Value value)
          Add to front.
 java.util.Collection<Value> values()
          Returns a collection of the values.
 Value[] valuesToArray()
          Takes the values of this array and puts them in a java array
 java.lang.Object valuesToArray(Env env, java.lang.Class elementType)
          Takes the values of this array, unmarshalls them to objects of type elementType, and puts them in a java array.
 void varDumpImpl(Env env, WriteStream out, int depth, java.util.IdentityHashMap<Value,java.lang.String> valueSet)
           
 void varExport(java.lang.StringBuilder sb)
          Exports the value.
 Value wrapJava(java.lang.Object obj)
           
 
Methods inherited from class com.caucho.quercus.env.ArrayValue
add, append, callCallback, callCallback, callCallback, cmp, copyReturn, eq, eql, geq, getArray, getBaseIterator, getCount, getCountRecursive, getCurrent, getIterator, getKeyArray, getKeyIterator, getKeys, getObject, getRaw, getType, getValueArray, getValueIterator, getValues, getValueType, gt, isArray, isCallable, isEmpty, isset, jsonEncode, keyExists, keysToArray, leq, lt, print, printREntry, put, put, put, put, put, put, put, put, put, put, put, putAll, serialize, setCurrent, slice, toArray, toArray, toArrayValue, toAutoArray, toBinaryValueMarshalCost, toBoolean, toCallable, toCharMarshalCost, toDouble, toKey, toLocalRef, toLong, toStringMarshalCost, toStringValueMarshalCost, toUnicodeValueMarshalCost, varDumpEntry
 
Methods inherited from class com.caucho.quercus.env.Value
abs, add, addOne, appendTo, appendTo, appendTo, appendTo, bitAnd, bitOr, bitXor, call, call, call, call, call, call, call, callCopy, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callRef, callRef, callRef, callRef, callRef, callRef, callRef, charValueAt, checkPrivate, checkProtected, clone, copy, copyArrayItem, copySaveFunArg, copyStringBuilder, copyTree, div, div, eqValue, findFunction, generate, getArray, getCallableName, getCalledClass, getClassName, getDirty, getFieldArg, getFieldArgRef, getFieldArray, getFieldObject, getFieldVar, getHashCode, getIterator, getObject, getQuercusClass, getRef, getResourceType, getThisField, getThisFieldArg, getThisFieldArgRef, getThisFieldArray, getThisFieldObject, getThisFieldVar, hashCode, increment, initField, isA, isBinary, isBoolean, isDefault, isDouble, isDoubleConvertible, isFieldInit, isLong, isLongConvertible, isNull, isNumberConvertible, isNumeric, isObject, isResource, isset, issetField, issetThisField, isString, isUnicode, isVar, length, lshift, mod, mul, mul, neg, nextIndex, pos, postdecr, postincr, postincr, predecr, preincr, preincr, print, printDepth, printJavaChar, printJavaString, printR, put, putField, putField, putObject, putThisField, putThisField, rshift, set, setCharValueAt, setFieldInit, setJavaObject, sub_rev, sub, sub, subOne, toArgRef, toAutoObject, toBigDecimal, toBigInteger, toBinaryValue, toBinaryValue, toBinaryValue, toBooleanMarshalCost, toByteArrayMarshalCost, toByteMarshalCost, toChar, toCharArrayMarshalCost, toDebugString, toDoubleMarshalCost, toDoubleValue, toException, toFloatMarshalCost, toInputStream, toInt, toIntegerMarshalCost, toInternString, toJavaBoolean, toJavaByte, toJavaCalendar, toJavaCharacter, toJavaDate, toJavaDouble, toJavaFloat, toJavaInteger, toJavaLong, toJavaObject, toJavaObjectMarshalCost, toJavaShort, toJavaString, toJavaURL, toLocalThis, toLocalValue, toLocalValueReadOnly, toLocalVar, toLocalVarDeclAsRef, toLongMarshalCost, toLongValue, toRef, toRefValue, toShortMarshalCost, toString, toStringBuilder, toStringBuilder, toStringBuilder, toStringBuilder, toStringValue, toStringValue, toUnicode, toUnicodeValue, toUnicodeValue, toValue, toVar, unsetArray, unsetField, unsetThisArray, unsetThisField, varDump
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaAdapter

protected JavaAdapter(java.lang.Object object,
                      JavaClassDef def)
Method Detail

getClassDef

public JavaClassDef getClassDef()

getEnv

public Env getEnv()

wrapJava

public Value wrapJava(java.lang.Object obj)

toObject

public java.lang.Object toObject()
Converts to an object.

Overrides:
toObject in class ArrayValue

toJavaObject

public java.lang.Object toJavaObject()
Converts to a Java object.

Overrides:
toJavaObject in class ArrayValue

toJavaObjectNotNull

public java.lang.Object toJavaObjectNotNull(Env env,
                                            java.lang.Class type)
Converts to a java object.

Overrides:
toJavaObjectNotNull in class Value

toObject

public Value toObject(Env env)
Converts to an object.

Overrides:
toObject in class ArrayValue

toJavaCollection

public java.util.Collection toJavaCollection(Env env,
                                             java.lang.Class type)
Converts to a java List object.

Overrides:
toJavaCollection in class ArrayValue

toJavaList

public java.util.List toJavaList(Env env,
                                 java.lang.Class type)
Converts to a java List object.

Overrides:
toJavaList in class ArrayValue

toJavaMap

public java.util.Map toJavaMap(Env env,
                               java.lang.Class type)
Converts to a java object.

Overrides:
toJavaMap in class ArrayValue

copy

public abstract Value copy()
Copy for assignment.

Specified by:
copy in class ArrayValue

copy

public abstract Value copy(Env env,
                           java.util.IdentityHashMap<Value,Value> map)
Copy for serialization

Specified by:
copy in class ArrayValue

getSize

public abstract int getSize()
Returns the size.

Specified by:
getSize in class ArrayValue

clear

public abstract void clear()
Clears the array

Specified by:
clear in class ArrayValue

put

public final Value put(Value value)
Adds a new value.

Specified by:
put in class ArrayValue

put

public final Value put(Value key,
                       Value value)
Adds a new value.

Overrides:
put in class ArrayValue

putImpl

public abstract Value putImpl(Value key,
                              Value value)
Adds a new value.


unshift

public ArrayValue unshift(Value value)
Add to front.

Specified by:
unshift in class ArrayValue

splice

public ArrayValue splice(int begin,
                         int end,
                         ArrayValue replace)
Splices.

Specified by:
splice in class ArrayValue

getArg

public Value getArg(Value index,
                    boolean isTop)
Returns the value as an argument which may be a reference.

Specified by:
getArg in class ArrayValue

putVar

public Var putVar()
Sets the array ref.

Specified by:
putVar in class ArrayValue

createTailKey

public abstract Value createTailKey()
Creatse a tail index.

Specified by:
createTailKey in class ArrayValue

getIndices

public java.util.Collection<Value> getIndices()
Returns the field values.


get

public abstract Value get(Value key)
Gets a new value.

Specified by:
get in class ArrayValue

remove

public abstract Value remove(Value key)
Removes a value.

Specified by:
remove in class ArrayValue

getVar

public Var getVar(Value index)
Returns the array ref.

Specified by:
getVar in class ArrayValue

keySet

public java.util.Set<Value> keySet()
Returns an iterator of the entries.

Overrides:
keySet in class ArrayValue

entrySet

public abstract java.util.Set<java.util.Map.Entry<Value,Value>> entrySet()
Returns a set of all the entries.

Overrides:
entrySet in class ArrayValue

objectEntrySet

public abstract java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> objectEntrySet()
Returns a java object set of all the entries.


values

public java.util.Collection<Value> values()
Returns a collection of the values.

Overrides:
values in class ArrayValue

append

public ArrayValue append(Value key,
                         Value value)
Appends as an argument - only called from compiled code XXX: change name to appendArg

Specified by:
append in class ArrayValue

pop

public Value pop(Env env)
Pops the top value.

Specified by:
pop in class ArrayValue

shuffle

public Value shuffle()
Shuffles the array

Specified by:
shuffle in class ArrayValue

getHead

public ArrayValue.Entry getHead()
Returns the head.

Specified by:
getHead in class ArrayValue

getTail

protected ArrayValue.Entry getTail()
Returns the tail.

Specified by:
getTail in class ArrayValue

current

public Value current()
Returns the current value.

Overrides:
current in class ArrayValue

key

public Value key()
Returns the current key

Overrides:
key in class ArrayValue

hasCurrent

public boolean hasCurrent()
Returns true if there are more elements.

Overrides:
hasCurrent in class ArrayValue

next

public Value next()
Returns the next value.

Overrides:
next in class ArrayValue

prev

public Value prev()
Returns the previous value.

Overrides:
prev in class ArrayValue

each

public Value each()
The each iterator

Overrides:
each in class ArrayValue

reset

public Value reset()
Returns the first value.

Overrides:
reset in class ArrayValue

end

public Value end()
Returns the last value.

Overrides:
end in class ArrayValue

contains

public Value contains(Value value)
Returns the corresponding key if this array contains the given value

Specified by:
contains in class ArrayValue
Parameters:
value - to search for in the array
Returns:
the key if it is found in the array, NULL otherwise
Throws:
java.lang.NullPointerException

containsStrict

public Value containsStrict(Value value)
Returns the corresponding key if this array contains the given value

Specified by:
containsStrict in class ArrayValue
Parameters:
value - to search for in the array
Returns:
the key if it is found in the array, NULL otherwise

containsKey

public Value containsKey(Value key)
Returns the corresponding valeu if this array contains the given key

Specified by:
containsKey in class ArrayValue
Parameters:
key - to search for in the array
Returns:
the value if it is found in the array, NULL otherwise

toEntryArray

public java.util.Map.Entry<Value,Value>[] toEntryArray()
Returns an object array of this array. This is a copy of this object's backing structure. Null elements are not included.

Overrides:
toEntryArray in class ArrayValue
Returns:
an object array of this array

sort

public void sort(java.util.Comparator<java.util.Map.Entry<Value,Value>> comparator,
                 boolean resetKeys,
                 boolean strict)
Sorts this array based using the passed Comparator

Overrides:
sort in class ArrayValue
Parameters:
comparator - the comparator for sorting the array
resetKeys - true if the keys should not be preserved
strict - true if alphabetic keys should not be preserved

serialize

public void serialize(Env env,
                      java.lang.StringBuilder sb)
Serializes the value.

Overrides:
serialize in class Value

varExport

public void varExport(java.lang.StringBuilder sb)
Exports the value.

Overrides:
varExport in class ArrayValue

keyReset

public boolean keyReset(long base,
                        boolean strict)
Resets all numerical keys with the first index as base

Overrides:
keyReset in class ArrayValue
Parameters:
base - the initial index
strict - if true, string keys are also reset

valuesToArray

public Value[] valuesToArray()
Takes the values of this array and puts them in a java array

Overrides:
valuesToArray in class ArrayValue

valuesToArray

public java.lang.Object valuesToArray(Env env,
                                      java.lang.Class elementType)
Takes the values of this array, unmarshalls them to objects of type elementType, and puts them in a java array.

Overrides:
valuesToArray in class ArrayValue

getField

public Value getField(Env env,
                      StringValue name)
Description copied from class: Value
Returns the field value

Overrides:
getField in class Value

putField

public Value putField(Env env,
                      StringValue name,
                      Value value)
Description copied from class: Value
Returns the field ref.

Overrides:
putField in class Value

getName

public java.lang.String getName()
Returns the class name.


isA

public boolean isA(java.lang.String name)
Description copied from class: Value
Returns true for an implementation of a class

Overrides:
isA in class Value

findFunction

public AbstractFunction findFunction(StringValue methodName)
Returns the method.


callMethod

public Value callMethod(Env env,
                        StringValue methodName,
                        int hash,
                        Value[] args)
Evaluates a method.

Overrides:
callMethod in class Value

callMethod

public Value callMethod(Env env,
                        StringValue methodName,
                        int hash)
Evaluates a method.

Overrides:
callMethod in class Value

callMethod

public Value callMethod(Env env,
                        StringValue methodName,
                        int hash,
                        Value a1)
Evaluates a method.

Overrides:
callMethod in class Value

callMethod

public Value callMethod(Env env,
                        StringValue methodName,
                        int hash,
                        Value a1,
                        Value a2)
Evaluates a method.

Overrides:
callMethod in class Value

callMethod

public Value callMethod(Env env,
                        StringValue methodName,
                        int hash,
                        Value a1,
                        Value a2,
                        Value a3)
Evaluates a method.

Overrides:
callMethod in class Value

callMethod

public Value callMethod(Env env,
                        StringValue methodName,
                        int hash,
                        Value a1,
                        Value a2,
                        Value a3,
                        Value a4)
Evaluates a method.

Overrides:
callMethod in class Value

callMethod

public Value callMethod(Env env,
                        StringValue methodName,
                        int hash,
                        Value a1,
                        Value a2,
                        Value a3,
                        Value a4,
                        Value a5)
Evaluates a method.

Overrides:
callMethod in class Value

callMethodRef

public Value callMethodRef(Env env,
                           StringValue methodName,
                           int hash,
                           Value[] args)
Evaluates a method.

Overrides:
callMethodRef in class Value

callMethodRef

public Value callMethodRef(Env env,
                           StringValue methodName,
                           int hash)
Evaluates a method.

Overrides:
callMethodRef in class Value

callMethodRef

public Value callMethodRef(Env env,
                           StringValue methodName,
                           int hash,
                           Value a1)
Evaluates a method.

Overrides:
callMethodRef in class Value

callMethodRef

public Value callMethodRef(Env env,
                           StringValue methodName,
                           int hash,
                           Value a1,
                           Value a2)
Evaluates a method.

Overrides:
callMethodRef in class Value

callMethodRef

public Value callMethodRef(Env env,
                           StringValue methodName,
                           int hash,
                           Value a1,
                           Value a2,
                           Value a3)
Evaluates a method.

Overrides:
callMethodRef in class Value

callMethodRef

public Value callMethodRef(Env env,
                           StringValue methodName,
                           int hash,
                           Value a1,
                           Value a2,
                           Value a3,
                           Value a4)
Evaluates a method.

Overrides:
callMethodRef in class Value

callMethodRef

public Value callMethodRef(Env env,
                           StringValue methodName,
                           int hash,
                           Value a1,
                           Value a2,
                           Value a3,
                           Value a4,
                           Value a5)
Evaluates a method.

Overrides:
callMethodRef in class Value

varDumpImpl

public void varDumpImpl(Env env,
                        WriteStream out,
                        int depth,
                        java.util.IdentityHashMap<Value,java.lang.String> valueSet)
                 throws java.io.IOException
Overrides:
varDumpImpl in class ArrayValue
Throws:
java.io.IOException

printRImpl

protected void printRImpl(Env env,
                          WriteStream out,
                          int depth,
                          java.util.IdentityHashMap<Value,java.lang.String> valueSet)
                   throws java.io.IOException
Overrides:
printRImpl in class ArrayValue
Throws:
java.io.IOException

toString

public java.lang.String toString()
Converts to a string.

Overrides:
toString in class ArrayValue