org.apache.xpath.objects

Class XStringForChars

Implemented Interfaces:
Cloneable, Serializable, ExpressionNode, SourceLocator, XMLString, XPathVisitable

public class XStringForChars
extends XString

This class will wrap a FastStringBuffer and allow for
See Also:
Serialized Form

Field Summary

Fields inherited from class org.apache.xpath.objects.XString

EMPTYSTRING

Fields inherited from class org.apache.xpath.objects.XObject

CLASS_BOOLEAN, CLASS_NODESET, CLASS_NULL, CLASS_NUMBER, CLASS_RTREEFRAG, CLASS_STRING, CLASS_UNKNOWN, CLASS_UNRESOLVEDVARIABLE

Constructor Summary

XStringForChars(char[] val, int start, int length)
Construct a XNodeSet object.

Method Summary

void
appendToFsb(FastStringBuffer fsb)
Cast result object to a string.
char
charAt(int index)
Returns the character at the specified index.
void
dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
Directly call the comment method on the passed LexicalHandler for the string-value.
void
dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
Directly call the characters method on the passed ContentHandler for the string-value.
FastStringBuffer
fsb()
Cast result object to a string.
void
getChars(int srcBegin, int srcEnd, dst[] , int dstBegin)
Copies characters from this string into the destination character array.
boolean
hasString()
Tell if this object contains a java String object.
int
length()
Returns the length of this string.
Object
object()
Since this object is incomplete without the length and the offset, we have to convert to a string when this function is called.
String
str()
Cast result object to a string.

Methods inherited from class org.apache.xpath.objects.XString

bool, callVisitors, charAt, compareTo, compareToIgnoreCase, concat, dispatchAsComment, dispatchCharactersEvents, endsWith, equals, equals, equals, equalsIgnoreCase, fixWhiteSpace, getChars, getType, getTypeString, hasString, hashCode, indexOf, indexOf, indexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, length, num, rtf, startsWith, startsWith, startsWith, startsWith, str, substring, substring, toDouble, toLowerCase, toLowerCase, toUpperCase, toUpperCase, trim, xstr

Methods inherited from class org.apache.xpath.objects.XObject

allowDetachToRelease, appendToFsb, bool, boolWithSideEffects, callVisitors, castToType, create, create, deepEquals, destruct, detach, dispatchCharactersEvents, equals, execute, fixupVariables, getFresh, getType, getTypeString, greaterThan, greaterThanOrEqual, iter, lessThan, lessThanOrEqual, mutableNodeset, nodelist, nodeset, notEquals, num, numWithSideEffects, object, reset, rtf, rtf, rtree, rtree, str, toString, xstr

Methods inherited from class org.apache.xpath.Expression

asIterator, asIteratorRaw, asNode, assertion, bool, canTraverseOutsideSubtree, deepEquals, error, execute, execute, execute, execute, executeCharsToContentHandler, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, fixupVariables, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isNodesetExpr, isStableNumber, num, warn, xstr

Constructor Details

XStringForChars

public XStringForChars(char[] val,
                       int start,
                       int length)
Construct a XNodeSet object.
Parameters:
val - FastStringBuffer object this will wrap, must be non-null.
start - The start position in the array.
length - The number of characters to read from the array.

Method Details

appendToFsb

public void appendToFsb(FastStringBuffer fsb)
Cast result object to a string.
Overrides:
appendToFsb in interface XObject

charAt

public char charAt(int index)
Returns the character at the specified index. An index ranges from 0 to length() - 1. The first character of the sequence is at index 0, the next at index 1, and so on, as for array indexing.
Specified by:
charAt in interface XMLString
Overrides:
charAt in interface XString
Parameters:
index - the index of the character.
Returns:
the character at the specified index of this string. The first character is at index 0.

dispatchAsComment

public void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
            throws org.xml.sax.SAXException
Directly call the comment method on the passed LexicalHandler for the string-value.
Specified by:
dispatchAsComment in interface XMLString
Overrides:
dispatchAsComment in interface XString
Parameters:
lh - A non-null reference to a LexicalHandler.

dispatchCharactersEvents

public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
            throws org.xml.sax.SAXException
Directly call the characters method on the passed ContentHandler for the string-value. Multiple calls to the ContentHandler's characters methods may well occur for a single call to this method.
Specified by:
dispatchCharactersEvents in interface XMLString
Overrides:
dispatchCharactersEvents in interface XString
Parameters:
ch - A non-null reference to a ContentHandler.

fsb

public FastStringBuffer fsb()
Cast result object to a string.
Returns:
The string this wraps or the empty string if null

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     dst[] ,
                     int dstBegin)
Copies characters from this string into the destination character array.
Specified by:
getChars in interface XMLString
Overrides:
getChars in interface XString
Parameters:
srcBegin - index of the first character in the string to copy.
srcEnd - index after the last character in the string to copy.
dstBegin - the start offset in the destination array.

hasString

public boolean hasString()
Tell if this object contains a java String object.
Specified by:
hasString in interface XMLString
Overrides:
hasString in interface XString
Returns:
true if this XMLString can return a string without creating one.

length

public int length()
Returns the length of this string.
Specified by:
length in interface XMLString
Overrides:
length in interface XString
Returns:
the length of the sequence of characters represented by this object.

object

public Object object()
Since this object is incomplete without the length and the offset, we have to convert to a string when this function is called.
Overrides:
object in interface XObject
Returns:
The java String representation of this object.

str

public String str()
Cast result object to a string.
Overrides:
str in interface XString
Returns:
The string this wraps or the empty string if null

Copyright B) 2004 Apache XML Project. All Rights Reserved.