FileDocCategorySizeDatePackage
XStringForChars.javaAPI DocJava SE 6 API6646Tue Jun 10 00:23:16 BST 2008com.sun.org.apache.xpath.internal.objects

XStringForChars

public class XStringForChars extends XString
This class will wrap a FastStringBuffer and allow for

Fields Summary
static final long
serialVersionUID
int
m_start
The start position in the fsb.
int
m_length
The length of the string.
protected String
m_strCache
Constructors Summary
public XStringForChars(char[] val, int start, int length)
Construct a XNodeSet object.

param
val FastStringBuffer object this will wrap, must be non-null.
param
start The start position in the array.
param
length The number of characters to read from the array.

  
                                      
        
  
    super(val);
    m_start = start;
    m_length = length;
    if(null == val)
      throw new IllegalArgumentException(
                          XSLMessages.createXPATHMessage(XPATHErrorResources.ER_FASTSTRINGBUFFER_CANNOT_BE_NULL, null)); //"The FastStringBuffer argument can not be null!!");
  
private XStringForChars(String val)
Construct a XNodeSet object.

param
val String object this will wrap.

    super(val);
    throw new IllegalArgumentException(
                      XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XSTRINGFORCHARS_CANNOT_TAKE_STRING, null)); //"XStringForChars can not take a string for an argument!");
  
Methods Summary
public voidappendToFsb(com.sun.org.apache.xml.internal.utils.FastStringBuffer fsb)
Cast result object to a string.

return
The string this wraps or the empty string if null

    fsb.append((char[])m_obj, m_start, m_length);
  
public charcharAt(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.

param
index the index of the character.
return
the character at the specified index of this string. The first character is at index 0.
exception
IndexOutOfBoundsException if the index argument is negative or not less than the length of this string.

    return ((char[])m_obj)[index+m_start];
  
public voiddispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
Directly call the comment method on the passed LexicalHandler for the string-value.

param
lh A non-null reference to a LexicalHandler.
throws
org.xml.sax.SAXException

    lh.comment((char[])m_obj, m_start, m_length);
  
public voiddispatchCharactersEvents(org.xml.sax.ContentHandler ch)
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.

param
ch A non-null reference to a ContentHandler.
throws
org.xml.sax.SAXException

    ch.characters((char[])m_obj, m_start, m_length);
  
public com.sun.org.apache.xml.internal.utils.FastStringBufferfsb()
Cast result object to a string.

return
The string this wraps or the empty string if null

    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_FSB_NOT_SUPPORTED_XSTRINGFORCHARS, null)); //"fsb() not supported for XStringForChars!");
  
public voidgetChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
Copies characters from this string into the destination character array.

param
srcBegin index of the first character in the string to copy.
param
srcEnd index after the last character in the string to copy.
param
dst the destination array.
param
dstBegin the start offset in the destination array.
exception
IndexOutOfBoundsException If any of the following is true:
  • srcBegin is negative.
  • srcBegin is greater than srcEnd
  • srcEnd is greater than the length of this string
  • dstBegin is negative
  • dstBegin+(srcEnd-srcBegin) is larger than dst.length
exception
NullPointerException if dst is null

    System.arraycopy((char[])m_obj, m_start+srcBegin, dst, dstBegin, srcEnd);
  
public booleanhasString()
Tell if this object contains a java String object.

return
true if this XMLString can return a string without creating one.

    return (null != m_strCache);
  
public intlength()
Returns the length of this string.

return
the length of the sequence of characters represented by this object.

    return m_length;
  
public java.lang.Objectobject()
Since this object is incomplete without the length and the offset, we have to convert to a string when this function is called.

return
The java String representation of this object.

    return str();
  
public java.lang.Stringstr()
Cast result object to a string.

return
The string this wraps or the empty string if null

    if(null == m_strCache)
      m_strCache = new String((char[])m_obj, m_start, m_length);
    
    return m_strCache;