com.caucho.quercus.env
Class StringValue

java.lang.Object
  extended by com.caucho.quercus.env.Value
      extended by com.caucho.quercus.env.StringValue
All Implemented Interfaces:
java.io.Serializable, java.lang.CharSequence
Direct Known Subclasses:
BinaryValue, LargeStringBuilderValue, StringBuilderValue, UnicodeValue

public abstract class StringValue
extends Value
implements java.lang.CharSequence

Represents a Quercus string value.

See Also:
Serialized Form

Field Summary
static StringValue EMPTY
           
protected static int IS_DOUBLE
           
protected static int IS_LONG
           
protected static int IS_STRING
           
 
Fields inherited from class com.caucho.quercus.env.Value
L, NULL_ARGS, NULL_VALUE_ARRAY, SCALAR_V
 
Constructor Summary
StringValue()
           
 
Method Summary
 Value add(long rValue)
          Adds to the following value.
 StringValue append(boolean v)
          Append a Java boolean to the value.
 StringValue append(byte[] buf)
          Append a byte buffer to the value.
 StringValue append(byte[] buf, int offset, int length)
          Append a byte buffer to the value.
 StringValue append(char v)
          Append a Java char to the value.
 StringValue append(char[] buf)
          Append a Java double to the value.
 StringValue append(char[] buf, int offset, int length)
          Append a Java buffer to the value.
 StringValue append(java.lang.CharSequence buf, int head, int tail)
          Append a Java buffer to the value.
 StringValue append(double v)
          Append a Java double to the value.
 StringValue append(Env env, StringValue unicodeStr, java.lang.String charset)
           
 StringValue append(long v)
          Append a Java long to the value.
 StringValue append(java.lang.Object v)
          Append a Java value to the value.
 StringValue append(java.io.Reader reader)
          Append from a read stream
 StringValue append(java.io.Reader reader, long length)
          Append from a read stream
 StringValue append(java.lang.String s)
          Append a Java string to the value.
 StringValue append(java.lang.String s, int start, int end)
          Append a Java string to the value.
 StringValue append(UnicodeBuilderValue sb, int head, int tail)
          Append a Java buffer to the value.
 StringValue append(Value v)
          Append a Java value to the value.
 StringValue appendByte(int v)
          Append a Java byte to the value without conversions.
 StringValue appendBytes(char[] buf, int offset, int length)
          Append a Java char[] to the value without conversions.
 StringValue appendBytes(java.lang.String s)
          Append a Java String to the value without conversions.
 int appendRead(BinaryInput is, long length)
          Append from an input stream, using InputStream semantics, i.e call is.read() only once.
 int appendRead(java.io.InputStream is, long length)
          Append from an input stream, using InputStream.read semantics, i.e.
 int appendReadAll(BinaryInput is, long length)
          Append from an input stream, reading all available data from the stream.
 int appendReadAll(java.io.InputStream is, long length)
          Append from an input stream, reading from the input stream until end of file or the length is reached.
 StringValue appendTo(UnicodeBuilderValue sb)
          Append to a string builder.
 StringValue appendUnicode(boolean v)
          Append a Java boolean to the value.
 StringValue appendUnicode(char v)
          Append a Java char, possibly converting to a unicode string
 StringValue appendUnicode(char[] buffer)
          Append a Java char buffer, possibly converting to a unicode string
 StringValue appendUnicode(char[] buffer, int offset, int length)
          Append a Java char buffer, possibly converting to a unicode string
 StringValue appendUnicode(double v)
          Append a Java double to the value.
 StringValue appendUnicode(long v)
          Append a Java long to the value.
 StringValue appendUnicode(java.lang.Object v)
          Append a Java value to the value.
 StringValue appendUnicode(java.lang.String value)
          Append a Java char buffer, possibly converting to a unicode string
 StringValue appendUnicode(java.lang.String value, int offset, int length)
          Append a Java char buffer, possibly converting to a unicode string
 StringValue appendUnicode(Value value)
          Append a Java char buffer, possibly converting to a unicode string
 StringValue appendUnicode(Value v1, Value v2)
          Append a Java char buffer, possibly converting to a unicode string
 Value bitAnd(Value rValue)
           
 Value bitOr(Value rValue)
           
 Value bitXor(Value rValue)
           
 char charAt(int index)
          Returns the character at a particular location
 Value charValueAt(long index)
          Returns the character at an index
 int cmp(Value rValue)
          Returns true for equality
 int cmpString(StringValue rValue)
          Compare two strings
 StringValue convertToUnicode(Env env, java.lang.String charset)
          Decodes from charset and returns UnicodeValue.
