use of commonj.sdo.DataObject in project metro-jax-ws by eclipse-ee4j.
the class SDOBond method deserialize.
private T deserialize(Source src, jakarta.xml.bind.attachment.AttachmentUnmarshaller au) {
try {
if (!commonj.sdo.DataObject.class.isAssignableFrom(javaType) && !javaType.isInterface()) {
return (T) deserializePrimitives(src);
}
HelperContext context = parent.getHelperContext();
SDOAttachmentUnmarshaller unmarshaller = null;
if (au != null) {
unmarshaller = new SDOAttachmentUnmarshaller(au);
}
DataFactory dataFactory = context.getDataFactory();
DataObject loadOptions = dataFactory.create(SDOConstants.ORACLE_SDO_URL, SDOConstants.XMLHELPER_LOAD_OPTIONS);
// bug 8680450
loadOptions.set(SDOConstants.TYPE_LOAD_OPTION, theType);
if (unmarshaller != null) {
loadOptions.set(SDOConstants.ATTACHMENT_UNMARSHALLER_OPTION, unmarshaller);
}
XMLDocument xdoc = context.getXMLHelper().load(src, null, loadOptions);
DataObject obj = xdoc.getRootObject();
Object o = SDOUtils.unwrapPrimitives(obj);
// ClassCast possible without check
return (T) o;
} catch (Exception e) {
throw new SDODatabindingException(e);
}
}
use of commonj.sdo.DataObject in project metro-jax-ws by eclipse-ee4j.
the class SDOBond method marshal.
@Override
public void marshal(T object, XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException {
/* Didn't work due to bug 8539542
StAXResult result = new StAXResult(writer);
sdoXMLHelper.save(xmlDoc, result, null);
*/
try {
output.flush();
} catch (Exception e) {
e.printStackTrace();
}
SAX2StaxContentHandler handler = new SAX2StaxContentHandler(output);
if (object instanceof DataObject) {
serializeDataObject((DataObject) object, new SAXResult(handler), am);
return;
}
try {
String value = serializePrimitive(object, javaType);
String prefix = output.getPrefix(xmlTag.getNamespaceURI());
// TODO, this is a hack, seems to be wrong. why should namespace returned is ""?
if (xmlTag.getNamespaceURI().equals("")) {
output.writeStartElement("", xmlTag.getLocalPart(), xmlTag.getNamespaceURI());
// } else if (prefix == null) {
// output.writeStartElement(xmlTag.getNamespaceURI(), xmlTag.getLocalPart());
} else {
output.writeStartElement(prefix, xmlTag.getLocalPart(), xmlTag.getNamespaceURI());
output.writeNamespace(prefix, xmlTag.getNamespaceURI());
}
output.writeCharacters(value);
output.writeEndElement();
} catch (XMLStreamException e) {
throw new SDODatabindingException(e);
}
}
use of commonj.sdo.DataObject in project metro-jax-ws by eclipse-ee4j.
the class SDOBond method marshal.
@Override
public void marshal(T object, OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException {
if (object instanceof DataObject) {
serializeDataObject((DataObject) object, new StreamResult(output), am);
return;
}
try {
String value = serializePrimitive(object, javaType);
String prefix = nsContext.getPrefix(xmlTag.getNamespaceURI());
StringBuilder sb = new StringBuilder();
if ("".equals(prefix)) {
sb.append("<").append(xmlTag.getLocalPart()).append(">");
sb.append(value);
sb.append("</").append(xmlTag.getLocalPart()).append(">");
} else if (prefix != null) {
sb.append("<").append(prefix).append(":").append(xmlTag.getLocalPart()).append(">");
sb.append(value);
sb.append("</").append(prefix).append(":").append(xmlTag.getLocalPart()).append(">");
} else {
// Unbound namespace!
sb.append("<ns1:").append(xmlTag.getLocalPart()).append(" xmlns:ns1=\"").append(xmlTag.getNamespaceURI()).append("\"").append(">");
sb.append(value);
sb.append("</ns1:").append(xmlTag.getLocalPart()).append(">");
}
} catch (Exception e) {
throw new SDODatabindingException(e);
}
}
use of commonj.sdo.DataObject in project metro-jax-ws by eclipse-ee4j.
the class SDOBond method marshal.
@Override
public void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
Result res = new SAXResult(contentHandler);
if (object instanceof DataObject) {
serializeDataObject((DataObject) object, res, null);
return;
}
String value = serializePrimitive(object, javaType);
serializeToResult(value, res);
}
use of commonj.sdo.DataObject in project metro-jax-ws by eclipse-ee4j.
the class SDOBond method marshal.
@Override
public void marshal(T object, Node output) throws JAXBException {
Result res = new DOMResult(output);
if (object instanceof DataObject) {
serializeDataObject((DataObject) object, res, null);
return;
}
String value = serializePrimitive(object, javaType);
serializeToResult(value, res);
}
Aggregations