in axiom-api/src/main/java/org/apache/axiom/util/stax/TextFromElementReader.java [75:124]
public int read(char[] cbuf, int off, int len) throws IOException {
if (endOfStream) {
return -1;
}
int read = 0;
try {
while (true) {
if (sourceStart == -1) {
eventLoop: while (true) {
int type = stream.next();
switch (type) {
case XMLStreamReader.CHARACTERS:
case XMLStreamReader.CDATA:
if (skipDepth == 0) {
sourceStart = 0;
break eventLoop;
}
break;
case XMLStreamReader.START_ELEMENT:
if (allowNonTextChildren) {
skipDepth++;
} else {
throw new IOException("Unexpected START_ELEMENT event");
}
break;
case XMLStreamReader.END_ELEMENT:
if (skipDepth == 0) {
endOfStream = true;
return read == 0 ? -1 : read;
} else {
skipDepth--;
}
}
}
}
int c = stream.getTextCharacters(sourceStart, cbuf, off, len);
sourceStart += c;
off += c;
len -= c;
read += c;
if (len > 0) {
sourceStart = -1;
} else {
return read;
}
}
} catch (XMLStreamException ex) {
throw new XMLStreamIOException(ex);
}
}