static StringValue create(char value)
          Creates the string.
 StringValue create(Env env, StringValue unicodeStr, java.lang.String charset)
           
static Value create(java.lang.Object value)
          Creates the string.
static Value create(java.lang.String value)
          Creates the string.
abstract  StringValue createStringBuilder()
          Creates a string builder of the same type.
abstract  StringValue createStringBuilder(int length)
          Creates a string builder of the same type.
 boolean endsWith(StringValue tail)
          Returns true if the string ends with another string.
 void ensureAppendCapacity(int size)
          Ensure enough append capacity.
 boolean eq(Value rValue)
          Returns true for equality
 boolean equals(java.lang.Object o)
          Test for equality
 void generate(java.io.PrintWriter out)
          Generates code to recreate the expression.
 Value get(Value key)
          Returns the character at an index
 Value getArg(Value key)
          Returns the character at an index
 void getChars(int stringOffset, char[] buffer, int offset, int length)
          Copies the chars
abstract  StringValue getEmptyString()
           
 char[] getRawCharArray()
           
 Value getRef(Value key)
          Returns the character at an index
 java.lang.String getType()
          Returns the type.
 ValueType getValueType()
          Returns the ValueType.
 int hashCode()
          Returns the hash code.
 int indexOf(char match)
          Returns the last index of the match string, starting from the head.
 int indexOf(char match, int head)
          Returns the last index of the match string, starting from the head.
 int indexOf(java.lang.CharSequence match)
          Returns the first index of the match string, starting from the head.
 int indexOf(java.lang.CharSequence match, int head)
          Returns the first index of the match string, starting from the head.
 StringValue intern(Quercus quercus)
          Interns the string.
 boolean isDoubleConvertible()
          Returns true for a double
 boolean isEmpty()
          Returns true if the value is empty
 boolean isLongConvertible()
          Returns true for a long
 boolean isNumber()
          Returns true for a number
 boolean isNumeric()
          Returns true for is_numeric
 boolean isPHP5String()
           
 boolean isScalar()
          Returns true for a scalar
 boolean isString()
          Returns true for StringValue
 int lastIndexOf(char match)
          Returns the last index of the match string, starting from the head.
 int lastIndexOf(char match, int tail)
          Returns the last index of the match string, starting from the head.
 int lastIndexOf(java.lang.CharSequence match)
          Returns the last index of the match string, starting from the tail.
 int lastIndexOf(java.lang.CharSequence match, int tail)
          Returns the last index of the match string, starting from the tail.
 int length()
          Returns the length of the string.
 Value postincr(int incr)
          Post-increment the following value.
 Value preincr(int incr)
          Pre-increment the following value.
 boolean regionMatches(int offset, char[] mBuffer, int mOffset, int mLength)
          Returns true if the region matches
 boolean regionMatches(int offset, StringValue match, int mOffset, int mLength)
          Returns true if the region matches
 boolean regionMatchesIgnoreCase(int offset, char[] match, int mOffset, int mLength)
          Returns true if the region matches
 void serialize(Env env, java.lang.StringBuilder sb)
          Serializes the value.
 Value setCharValueAt(long index, java.lang.String value)
          sets the character at an index
 Value sub(long rValue)
          Adds to the following value.
 java.lang.CharSequence subSequence(int start, int end)
          Returns a subsequence
 StringValue substring(int head)
          Returns a StringValue substring.
 StringValue substring(int begin, int end)
          Returns a StringValue substring.
 Value toAutoArray()
          Converts to an array if null.
 Value toAutoObject(Env env)
          Converts to an object.
 StringValue toBinaryValue(Env env, java.lang.String charset)
          Converts to a BinaryValue in desired charset.
 boolean toBoolean()
          Converts to a boolean.
 byte[] toBytes()
           
 char[] toCharArray()
          Returns a character array
