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


Java XmlAdapter.marshal方法代碼示例

本文整理匯總了Java中javax.xml.bind.annotation.adapters.XmlAdapter.marshal方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlAdapter.marshal方法的具體用法?Java XmlAdapter.marshal怎麽用?Java XmlAdapter.marshal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.bind.annotation.adapters.XmlAdapter的用法示例。


在下文中一共展示了XmlAdapter.marshal方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: _adaptM

import javax.xml.bind.annotation.adapters.XmlAdapter; //導入方法依賴的package包/類
private OnWire _adaptM(XMLSerializer serializer, InMemory v) throws MarshalException {
    XmlAdapter<OnWire,InMemory> a = serializer.getAdapter(adapter);
    try {
        return a.marshal(v);
    } catch (Exception e) {
        serializer.handleError(e,v,null);
        throw new MarshalException(e);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:BridgeAdapter.java

示例2: get

import javax.xml.bind.annotation.adapters.XmlAdapter; //導入方法依賴的package包/類
public OnWireValueT get(BeanT bean) throws AccessorException {
    InMemValueT v = core.get(bean);

    XmlAdapter<OnWireValueT,InMemValueT> a = getAdapter();
    try {
        return a.marshal(v);
    } catch (Exception e) {
        throw new AccessorException(e);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:AdaptedAccessor.java

示例3: validateField

import javax.xml.bind.annotation.adapters.XmlAdapter; //導入方法依賴的package包/類
/**
 * Validate a field setting.
 * <p>
 * This method inspects the field annotation for an XmlTypeValidator. If found
 * then the XmlTypeValidator is instantiated and called against the provided
 * field value.
 * <p>
 * If no XmlTypeValidator annotation is found then the field value is assumed
 * to be valid.
 * <p>
 * If the field value is null then NO VALIDATION is done.
 *
 *
 * @param field      the class field
 * @param fieldValue the class field configured value
 * @throws Exception the XmlTypeValidator marshal error, thrown ONLY if the
 *                   field value is not valid
 */
private static void validateField(Field field, Object fieldValue) throws Exception {
  /**
   * Do not validate fields with null values.
   */
  if (fieldValue == null) {
    return;
  }
  /**
   * Scan the field annotations looking for an XmlJavaTypeAdapter instance.
   */
  for (Annotation annotation : field.getAnnotations()) {
    if (annotation instanceof XmlJavaTypeAdapter) {
      /**
       * If an XmlJavaTypeAdapter annotation is found then instantiate the
       * XmlAdapter class referred to in the "value" field and attempt to
       * marshal the field value. This action will complete silently if the
       * field value is valid and throw an exception if the field value is not
       * valid (as determined by the marshal method).
       */
      try {
        XmlAdapter<Object, Object> adapterInstance = ((XmlJavaTypeAdapter) annotation).value().getConstructor().newInstance();
        adapterInstance.marshal(fieldValue);
      } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
        logger.log(Level.WARNING, "XmlJavaTypeAdapter failed to instantiate: {0}", ex.getMessage());
        logger.log(Level.SEVERE, null, ex);
      }
    }
  }
}
 
開發者ID:KeyBridge,項目名稱:lib-openssrf,代碼行數:48,代碼來源:SSRFUtility.java

示例4: marshall

import javax.xml.bind.annotation.adapters.XmlAdapter; //導入方法依賴的package包/類
public static <ValueType, BoundType> ValueType marshall(
		Class<? extends XmlAdapter<ValueType, BoundType>> xmlAdapterClass,
		BoundType v) {
	try {
		final XmlAdapter<ValueType, BoundType> xmlAdapter = getXmlAdapter(xmlAdapterClass);
		return xmlAdapter.marshal(v);
	} catch (Exception ex) {
		throw new RuntimeException(ex);
	}
}
 
開發者ID:highsource,項目名稱:hyperjaxb3,代碼行數:11,代碼來源:XmlAdapterUtils.java

示例5: marshallJAXBElement

import javax.xml.bind.annotation.adapters.XmlAdapter; //導入方法依賴的package包/類
public static <ValueType, BoundType> JAXBElement<BoundType> marshallJAXBElement(
		Class<? extends XmlAdapter<BoundType, ValueType>> xmlAdapterClass,
		Class<BoundType> declaredType, QName name, Class<?> scope, ValueType v) {
	try {
		if (v == null) {
			return null;
		} else {
			final XmlAdapter<BoundType, ValueType> xmlAdapter = getXmlAdapter(xmlAdapterClass);
			return new JAXBElement<BoundType>(name, declaredType, scope,
					xmlAdapter.marshal(v));
		}
	} catch (Exception ex) {
		throw new RuntimeException(ex);
	}
}
 
開發者ID:highsource,項目名稱:hyperjaxb3,代碼行數:16,代碼來源:XmlAdapterUtils.java

示例6: uncheckedMarshal

import javax.xml.bind.annotation.adapters.XmlAdapter; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private static <T> Object uncheckedMarshal(MutableLocatable<?> object, XmlAdapter<?, T> xmlAdapter)
        throws Exception {
    return xmlAdapter.marshal((T) object);
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:6,代碼來源:MutableLocatableContract.java


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