feat(serialize-xml): Add NativeXmlReader.copyTo
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
400a2cf654
commit
d99c129a06
@ -822,4 +822,33 @@ public class NativeXmlReader implements Closeable {
|
|||||||
stackSize = 1;
|
stackSize = 1;
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies the current element to the writer.
|
||||||
|
*
|
||||||
|
* @param writer the writer to copy to
|
||||||
|
* @throws IOException if an error occurs
|
||||||
|
*/
|
||||||
|
public void copyTo(NativeXmlWriter writer) throws IOException {
|
||||||
|
switch (peek()) {
|
||||||
|
case BEGIN_TAG -> {
|
||||||
|
beginTag();
|
||||||
|
writer.beginTag(pathNames[stackSize - 1]);
|
||||||
|
while (hasNext()) {
|
||||||
|
copyTo(writer);
|
||||||
|
}
|
||||||
|
endTag();
|
||||||
|
writer.endTag();
|
||||||
|
}
|
||||||
|
case END_TAG -> throw new IllegalStateException("Cannot copy standalone END_TAG");
|
||||||
|
case TEXT -> writer.text(nextText());
|
||||||
|
case CDATA -> writer.cdata(nextCData());
|
||||||
|
case ATTRIBUTE_NAME -> {
|
||||||
|
String name = nextAttributeName();
|
||||||
|
writer.attribute(name, nextAttributeValue());
|
||||||
|
}
|
||||||
|
case ATTRIBUTE_VALUE -> writer.attributeValue(nextAttributeValue());
|
||||||
|
case EOF -> throw new IllegalStateException("Cannot copy END_DOCUMENT");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user