abstract  java.lang.String toDebugString()
           
 double toDouble()
          Converts to a double.
static double toDouble(java.lang.String s)
          Converts to a double.
 java.io.InputStream toInputStream()
          Returns a byteArrayInputStream for the value.
 java.io.InputStream toInputStream(java.lang.String charset)
          Returns a byte stream of chars.
 java.lang.Object toJavaObject()
          Converts to a Java object.
 Value toKey()
          Converts to a key.
static long toLong(java.lang.String string)
          Converts to a long.
 StringValue toLowerCase()
          Convert to lower case.
 java.io.Reader toReader(java.lang.String charset)
          Returns a char stream.
 StringValue toStringBuilder(Env env)
          Converts to a string builder
 StringValue toStringValue()
          Converts to a string value.
 StringValue toUnicodeValue(Env env, java.lang.String charset)
          Decodes from charset and returns UnicodeValue.
 StringValue toUpperCase()
          Convert to lower case.
 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.
abstract  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.
 void writeTo(java.io.OutputStream os)
          Writes to a stream
 
Methods inherited from class com.caucho.quercus.env.Value
add, appendTo, appendTo, appendTo, callClassMethod, callMethod, callMethod, 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, callMethodRef, callMethodRef, checkPrivate, checkProtected, clone, copy, copy, copy, copyArrayItem, copyReturn, copyTree, current, div, div, eql, eqValue, findFunction, geq, getArray, getArray, getClassName, getCount, getCountRecursive, getDirty, getField, getFieldArg, getFieldArgRef, getFieldArray, getFieldObject, getFieldRef, getIterator, getKeyArray, getKeyIterator, getObject, getObject, getResourceType, getSize, getThisField, getThisFieldArg, getThisFieldArgRef, getThisFieldArray, getThisFieldObject, getThisFieldRef, getValueArray, getValueIterator, gt, hasCurrent, isA, isArray, isBinary, isBoolean, isDefault, isNull, isNumberConvertible, isObject, isResource, isset, isset, issetField, issetThisField, isUnicode, key, leq, lshift, lt, mod, mul, mul, neg, next, nextIndex, pos, print, print, printDepth, printJavaString, printR, printRImpl, put, put, putArray, putField, putField, putObject, putRef, putThisField, remove, rshift, serialize, set, sub_rev, sub, toArgValue, toArgValueReadOnly, toArray, toArrayValue, toBigDecimal, toBigInteger, toBinaryValue, toBinaryValue, toChar, toDoubleValue, toException, toInt, toInternString, toJavaBoolean, toJavaByte, toJavaCalendar, toJavaCharacter, toJavaCollection, toJavaDate, toJavaDouble, toJavaFloat, toJavaInteger, toJavaList, toJavaLong, toJavaMap, toJavaObject, toJavaObjectNotNull, toJavaShort, toJavaString, toJavaURL, toLong, toLongValue, toObject, toRef, toRefValue, toRefVar, toString, toStringBuilder, toUnicodeValue, toUnicodeValue, toValue, toVar, unsetField, unsetThisField, varDump
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.CharSequence
toString
 

Field Detail

EMPTY

public static final StringValue EMPTY

IS_STRING

protected static final int IS_STRING
See Also:
Constant Field Values

IS_LONG

protected static final int IS_LONG
See Also:
Constant Field Values

IS_DOUBLE

protected static final int IS_DOUBLE
See Also:
Constant Field Values
Constructor Detail

