本文整理匯總了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);
}