com.caucho.quercus.env
Class ArrayValueImpl

java.lang.Object
  extended by com.caucho.quercus.env.Value
      extended by com.caucho.quercus.env.ArrayValue
          extended by com.caucho.quercus.env.ArrayValueImpl
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ArrayCopyValueImpl, ConstArrayValue, GlobalArrayValue, ServerArrayValue

public class ArrayValueImpl
extends ArrayValue
implements java.io.Serializable

Represents a PHP array value.

See Also:
Serialized Form

Nested Class Summary
 
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.KeySet, ArrayValue.ValueCollection, ArrayValue.ValueComparator, ArrayValue.ValueIterator
 
Field Summary
 
Fields inherited from class com.caucho.quercus.env.ArrayValue
ARRAY, GET_KEY, GET_VALUE
 
Fields inherited from class com.caucho.quercus.env.Value
L, NULL_ARGS, NULL_VALUE_ARRAY, SCALAR_V
 
Constructor Summary
  ArrayValueImpl()
           
  ArrayValueImpl(ArrayValue source)
           
  ArrayValueImpl(ArrayValueComponent[] components)
           
  ArrayValueImpl(ArrayValueImpl source)
           
  ArrayValueImpl(ConstArrayValue source)
           
  ArrayValueImpl(Env env, ArrayValueComponent[] components)
           
protected ArrayValueImpl(Env env, ArrayValue copy, CopyRoot root)
          Copy for unserialization.
  ArrayValueImpl(Env env, java.util.IdentityHashMap<Value,Value> map, ArrayValue copy)
           
  ArrayValueImpl(int size)
           
  ArrayValueImpl(Value[] values)
           
  ArrayValueImpl(Value[] keys, Value[] values)
           
 
Method Summary
 ArrayValue append(Value key, Value value)
          Adds a new value.
 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 value if this array contains the given key
 Value containsStrict(Value value)
          Returns the corresponding key if this array contains the given value
 Value copy()
          Copy the value.
 Value copy(Env env, java.util.IdentityHashMap<Value,Value> map)
          Copy for serialization
protected  void copyFrom(ArrayValueImpl source)
           
 Value copyReturn()
          Copy for return.
 Value copySaveFunArg()
          Copy for saving a method's arguments.
 Value copyTree(Env env, CopyRoot root)
          Copy for serialization
 Value createTailKey()
          Creatse a tail index.
 void generate(java.io.PrintWriter out)
          Generates code to recreate the expression.
 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.
 Value getArray(Value index)
          Returns the value as an array.
 Value getDirty(Value index)
          Returns the value as an array, using copy on write if necessary.
protected  ArrayValue.Entry[] getEntries()
           
protected  int getHashMask()
           
 ArrayValue.Entry getHead()
          Returns the head.
 Value getKeys()
          Returns the array keys.
protected  long getNextAvailableIndex()
           
 Value getObject(Env env, Value fieldName)
          Returns the field value, creating an object if it's unset.
 Value getRaw(Value key)
          Returns the value in the array as-is.
 Var getRef(Value index)
          Returns the array ref.
 int getSize()
          Returns the size.
protected  ArrayValue.Entry getTail()
          Returns the tail.
 java.lang.String getType()
          Returns the type.
 Value getValues()
          Returns the array keys.
 Var getVar(Value index)
          Returns the array ref.
 boolean isArray()
          Returns true for an array.
 Value pop(Env env)
          Pops the top value.
 Value put(Value value)
          Add
 Var putVar()
          Sets the array ref.
 Value remove(Value key)
          Removes a value.
 Value shuffle()
          Shuffles the array
 int size()
          Returns the size.
 ArrayValue slice(Env env, int start, int end, boolean isPreserveKeys)
          Slices.
 ArrayValue splice(int start, int end, ArrayValue replace)
          Replace a section of the array.
 boolean toBoolean()
          Converts to a boolean.
 Value toLocalRef()
          Convert to an argument value.
 Value toLocalValue()
          Convert to an argument value.
 java.lang.Object toObject()
          Converts to an object.
 Value toRefValue()
          Convert to an argument declared as a reference
 StringValue toString(Env env)
          Converts to a string.
 ArrayValue unshift(Value value)
          Add to the beginning
 
Methods inherited from class com.caucho.quercus.env.ArrayValue
add, append, callCallback, callCallback, callCallback, cmp, current, each, end, entrySet, eq, eql, geq, getBaseIterator, getCount, getCountRecursive, getCurrent, getIterator, getKeyArray, getKeyIterator, getValueArray, getValueIterator, getValueType, gt, hasCurrent, isCallable, isEmpty, isset, jsonEncode, key, keyExists, keyReset, keySet, keysToArray, leq, lt, next, prev, print, printREntry, printRImpl, put, put, put, put, put, put, put, put, put, put, put, put, putAll, reset, serialize, setCurrent, sort, toArray, toArray, toArrayValue, toAutoArray, toBinaryValueMarshalCost, toCallable, toCharMarshalCost, toDouble, toEntryArray, toJavaCollection, toJavaList, toJavaMap, toJavaObject, toKey, toLong, toObject, toString, toStringMarshalCost, toStringValueMarshalCost, toUnicodeValueMarshalCost, values, valuesToArray, valuesToArray, varDumpEntry, varDumpImpl, varExport
 
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, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callRef, callRef, callRef, callRef, callRef, callRef, callRef, charValueAt, checkPrivate, checkProtected, clone, copy, copyArrayItem, copyStringBuilder, div, div, eqValue, findFunction, getArray, getCallableName, getCalledClass, getClassName, getField, getFieldArg, getFieldArgRef, getFieldArray, getFieldObject, getFieldVar, getHashCode, getIterator, getObject, getQuercusClass, getResourceType, getThisField, getThisFieldArg, getThisFieldArgRef, getThisFieldArray, getThisFieldObject, getThisFieldVar, hashCode, increment, initField, isA, 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, putField, putObject, putThisField, putThisField, rshift, serialize, 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, toJavaObjectNotNull, toJavaShort, toJavaString, toJavaURL, toLocalThis, toLocalValueReadOnly, toLocalVar, toLocalVarDeclAsRef, toLongMarshalCost, toLongValue, toRef, toShortMarshalCost, 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