StringValue

public StringValue()
Method Detail

create

public static Value create(java.lang.String value)
Creates the string.


create

public static StringValue create(char value)
Creates the string.


create

public static Value create(java.lang.Object value)
Creates the string.


create

public StringValue create(Env env,
                          StringValue unicodeStr,
                          java.lang.String charset)

createStringBuilder

public abstract StringValue createStringBuilder()
Creates a string builder of the same type.


createStringBuilder

public abstract StringValue createStringBuilder(int length)
Creates a string builder of the same type.


getEmptyString

public abstract StringValue getEmptyString()

getType

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

Overrides:
getType in class Value

getValueType

public ValueType getValueType()
Returns the ValueType.

Overrides:
getValueType in class Value

isLongConvertible

public boolean isLongConvertible()
Returns true for a long

Overrides:
isLongConvertible in class Value

isDoubleConvertible

public boolean isDoubleConvertible()
Returns true for a double

Overrides:
isDoubleConvertible in class Value

isNumber

public boolean isNumber()
Returns true for a number


isNumeric

public boolean isNumeric()
Returns true for is_numeric

Overrides:
isNumeric in class Value

isScalar

public boolean isScalar()
Returns true for a scalar


isString

public boolean isString()
Returns true for StringValue

Overrides:
isString in class Value

isPHP5String

public boolean isPHP5String()

isEmpty

public boolean isEmpty()
Returns true if the value is empty

Overrides:
isEmpty in class Value

cmp

public int cmp(Value rValue)
Returns true for equality

Overrides:
cmp in class Value

eq

public boolean eq(Value rValue)
Returns true for equality

Overrides:
eq in class Value

cmpString

public int cmpString(StringValue rValue)
Compare two strings


toStringValue

public StringValue toStringValue()
Converts to a string value.

Overrides:
toStringValue in class Value

toLong

public static long toLong(java.lang.String string)
Converts to a long.


toDouble

public double toDouble()
Converts to a double.

Overrides:
toDouble in class Value

toDouble

public static double toDouble(java.lang.String s)
Converts to a double.


toBoolean

public boolean toBoolean()
Converts to a boolean.

Overrides:
toBoolean in class Value

toKey

public Value toKey()
Converts to a key.

Overrides:
toKey in class Value

toAutoObject

public final Value toAutoObject(Env env)
Converts to an object.

Overrides:
toAutoObject in class Value

toJavaObject

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

Overrides:
toJavaObject in class Value

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 Value

toAutoArray

public Value toAutoArray()
Converts to an array if null.

Overrides:
toAutoArray in class Value

get

public Value get(Value key)
Returns the character at an index

Overrides:
get in class Value

getArg

public Value getArg(Value key)
Returns the character at an index

Overrides:
getArg in class Value

getRef

public Value getRef(Value key)
Returns the character at an index

Overrides:
getRef in class Value

charValueAt

public Value charValueAt(long index)
Returns the character at an index

Overrides:
charValueAt in class Value

setCharValueAt

public Value setCharValueAt(long index,
                            java.lang.String value)
sets the character at an index

Overrides:
setCharValueAt in class Value

preincr

public Value preincr(int incr)
Pre-increment the following value.

Overrides:
preincr in class Value

postincr

public Value postincr(int incr)
Post-increment the following value.

Overrides:
postincr in class Value

add

public Value add(long rValue)
Adds to the following value.

Overrides:
add in class Value

sub

public Value sub(long rValue)
Adds to the following value.

Overrides:
sub in class Value

bitAnd

public Value bitAnd(Value rValue)
Overrides:
bitAnd in class Value

bitOr

public Value bitOr(Value rValue)
Overrides:
bitOr in class Value

bitXor

public Value bitXor(Value rValue)
Overrides:
bitXor in class Value

serialize

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

Overrides:
serialize in class Value

append

public StringValue append(java.lang.String s)
Append a Java string to the value.


append

public StringValue append(java.lang.String s,
                          int start,
                          int end)
