Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.util.serializers; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | |
| 5 | import org.codehaus.jackson.JsonGenerator; |
| 6 | import org.codehaus.jackson.JsonProcessingException; |
| 7 | import org.codehaus.jackson.map.JsonSerializer; |
| 8 | import org.codehaus.jackson.map.SerializerProvider; |
| 9 | |
| 10 | import net.floodlightcontroller.util.FlowEntry; |
| 11 | |
| 12 | /** |
| 13 | * Serialize a FlowEntry as a string. |
| 14 | */ |
| 15 | public class FlowEntrySerializer extends JsonSerializer<FlowEntry> { |
| 16 | |
| 17 | @Override |
| 18 | public void serialize(FlowEntry flowEntry, |
| 19 | JsonGenerator jGen, SerializerProvider serializer) |
| 20 | throws IOException, JsonProcessingException { |
| 21 | jGen.writeStartObject(); |
| 22 | jGen.writeObjectField("flowEntryId", flowEntry.flowEntryId()); |
| 23 | jGen.writeObjectField("flowEntryMatch", flowEntry.flowEntryMatch()); |
| 24 | jGen.writeObjectField("flowEntryActions", |
| 25 | flowEntry.flowEntryActions()); |
| 26 | jGen.writeObjectField("dpid", flowEntry.dpid()); |
| 27 | jGen.writeObjectField("inPort", flowEntry.inPort()); |
| 28 | jGen.writeObjectField("outPort", flowEntry.outPort()); |
| 29 | jGen.writeObjectField("flowEntryUserState", |
| 30 | flowEntry.flowEntryUserState()); |
| 31 | jGen.writeObjectField("flowEntrySwitchState", |
| 32 | flowEntry.flowEntrySwitchState()); |
| 33 | jGen.writeObjectField("flowEntryErrorState", |
| 34 | flowEntry.flowEntryErrorState()); |
| 35 | jGen.writeEndObject(); |
| 36 | } |
| 37 | } |