本文整理汇总了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);
}
示例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;
}
}
示例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());
}
});
}
示例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());
}
});
}
示例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());
}
});
}