Gets the the text associated with a CHARACTERS, SPACE or CDATA event.
Text starting a "sourceStart" is copied into "target" starting at "targetStart".
Up to "length" characters are copied. The number of characters actually copied is returned.
The "sourceStart" argument must be greater or equal to 0 and less than or equal to
the number of characters associated with the event. Usually, one requests text starting at a "sourceStart" of 0.
If the number of characters actually copied is less than the "length", then there is no more text.
Otherwise, subsequent calls need to be made until all text has been retrieved. For example:
int length = 1024;
char[] myBuffer = new char[ length ];
for ( int sourceStart = 0 ; ; sourceStart += length )
{
int nCopied = stream.getTextCharacters( sourceStart, myBuffer, 0, length );
if (nCopied < length)
break;
}
XMLStreamException may be thrown if there are any XML errors in the underlying source.
The "targetStart" argument must be greater than or equal to 0 and less than the length of "target",
Length must be greater than 0 and "targetStart + length" must be less than or equal to length of "target".
Returns:
the number of characters actually copied
Parameters:
-
sourceStart - the index of the first character in the source array to copy
-
target - the destination array
-
targetStart - the start offset in the target array
-
length - the number of characters to copy
Throws:
-
XMLStreamException - if the underlying XML source is not well-formed
-
IndexOutOfBoundsException - if targetStart < 0 or > than the length of target
-
IndexOutOfBoundsException - if length < 0 or targetStart + length > length of target
-
UnsupportedOperationException - if this method is not supported
-
NullPointerException - is if target is null