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


Java SerializerBase类代码示例

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


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

示例1: JsonStreamCodec

import org.codehaus.jackson.map.ser.std.SerializerBase; //导入依赖的package包/类
public JsonStreamCodec(Map<Class<?>, Class<? extends StringCodec<?>>> codecs)
{
  JacksonObjectMapperProvider jomp = new JacksonObjectMapperProvider();
  if (codecs != null) {
    for (Map.Entry<Class<?>, Class<? extends StringCodec<?>>> entry: codecs.entrySet()) {
      try {
        @SuppressWarnings("unchecked")
        final StringCodec<Object> codec = (StringCodec<Object>)entry.getValue().newInstance();
        jomp.addSerializer(new SerializerBase(entry.getKey())
        {
          @Override
          public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException
          {
            jgen.writeString(codec.toString(value));
          }

        });
      } catch (Exception ex) {
        logger.error("Caught exception when instantiating codec for class {}", entry.getKey().getName(), ex);
      }
    }
  }
  mapper = jomp.getContext(null);
}
 
开发者ID:apache,项目名称:apex-core,代码行数:25,代码来源:JsonStreamCodec.java

示例2: init

import org.codehaus.jackson.map.ser.std.SerializerBase; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
private void init()
{
  //clear content type
  httpResponse.setContentType(null);
  if (!initialized) {
    Map<Class<?>, Class<? extends StringCodec<?>>> codecs = dagManager.getApplicationAttributes().get(DAGContext.STRING_CODECS);
    StringCodecs.loadConverters(codecs);
    if (codecs != null) {
      SimpleModule sm = new SimpleModule("DTSerializationModule", new Version(1, 0, 0, null));
      for (Map.Entry<Class<?>, Class<? extends StringCodec<?>>> entry : codecs.entrySet()) {
        try {
          final StringCodec<Object> codec = (StringCodec<Object>)entry.getValue().newInstance();
          sm.addSerializer(new SerializerBase(entry.getKey())
          {
            @Override
            public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException
            {
              jgen.writeString(codec.toString(value));
            }

          });
        } catch (Exception ex) {
          LOG.error("Caught exception when instantiating codec for class {}", entry.getKey().getName(), ex);
        }
      }

      objectMapper.registerModule(sm);
    }
    initialized = true;
  }
}
 
开发者ID:apache,项目名称:apex-core,代码行数:33,代码来源:StramWebServices.java

示例3: IntentResource

import org.codehaus.jackson.map.ser.std.SerializerBase; //导入依赖的package包/类
/**
 * Constructs an IntentResource.
 * <p/>
 * A custom serializer for {@link IntentId} is automatically registered,
 * because IntentId can't be serialized by default.
 */
public IntentResource() {
    intentSerializers = new CustomSerializerHelper();
    intentSerializers.addSerializer(IntentId.class,
        new SerializerBase<IntentId>(IntentId.class) {
            @Override
            public void serialize(IntentId id, JsonGenerator jGen,
                    SerializerProvider sp) throws IOException,
                    JsonProcessingException {
                jGen.writeString(id.toString());
            }
        });
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:19,代码来源:IntentResource.java

示例4: FlowResource

import org.codehaus.jackson.map.ser.std.SerializerBase; //导入依赖的package包/类
/**
 * Constructs a FlowResource.
 * <p/>
 * A custom serializer for {@link FlowId} is automatically registered,
 * because FlowId can't be serialized by default.
 */
public FlowResource() {
    flowSerializers = new CustomSerializerHelper();
    flowSerializers.addSerializer(FlowId.class, new SerializerBase<FlowId>(FlowId.class) {
        @Override
        public void serialize(FlowId flowId, JsonGenerator jgen,
                SerializerProvider provider) throws IOException,
                JsonGenerationException {
            jgen.writeString(flowId.toString());
        }
    });
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:18,代码来源:FlowResource.java

示例5: MatchActionResource

import org.codehaus.jackson.map.ser.std.SerializerBase; //导入依赖的package包/类
/**
 * Constructs a MatchActionResource.
 * <p/>
 * A custom serializer for {@link MatchActionId} is automatically
 * registered, because MatchActionId can't be serialized by default.
 */
public MatchActionResource() {
    matchActionSerializers = new CustomSerializerHelper();
    matchActionSerializers.addSerializer(MatchActionId.class,
            new SerializerBase<MatchActionId>(MatchActionId.class) {
        @Override
        public void serialize(MatchActionId id, JsonGenerator jGen, SerializerProvider sp)
                throws IOException, JsonProcessingException {
            jGen.writeString(id.toString());
        }
    });
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:18,代码来源:MatchActionResource.java


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