use of org.apache.axiom.om.OMException in project webservices-axiom by apache.
the class StAXPullReader method processText.
private void processText(int textType) throws StreamException {
if (textType == XMLStreamConstants.CHARACTERS && dataHandlerReader != null && dataHandlerReader.isBinary()) {
TextContent data;
if (dataHandlerReader.isDeferred()) {
data = new TextContent(dataHandlerReader.getContentID(), dataHandlerReader.getDataHandlerProvider(), dataHandlerReader.isOptimized());
} else {
try {
data = new TextContent(dataHandlerReader.getContentID(), dataHandlerReader.getDataHandler(), dataHandlerReader.isOptimized());
} catch (XMLStreamException ex) {
throw new OMException(ex);
}
}
handler.processCharacterData(data, false);
} else {
// Some parsers (like Woodstox) parse text nodes lazily and may throw a
// RuntimeException in getText()
String text;
try {
text = parser.getText();
} catch (RuntimeException ex) {
parserException = ex;
throw ex;
}
switch(textType) {
case XMLStreamConstants.CHARACTERS:
handler.processCharacterData(text, false);
break;
case XMLStreamConstants.SPACE:
handler.processCharacterData(text, true);
break;
case XMLStreamConstants.CDATA:
handler.startCDATASection();
handler.processCharacterData(text, false);
handler.endCDATASection();
break;
default:
throw new IllegalStateException();
}
}
}
use of org.apache.axiom.om.OMException in project webservices-axiom by apache.
the class DetachableReader method detach.
@Override
public void detach() {
MemoryBlob blob = Blobs.createMemoryBlob();
Writer out = new OutputStreamWriter(blob.getOutputStream(), UTF8);
char[] buffer = new char[2048];
int c;
try {
while ((c = target.read(buffer)) != -1) {
out.write(buffer, 0, c);
}
out.close();
} catch (IOException ex) {
throw new OMException(ex);
}
target = new InputStreamReader(blob.readOnce(), UTF8);
}
use of org.apache.axiom.om.OMException in project webservices-axiom by apache.
the class TestDeclareDefaultNamespaceConflict2 method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("urn:ns1", "");
OMElement element = factory.createOMElement("test", ns);
try {
element.declareDefaultNamespace("urn:ns2");
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMException in project webservices-axiom by apache.
the class TestInsertSiblingBeforeOnSelf method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement parent = factory.createOMElement("test", null);
OMText text = factory.createOMText("test");
parent.addChild(text);
try {
text.insertSiblingBefore(text);
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMException in project webservices-axiom by apache.
the class TestInsertSiblingAfterOnSelf method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement parent = factory.createOMElement("test", null);
OMText text = factory.createOMText("test");
parent.addChild(text);
try {
text.insertSiblingAfter(text);
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
Aggregations