com.crystaldecisions.reports.common.value
Class StringValue

java.lang.Object
  extended by CrystalValue
      extended by com.crystaldecisions.reports.common.value.FormulaValue
          extended by com.crystaldecisions.reports.common.value.StringValue

public abstract class StringValue
extends FormulaValue

Provides methods for converting native Java types to a format understood by the Crystal Reports Formula Language. All Java user defined functions must return a FormulaValue object.


Field Summary
static StringValue empty
           A StringValue object that represents an empty string.
 
Constructor Summary
StringValue()
           
 
Method Summary
 FormulaValue coerceToString()
           Internal use only.
 int compareTo(java.lang.Object obj, java.util.Comparator stringComparator)
           Internal use only.
 boolean equals(java.lang.Object obj, boolean caseInsensitive)
           Returns true if obj has the same class, comparator and string as this StringValue object.
static StringValue fromString(java.lang.String string)
           Returns a StringValue that represents the given String.
static java.lang.String getAsString(CrystalValue value, java.lang.String defaultValue)
           
 char getCharAt(int index)
           Gets the character at the specified index.
 int getLength()
           Gets the length of this StringValue object.
abstract  java.lang.String getString()
           Gets a String from this StringValue object.
 java.lang.String getSubstring(int beginIndex, int endIndex)
           Gets a substring from this StringValue object.
 ValueType getValueType()
           Gets the ValueType of this StringValue object.
 int hashCode(boolean caseInsensitive)
           Returns a hash code for this StringValue object.
static StringValue Load(ExtendedDataInput in)
           
static StringValue LoadFromArchive(IInputArchive ar)
           
 java.lang.String toString()
           Returns a String representation of this StringValue object.
 StringValue truncate()
          this code uses the java.lang.String.trim() code, modified to only trim the trailing whitespace
 
Methods inherited from class com.crystaldecisions.reports.common.value.FormulaValue
coerce, coerceToArray, coerceToArray, coerceToBoolean, coerceToBoolean, coerceToCurrency, coerceToCurrency, coerceToDate, coerceToDate, coerceToDateTime, coerceToDateTime, coerceToNumber, coerceToNumber, coerceToRange, coerceToRange, coerceToRangeArray, coerceToRangeArray, coerceToString, coerceToTime, coerceToTime, getFormulaValueType, Load, LoadFromArchive, makeZeroValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

empty

public static final StringValue empty

A StringValue object that represents an empty string.

Constructor Detail

StringValue

public StringValue()
Method Detail

fromString

public static StringValue fromString(java.lang.String string)

Returns a StringValue that represents the given String.

Parameters:
string - the String to represent
Returns:
a StringValue object or null if the String provided is null.

getString

public abstract java.lang.String getString()

Gets a String from this StringValue object.

Returns:
a String

getLength

public int getLength()

Gets the length of this StringValue object.


Note: The length is equal to the number of 16-bit Unicode characters in the StringValue object.

Returns:
the length of this StringValue object

getCharAt

public char getCharAt(int index)

Gets the character at the specified index.

Parameters:
index - the integer used to specify the String index
Returns:
the character at the specified index
Throws:
java.lang.StringIndexOutOfBoundsException - if the index is outside of the StringValue bounds.

getSubstring

public java.lang.String getSubstring(int beginIndex,
                                     int endIndex)

Gets a substring from this StringValue object. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Therefore, the length of the substring is endIndex-beginIndex.

Parameters:
beginIndex - the index of the first character in the substring
endIndex - the index following the last character in the substring
Returns:
the specified substring
Throws:
java.lang.IndexOutOfBoundsException - - if beginIndex is negative or larger than endIndex, or endIndex is larger than the length of this StringValue object.

getValueType

public final ValueType getValueType()

Gets the ValueType of this StringValue object.

Returns:
ValueType.string

coerceToString

public FormulaValue coerceToString()

Internal use only.

Overrides:
coerceToString in class FormulaValue

equals

public boolean equals(java.lang.Object obj,
                      boolean caseInsensitive)

Returns true if obj has the same class, comparator and string as this StringValue object.

Parameters:
obj - the Object to compare this StringValue object to
Returns:
true if obj has the same class, comparator and string as this StringValue object, otherwise false

compareTo

public int compareTo(java.lang.Object obj,
                     java.util.Comparator stringComparator)

Internal use only.


hashCode

public int hashCode(boolean caseInsensitive)

Returns a hash code for this StringValue object.

Returns:
a hash code for this StringValue object as in int

toString

public java.lang.String toString()

Returns a String representation of this StringValue object. The String is of the form: "s(the string)".

Returns:
a String representation of this StringValue object

Load

public static StringValue Load(ExtendedDataInput in)
                        throws java.io.IOException
Throws:
java.io.IOException

LoadFromArchive

public static StringValue LoadFromArchive(IInputArchive ar)
                                   throws ArchiveException
Throws:
ArchiveException

getAsString

public static java.lang.String getAsString(CrystalValue value,
                                           java.lang.String defaultValue)

truncate

public StringValue truncate()
this code uses the java.lang.String.trim() code, modified to only trim the trailing whitespace

Returns:
a copy of the string with the trailing whitespace removed