本文整理汇总了Java中javax.xml.bind.util.JAXBResult.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java JAXBResult.getResult方法的具体用法?Java JAXBResult.getResult怎么用?Java JAXBResult.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.util.JAXBResult
的用法示例。
在下文中一共展示了JAXBResult.getResult方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readPayloadAsJAXB
import javax.xml.bind.util.JAXBResult; //导入方法依赖的package包/类
@Override
public <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException {
JAXBResult out = new JAXBResult(unmarshaller);
// since the bridge only produces fragments, we need to fire start/end document.
try {
out.getHandler().startDocument();
if (rawContext != null) {
Marshaller m = rawContext.createMarshaller();
m.setProperty("jaxb.fragment", Boolean.TRUE);
m.marshal(jaxbObject,out);
} else
bridge.marshal(jaxbObject,out);
out.getHandler().endDocument();
} catch (SAXException e) {
throw new JAXBException(e);
}
return (T)out.getResult();
}
示例2: getJAXBObject
import javax.xml.bind.util.JAXBResult; //导入方法依赖的package包/类
private T getJAXBObject(MCRContent source, XMLReader reader, TransformerHandler transformerHandler)
throws JAXBException, IOException, SAXException {
checkContext();
JAXBResult result = new JAXBResult(context);
transformerHandler.setResult(result);
// Parse the source XML, and send the parse events to the
// TransformerHandler.
reader.parse(source.getInputSource());
Object parsedResult = result.getResult();
if (parsedResult instanceof JAXBElement<?>) {
@SuppressWarnings("unchecked")
JAXBElement<T> jaxbElement = (JAXBElement<T>) parsedResult;
return jaxbElement.getValue();
}
@SuppressWarnings("unchecked")
T jaxbResult = (T) result.getResult();
return jaxbResult;
}
示例3: write
import javax.xml.bind.util.JAXBResult; //导入方法依赖的package包/类
@Deprecated
public void write(DigitalObjectHandler handler, ModsDefinition mods, String model, long timestamp, String message) throws DigitalObjectException {
try {
JAXBSource jaxbSource = new JAXBSource(ModsUtils.defaultMarshaller(false),
new cz.cas.lib.proarc.mods.ObjectFactory().createMods(mods));
// DO NOT include schemaLocation. Fedora validator does not accept it.
Transformer t = DcUtils.modsTransformer(model);
EditorResult result = editor.createResult();
JAXBResult jaxbResult = new JAXBResult(DcUtils.defaultUnmarshaller());
t.transform(jaxbSource, jaxbResult);
JAXBElement<OaiDcType> elm = (JAXBElement<OaiDcType>) jaxbResult.getResult();
OaiDcType dc = elm.getValue();
addDigitalObjectMetadata(handler, dc);
DcUtils.marshal(result, dc, false);
editor.write(result, timestamp, message);
} catch (TransformerException | JAXBException ex) {
throw new DigitalObjectException(object.getPid(), ex);
}
}
示例4: readAsJAXB
import javax.xml.bind.util.JAXBResult; //导入方法依赖的package包/类
public <T> T readAsJAXB(Unmarshaller unmarshaller) throws JAXBException {
try {
JAXBResult r = new JAXBResult(unmarshaller);
// bridge marshals a fragment, so we need to add start/endDocument by ourselves
r.getHandler().startDocument();
bridge.marshal(jaxbObject,r);
r.getHandler().endDocument();
return (T)r.getResult();
} catch (SAXException e) {
throw new JAXBException(e);
}
}
示例5: transformToObject
import javax.xml.bind.util.JAXBResult; //导入方法依赖的package包/类
public static <T> T transformToObject(File file, final String xslID, Class<T> targetClass, Class<?>... nestedClasses) throws TransformerException, SAXException, IOException, ParserConfigurationException, JAXBException{
JAXBContext jc = createJAXBContext(merge(targetClass, nestedClasses));
JAXBResult result = new JAXBResult(jc);
XslTransformer.transform(file, xslID, result);
// obtain the unmarshalled content tree
@SuppressWarnings("unchecked")
T object = (T) result.getResult();
return object;
}
示例6: readPayloadAsJAXB
import javax.xml.bind.util.JAXBResult; //导入方法依赖的package包/类
public <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException {
JAXBResult out = new JAXBResult(unmarshaller);
// since the bridge only produces fragments, we need to fire start/end document.
try {
out.getHandler().startDocument();
bridge.marshal(jaxbObject,out);
out.getHandler().endDocument();
} catch (SAXException e) {
throw new JAXBException(e);
}
return (T)out.getResult();
}