本文整理汇总了Java中javax.xml.bind.annotation.adapters.XmlAdapter.unmarshal方法的典型用法代码示例。如果您正苦于以下问题:Java XmlAdapter.unmarshal方法的具体用法?Java XmlAdapter.unmarshal怎么用?Java XmlAdapter.unmarshal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.annotation.adapters.XmlAdapter
的用法示例。
在下文中一共展示了XmlAdapter.unmarshal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConstant
import javax.xml.bind.annotation.adapters.XmlAdapter; //导入方法依赖的package包/类
public JExpression createConstant(Outline outline, XmlString lexical) {
if(isCollection()) return null;
if(adapter==null) return coreType.createConstant(outline, lexical);
// [RESULT] new Adapter().unmarshal(CONSTANT);
JExpression cons = coreType.createConstant(outline, lexical);
Class<? extends XmlAdapter> atype = adapter.getAdapterIfKnown();
// try to run the adapter now rather than later.
if(cons instanceof JStringLiteral && atype!=null) {
JStringLiteral scons = (JStringLiteral) cons;
XmlAdapter a = ClassFactory.create(atype);
try {
Object value = a.unmarshal(scons.str);
if(value instanceof String) {
return JExpr.lit((String)value);
}
} catch (Exception e) {
// assume that we can't eagerly bind this
}
}
return JExpr._new(adapter.getAdapterClass(outline)).invoke("unmarshal").arg(cons);
}
示例2: adaptU
import javax.xml.bind.annotation.adapters.XmlAdapter; //导入方法依赖的package包/类
private @NotNull InMemory adaptU(Unmarshaller _u, OnWire v) throws JAXBException {
UnmarshallerImpl u = (UnmarshallerImpl) _u;
XmlAdapter<OnWire,InMemory> a = u.coordinator.getAdapter(adapter);
u.coordinator.pushCoordinator();
try {
return a.unmarshal(v);
} catch (Exception e) {
throw new UnmarshalException(e);
} finally {
u.coordinator.popCoordinator();
}
}
示例3: adaptU
import javax.xml.bind.annotation.adapters.XmlAdapter; //导入方法依赖的package包/类
private @NotNull InMemory adaptU(Unmarshaller _u, OnWire v) throws JAXBException {
UnmarshallerImpl u = (UnmarshallerImpl) _u;
XmlAdapter<OnWire,InMemory> a = u.coordinator.getAdapter(adapter);
u.coordinator.setThreadAffinity();
u.coordinator.pushCoordinator();
try {
return a.unmarshal(v);
} catch (Exception e) {
throw new UnmarshalException(e);
} finally {
u.coordinator.popCoordinator();
u.coordinator.resetThreadAffinity();
}
}
示例4: createConstant
import javax.xml.bind.annotation.adapters.XmlAdapter; //导入方法依赖的package包/类
public JExpression createConstant(Outline outline, XmlString lexical) {
if (isCollection())
return null;
if (adapter == null)
return coreType.createConstant(outline, lexical);
// [RESULT] new Adapter().unmarshal(CONSTANT);
JExpression cons = coreType.createConstant(outline, lexical);
@SuppressWarnings("unchecked")
Class<? extends XmlAdapter<?, ?>> atype = (Class<? extends XmlAdapter<?, ?>>) adapter
.getAdapterIfKnown();
// try to run the adapter now rather than later.
if (cons instanceof JStringLiteral && atype != null) {
JStringLiteral scons = (JStringLiteral) cons;
@SuppressWarnings("unchecked")
XmlAdapter<Object, String> a = (XmlAdapter<Object, String>) ClassFactory
.create(atype);
try {
Object value = a.unmarshal(scons.str);
if (value instanceof String) {
return JExpr.lit((String) value);
}
} catch (Exception e) {
// assume that we can't eagerly bind this
}
}
return JExpr._new(adapter.getAdapterClass(outline)).invoke("unmarshal")
.arg(cons);
}
示例5: unmarshall
import javax.xml.bind.annotation.adapters.XmlAdapter; //导入方法依赖的package包/类
public static <ValueType, BoundType> BoundType unmarshall(
Class<? extends XmlAdapter<ValueType, BoundType>> xmlAdapterClass,
ValueType v) {
try {
final XmlAdapter<ValueType, BoundType> xmlAdapter = getXmlAdapter(xmlAdapterClass);
return xmlAdapter.unmarshal(v);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
示例6: unmarshallJAXBElement
import javax.xml.bind.annotation.adapters.XmlAdapter; //导入方法依赖的package包/类
public static <ValueType, BoundType> ValueType unmarshallJAXBElement(
Class<? extends XmlAdapter<BoundType, ValueType>> xmlAdapterClass,
JAXBElement<? extends BoundType> v) {
try {
if (v == null) {
return null;
} else {
final XmlAdapter<BoundType, ValueType> xmlAdapter = getXmlAdapter(xmlAdapterClass);
return xmlAdapter.unmarshal(v.getValue());
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
示例7: uncheckedUnmarshal
import javax.xml.bind.annotation.adapters.XmlAdapter; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> MutableLocatable<?> uncheckedUnmarshal(Object object, XmlAdapter<T, ?> xmlAdapter)
throws Exception {
return (MutableLocatable<?>) xmlAdapter.unmarshal((T) object);
}