當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlAdapter.unmarshal方法代碼示例

本文整理匯總了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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:TypeUseImpl.java

示例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();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:BridgeAdapter.java

示例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();
    }
}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:15,代碼來源:BridgeAdapter.java

示例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);
}
 
開發者ID:highsource,項目名稱:hyperjaxb3,代碼行數:33,代碼來源:DefaultTypeUse.java

示例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);
	}
}
 
開發者ID:highsource,項目名稱:hyperjaxb3,代碼行數:11,代碼來源:XmlAdapterUtils.java

示例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);
	}
}
 
開發者ID:highsource,項目名稱:hyperjaxb3,代碼行數:15,代碼來源:XmlAdapterUtils.java

示例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);
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:6,代碼來源:MutableLocatableContract.java


注:本文中的javax.xml.bind.annotation.adapters.XmlAdapter.unmarshal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。