Append a Java string to the value.


append

public StringValue append(char[] buf,
                          int offset,
                          int length)
Append a Java buffer to the value.


append

public StringValue append(char[] buf)
Append a Java double to the value.


append

public StringValue append(java.lang.CharSequence buf,
                          int head,
                          int tail)
Append a Java buffer to the value.


append

public StringValue append(UnicodeBuilderValue sb,
                          int head,
                          int tail)
Append a Java buffer to the value.


append

public StringValue append(Env env,
                          StringValue unicodeStr,
                          java.lang.String charset)

append

public StringValue append(char v)
Append a Java char to the value.


append

public StringValue append(boolean v)
Append a Java boolean to the value.


append

public StringValue append(long v)
Append a Java long to the value.


append

public StringValue append(double v)
Append a Java double to the value.


append

public StringValue append(java.lang.Object v)
Append a Java value to the value.


append

public StringValue append(Value v)
Append a Java value to the value.


ensureAppendCapacity

public void ensureAppendCapacity(int size)
Ensure enough append capacity.


append

public StringValue append(byte[] buf,
                          int offset,
                          int length)
Append a byte buffer to the value.


append

public StringValue append(byte[] buf)
Append a byte buffer to the value.


appendTo

public StringValue appendTo(UnicodeBuilderValue sb)
Append to a string builder.

Overrides:
appendTo in class Value

appendUnicode

public StringValue appendUnicode(boolean v)
Append a Java boolean to the value.


appendUnicode

public StringValue appendUnicode(long v)
Append a Java long to the value.


appendUnicode

public StringValue appendUnicode(double v)
Append a Java double to the value.


appendUnicode

public StringValue appendUnicode(java.lang.Object v)
Append a Java value to the value.


appendUnicode

public StringValue appendUnicode(char v)
Append a Java char, possibly converting to a unicode string


appendUnicode

public StringValue appendUnicode(char[] buffer,
                                 int offset,
                                 int length)
Append a Java char buffer, possibly converting to a unicode string


appendUnicode

public StringValue appendUnicode(char[] buffer)
Append a Java char buffer, possibly converting to a unicode string


appendUnicode

public StringValue appendUnicode(java.lang.String value)
Append a Java char buffer, possibly converting to a unicode string


appendUnicode

public StringValue appendUnicode(java.lang.String value,
                                 int offset,
                                 int length)
Append a Java char buffer, possibly converting to a unicode string


appendUnicode

public StringValue appendUnicode(Value value)
Append a Java char buffer, possibly converting to a unicode string


appendUnicode

public StringValue appendUnicode(Value v1,
                                 Value v2)
Append a Java char buffer, possibly converting to a unicode string


appendByte

public StringValue appendByte(int v)
Append a Java byte to the value without conversions.


appendBytes

public StringValue appendBytes(java.lang.String s)
Append a Java String to the value without conversions.


appendBytes

public StringValue appendBytes(char[] buf,
                               int offset,
                               int length)
Append a Java char[] to the value without conversions.


append

public StringValue append(java.io.Reader reader)
                   throws java.io.IOException
Append from a read stream

Throws:
java.io.IOException

append

public StringValue append(java.io.Reader reader,
                          long length)
                   throws java.io.IOException
Append from a read stream

Throws:
java.io.IOException

appendRead

public int appendRead(java.io.InputStream is,
                      long length)
Append from an input stream, using InputStream.read semantics, i.e. just call is.read once even if more data is available.


appendReadAll

public int appendReadAll(java.io.InputStream is,
                         long length)
Append from an input stream, reading from the input stream until end of file or the length is reached.


appendRead

public int appendRead(BinaryInput is,
                      long length)
Append from an input stream, using InputStream semantics, i.e call is.read() only once.


appendReadAll

public int appendReadAll(BinaryInput is,
                         long length)
Append from an input stream, reading all available data from the stream.


varExport

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

Overrides:
varExport in class Value

intern

public StringValue intern(