本文整理匯總了Java中org.codehaus.jackson.map.SerializerProvider類的典型用法代碼示例。如果您正苦於以下問題:Java SerializerProvider類的具體用法?Java SerializerProvider怎麽用?Java SerializerProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SerializerProvider類屬於org.codehaus.jackson.map包,在下文中一共展示了SerializerProvider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: JsonStreamCodec
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的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: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
/**
* Performs the serialization of a OFFeaturesReply object
*/
@Override
public void serialize(OFFeaturesReply reply, JsonGenerator jGen, SerializerProvider serializer) throws IOException, JsonProcessingException {
jGen.writeStartObject();
jGen.writeNumberField("actions", reply.getActions());
jGen.writeNumberField("buffers", reply.getBuffers());
jGen.writeNumberField("capabilities", reply.getCapabilities());
jGen.writeStringField("datapathId", HexString.toHexString(reply.getDatapathId()));
jGen.writeNumberField("length", reply.getLength());
serializer.defaultSerializeField("ports", reply.getPorts(), jGen);
jGen.writeNumberField("tables", reply.getTables());
jGen.writeStringField("type", reply.getType().toString());
jGen.writeNumberField("version", reply.getVersion());
jGen.writeNumberField("xid", reply.getXid());
jGen.writeEndObject();
}
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:19,代碼來源:OFFeaturesReplyJSONSerializer.java
示例3: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
/**
* Performs the serialization of a OneComponentTime object
*/
@Override
public void serialize(CumulativeTimeBucket ctb,
JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
jGen.writeStartObject();
Timestamp ts = new Timestamp(ctb.getStartTimeNs()/1000000);
jGen.writeStringField("start-time", ts.toString());
jGen.writeStringField("current-time",
new Timestamp(System.currentTimeMillis()).toString());
jGen.writeNumberField("total-packets", ctb.getTotalPktCnt());
jGen.writeNumberField("average", ctb.getAverageProcTimeNs());
jGen.writeNumberField("min", ctb.getMinTotalProcTimeNs());
jGen.writeNumberField("max", ctb.getMaxTotalProcTimeNs());
jGen.writeNumberField("std-dev", ctb.getTotalSigmaProcTimeNs());
jGen.writeArrayFieldStart("modules");
for (OneComponentTime oct : ctb.getModules()) {
serializer.defaultSerializeValue(oct, jGen);
}
jGen.writeEndArray();
jGen.writeEndObject();
}
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:26,代碼來源:CumulativeTimeBucketJSONSerializer.java
示例4: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
@Override
public void serialize(VirtualNetwork vNet, JsonGenerator jGen,
SerializerProvider serializer) throws IOException,
JsonProcessingException {
jGen.writeStartObject();
jGen.writeStringField("name", vNet.name);
jGen.writeStringField("guid", vNet.guid);
jGen.writeStringField("gateway", vNet.gateway);
jGen.writeArrayFieldStart("mac");
Iterator<MACAddress> hit = vNet.hosts.iterator();
while (hit.hasNext())
jGen.writeString(hit.next().toString());
jGen.writeEndArray();
jGen.writeEndObject();
}
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:19,代碼來源:VirtualNetworkSerializer.java
示例5: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
/**
* Performs the serialization of a EventHistory.BaseInfo object
*/
@Override
public void serialize(EventHistoryBaseInfo base_info, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
jGen.writeStartObject();
jGen.writeNumberField("Idx", base_info.getIdx());
Timestamp ts = new Timestamp(base_info.getTime_ms());
String tsStr = ts.toString();
while (tsStr.length() < 23) {
tsStr = tsStr.concat("0");
}
jGen.writeStringField("Time", tsStr);
jGen.writeStringField("State", base_info.getState().name());
String acStr = base_info.getAction().name().toLowerCase();
// Capitalize the first letter
acStr = acStr.substring(0,1).toUpperCase().concat(acStr.substring(1));
jGen.writeStringField("Action", acStr);
jGen.writeEndObject();
}
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:23,代碼來源:EventHistoryBaseInfoJSONSerializer.java
示例6: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
@Override
public void serialize(Map<String, Object> fields, JsonGenerator jgen,
SerializerProvider provider) throws IOException,
JsonProcessingException {
jgen.writeStartObject();
for (Entry<String, Object> entry : fields.entrySet()) {
Object objectValue = entry.getValue();
if (objectValue instanceof Date) {
Date date = (Date) objectValue;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland"));
String formattedDate = simpleDateFormat.format(date);
jgen.writeObjectField(entry.getKey().toString(), formattedDate);
} else {
jgen.writeObjectField(entry.getKey().toString(), objectValue);
}
}
jgen.writeEndObject();
}
示例7: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
@Override
public void serialize(SerializablePagedCollection pagedCol, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonGenerationException
{
if (pagedCol != null)
{
jgen.writeStartObject();
jgen.writeFieldName("list");
jgen.writeStartObject();
serializePagination(pagedCol, jgen);
serializeContext(pagedCol, jgen);
jgen.writeObjectField("entries", pagedCol.getCollection());
serializeIncludedSource(pagedCol, jgen);
jgen.writeEndObject();
jgen.writeEndObject();
}
}
示例8: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
/**
* Serializes a LinkData object in JSON.
*
* @param linkData the LinkData that is being converted to JSON
* @param jsonGenerator generator to place the serialized JSON into
* @param serializerProvider unused but required for method override
* @throws IOException if the JSON serialization process fails
*/
@Override
public void serialize(final LinkData linkData,
final JsonGenerator jsonGenerator,
final SerializerProvider serializerProvider)
throws IOException {
//
// TODO: For now, the JSON format of the serialized output should
// be same as the JSON format of the corresponding class Link.
// In the future, we will use a single serializer.
//
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField(TopologyElement.TYPE, linkData.getType());
jsonGenerator.writeObjectField("src", linkData.getSrc());
jsonGenerator.writeObjectField("dst", linkData.getDst());
jsonGenerator.writeObjectFieldStart("stringAttributes");
for (Entry<String, String> entry : linkData.getAllStringAttributes().entrySet()) {
jsonGenerator.writeStringField(entry.getKey(), entry.getValue());
}
jsonGenerator.writeEndObject(); // stringAttributes
jsonGenerator.writeEndObject();
}
示例9: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
public void serialize(JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonProcessingException
{
if (this._prefix != null)
paramJsonGenerator.writeRaw(this._prefix);
if (this._value == null)
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
while (true)
{
if (this._suffix != null)
paramJsonGenerator.writeRaw(this._suffix);
return;
if (this._serializationType != null)
{
paramSerializerProvider.findTypedValueSerializer(this._serializationType, true, null).serialize(this._value, paramJsonGenerator, paramSerializerProvider);
continue;
}
paramSerializerProvider.findTypedValueSerializer(this._value.getClass(), true, null).serialize(this._value, paramJsonGenerator, paramSerializerProvider);
}
}
示例10: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
public final void serialize(JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonProcessingException
{
paramJsonGenerator.writeStartObject();
if (this._children != null)
{
Iterator localIterator = this._children.entrySet().iterator();
while (localIterator.hasNext())
{
Map.Entry localEntry = (Map.Entry)localIterator.next();
paramJsonGenerator.writeFieldName((String)localEntry.getKey());
((BaseJsonNode)localEntry.getValue()).serialize(paramJsonGenerator, paramSerializerProvider);
}
}
paramJsonGenerator.writeEndObject();
}
示例11: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
public void serialize(JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonProcessingException
{
paramJsonGenerator.writeRaw(this._function);
paramJsonGenerator.writeRaw('(');
if (this._value == null)
paramSerializerProvider.defaultSerializeNull(paramJsonGenerator);
while (true)
{
paramJsonGenerator.writeRaw(')');
return;
if (this._serializationType != null)
{
paramSerializerProvider.findTypedValueSerializer(this._serializationType, true, null).serialize(this._value, paramJsonGenerator, paramSerializerProvider);
continue;
}
paramSerializerProvider.findTypedValueSerializer(this._value.getClass(), true, null).serialize(this._value, paramJsonGenerator, paramSerializerProvider);
}
}
示例12: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
public void serialize(Number paramNumber, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
throws IOException, JsonGenerationException
{
if ((paramNumber instanceof BigDecimal))
{
paramJsonGenerator.writeNumber((BigDecimal)paramNumber);
return;
}
if ((paramNumber instanceof BigInteger))
{
paramJsonGenerator.writeNumber((BigInteger)paramNumber);
return;
}
if ((paramNumber instanceof Double))
{
paramJsonGenerator.writeNumber(((Double)paramNumber).doubleValue());
return;
}
if ((paramNumber instanceof Float))
{
paramJsonGenerator.writeNumber(((Float)paramNumber).floatValue());
return;
}
paramJsonGenerator.writeNumber(paramNumber.toString());
}
示例13: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
@Override
public void serialize(WebPushUser value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeStartObject();
if (value.getDeviceToken().isPresent()) {
jgen.writeStringField("deviceToken", value.getDeviceToken().get());
}
if (value.getActive().isPresent()) {
jgen.writeBooleanField("isActive", value.getActive().get());
}
if (value.getUserId().isPresent()) {
jgen.writeStringField("userId", value.getUserId().get());
}
if (value.getWebsitePushId().isPresent()) {
jgen.writeStringField("websitePushId", value.getWebsitePushId().get());
}
if (value.getActiveTimestamp().isPresent()) {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
Date dt = new Date(value.getActiveTimestamp().get());
String readableDate = sdf.format(dt);
jgen.writeStringField("activeDate", readableDate);
}
jgen.writeEndObject();
}
示例14: serializeWithType
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
public void serializeWithType(JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, TypeSerializer paramTypeSerializer)
throws IOException, JsonProcessingException
{
paramTypeSerializer.writeTypePrefixForObject(this, paramJsonGenerator);
if (this._children != null)
{
Iterator localIterator = this._children.entrySet().iterator();
while (localIterator.hasNext())
{
Map.Entry localEntry = (Map.Entry)localIterator.next();
paramJsonGenerator.writeFieldName((String)localEntry.getKey());
((BaseJsonNode)localEntry.getValue()).serialize(paramJsonGenerator, paramSerializerProvider);
}
}
paramTypeSerializer.writeTypeSuffixForObject(this, paramJsonGenerator);
}
示例15: serialize
import org.codehaus.jackson.map.SerializerProvider; //導入依賴的package包/類
@Override
public void serialize(TunnelLinkStatus status, JsonGenerator jGen,
SerializerProvider serializer) throws IOException,
JsonProcessingException {
String resultString;
if (status == TunnelLinkStatus.UP)
resultString = "up";
else if (status == TunnelLinkStatus.DOWN)
resultString = "down";
else if (status == TunnelLinkStatus.NOT_ENABLED)
resultString = "disabled";
else if (status == TunnelLinkStatus.NOT_ACTIVE)
resultString = "not active";
else resultString = "unknown";
jGen.writeString(resultString);
}