当前位置: 首页>>代码示例>>Java>>正文


Java AbstractSingleValueConverter类代码示例

本文整理汇总了Java中com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter的典型用法代码示例。如果您正苦于以下问题:Java AbstractSingleValueConverter类的具体用法?Java AbstractSingleValueConverter怎么用?Java AbstractSingleValueConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractSingleValueConverter类属于com.thoughtworks.xstream.converters.basic包,在下文中一共展示了AbstractSingleValueConverter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createXStream

import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected XStream createXStream() {
    XStream xstream = null;
    if (brokerContext != null) {
        Map<String, XStream> beans = brokerContext.getBeansOfType(XStream.class);
        for (XStream bean : beans.values()) {
            if (bean != null) {
                xstream = bean;
                break;
            }
        }
    }

    if (xstream == null) {
        xstream = new XStream();
    }

    // For any object whose elements contains an UTF8Buffer instance instead of a String
    // type we map it to String both in and out such that we don't marshal UTF8Buffers out
    xstream.registerConverter(new AbstractSingleValueConverter() {

        @Override
        public Object fromString(String str) {
            return str;
        }

        @SuppressWarnings("rawtypes")
        @Override
        public boolean canConvert(Class type) {
            return type.equals(UTF8Buffer.class);
        }
    });

    xstream.alias("string", UTF8Buffer.class);

    return xstream;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:38,代码来源:JmsFrameTranslator.java


注:本文中的com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。