ArrayValueImpl

public ArrayValueImpl()

ArrayValueImpl

public ArrayValueImpl(int size)

ArrayValueImpl

public ArrayValueImpl(ArrayValue source)

ArrayValueImpl

public ArrayValueImpl(ArrayValueImpl source)

ArrayValueImpl

public ArrayValueImpl(ConstArrayValue source)

ArrayValueImpl

public ArrayValueImpl(Env env,
                      java.util.IdentityHashMap<Value,Value> map,
                      ArrayValue copy)

ArrayValueImpl

protected ArrayValueImpl(Env env,
                         ArrayValue copy,
                         CopyRoot root)
Copy for unserialization. XXX: need to update for references


ArrayValueImpl

public ArrayValueImpl(Value[] keys,
                      Value[] values)

ArrayValueImpl

public ArrayValueImpl(Value[] values)

ArrayValueImpl

public ArrayValueImpl(Env env,
                      ArrayValueComponent[] components)

ArrayValueImpl

public ArrayValueImpl(ArrayValueComponent[] components)
Method Detail

copyFrom

protected void copyFrom(ArrayValueImpl source)

getEntries

protected ArrayValue.Entry[] getEntries()

getHashMask

protected int getHashMask()

getNextAvailableIndex

protected long getNextAvailableIndex()

getType

public java.lang.String getType()
Returns the type.

Overrides:
getType in class ArrayValue

toBoolean

public boolean toBoolean()
Converts to a boolean.

Overrides:
toBoolean in class ArrayValue

toString

public StringValue toString(Env env)
Converts to a string.

Overrides:
toString in class Value
Parameters:
env -

toObject

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

Overrides:
toObject in class ArrayValue

copy

public Value copy()
Copy the value.

Specified by:
copy in class ArrayValue

copyReturn

public Value copyReturn()
Copy for return.

Overrides:
copyReturn in class ArrayValue

copy

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

Specified by:
copy in class ArrayValue

copyTree

public Value copyTree(Env env,
                      CopyRoot root)
Copy for serialization

Overrides:
copyTree in class Value

copySaveFunArg

public Value copySaveFunArg()
Copy for saving a method's arguments.

Overrides:
copySaveFunArg in class Value

toLocalValue

public Value toLocalValue()
Convert to an argument value.

Overrides:
toLocalValue in class Value

toLocalRef

public Value toLocalRef()
Convert to an argument value.

Overrides:
toLocalRef in class ArrayValue

toRefValue

public Value toRefValue()
Convert to an argument declared as a reference

Overrides:
toRefValue in class Value

size

public int size()
Returns the size.


getSize

public int getSize()
Returns the size.

Specified by:
getSize in class ArrayValue

clear

public void clear()
Clears the array

Specified by:
clear in class ArrayValue

isArray

public boolean isArray()
Returns true for an array.

Overrides:
isArray in class ArrayValue

append

public ArrayValue append(Value key,
                         Value value)
Adds a new value.

Specified by:
append in class ArrayValue

unshift

public ArrayValue unshift(Value value)
Add to the beginning

Specified by:
unshift in class ArrayValue

splice

public ArrayValue splice(int start,
                         int end,
                         ArrayValue replace)
Replace a section of the array.

Specified by:
splice in class ArrayValue

slice

public ArrayValue slice(Env env,
                        int start,
                        int end,
                        boolean isPreserveKeys)
Slices.

Overrides:
slice 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

getObject

public Value getObject(Env env,
                       Value fieldName)
Returns the field value, creating an object if it's unset.

Overrides:
getObject in class ArrayValue

getArray

public Value getArray(Value index)
Returns the value as an array.

Overrides:
getArray in class ArrayValue

getDirty

public Value getDirty(Value index)
Returns the value as an array, using copy on write if necessary.

Overrides:
getDirty in class Value

put

public Value put(Value value)
Add

Specified by:
put in class ArrayValue

putVar

public Var putVar()
Sets the array ref.

Specified by:
putVar in class ArrayValue

createTailKey

public Value createTailKey()
Creatse a tail index.

Specified by:
createTailKey in class ArrayValue

get

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

Specified by:
get in class ArrayValue

getRaw

public Value getRaw(Value key)
Returns the value in the array as-is. (i.e. without calling toValue() on it).

Overrides:
getRaw 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

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 value 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

remove

public 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

getRef

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

Overrides:
getRef in class Value

pop

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

Specified by:
pop in class ArrayValue

getHead

public final ArrayValue.Entry getHead()
Description copied from class: ArrayValue
Returns the head.

Specified by:
getHead in class ArrayValue

getTail

protected final ArrayValue.Entry getTail()
Description copied from class: ArrayValue
Returns the tail.

Specified by:
getTail in class ArrayValue

shuffle

public Value shuffle()
Shuffles the array

Specified by:
shuffle in class ArrayValue

getKeys

public Value getKeys()
Returns the array keys.

Overrides:
getKeys in class ArrayValue

getValues

public Value getValues()
Returns the array keys.

Overrides:
getValues in class ArrayValue

generate

public void generate(java.io.PrintWriter out)
              throws java.io.IOException
Generates code to recreate the expression.

Overrides:
generate in class Value
Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException