当前位置: 首页>>代码示例>>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;未经允许,请勿转载。