blob: 9912d554e1c18f8dbd2aa1fcae4a174f60ae79a1 [file] [log] [blame]
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08001package net.floodlightcontroller.util.serializers;
2
3import java.io.IOException;
4
5import org.codehaus.jackson.JsonGenerator;
6import org.codehaus.jackson.JsonProcessingException;
7import org.codehaus.jackson.map.JsonSerializer;
8import org.codehaus.jackson.map.SerializerProvider;
9
10import net.floodlightcontroller.util.FlowEntry;
11
12/**
13 * Serialize a FlowEntry as a string.
14 */
15public 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}