HIGUCHI Yuta | f086d8a | 2013-06-12 15:26:35 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.util.serializers; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 2 | |
| 3 | import java.io.IOException; |
| 4 | |
HIGUCHI Yuta | 858c1ea | 2013-06-14 13:10:06 -0700 | [diff] [blame^] | 5 | import net.onrc.onos.ofcontroller.util.IPv4Net; |
| 6 | |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 7 | import org.codehaus.jackson.JsonGenerator; |
| 8 | import org.codehaus.jackson.JsonProcessingException; |
| 9 | import org.codehaus.jackson.map.JsonSerializer; |
| 10 | import org.codehaus.jackson.map.SerializerProvider; |
| 11 | |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 12 | /** |
| 13 | * Serialize an IPv4Net address as a string. |
| 14 | */ |
| 15 | public class IPv4NetSerializer extends JsonSerializer<IPv4Net> { |
| 16 | |
| 17 | @Override |
| 18 | public void serialize(IPv4Net ipv4Net, 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", ipv4Net.toString()); |
| 23 | jGen.writeEndObject(); |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 24 | } |
| 25 | } |