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 | |
HIGUCHI Yuta | 356086e | 2013-06-12 15:21:19 -0700 | [diff] [blame^] | 10 | import net.onrc.onos.ofcontroller.util.IPv4; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 11 | |
| 12 | /** |
| 13 | * Serialize an IPv4 address as a string. |
| 14 | */ |
| 15 | public class IPv4Serializer extends JsonSerializer<IPv4> { |
| 16 | |
| 17 | @Override |
| 18 | public void serialize(IPv4 ipv4, JsonGenerator jGen, |
| 19 | SerializerProvider serializer) |
| 20 | throws IOException, JsonProcessingException { |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 21 | jGen.writeStartObject(); |
| 22 | jGen.writeStringField("value", ipv4.toString()); |
| 23 | jGen.writeEndObject(); |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 24 | } |
| 25 | } |