Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame^] | 1 | package aQute.lib.json; |
| 2 | |
| 3 | import java.lang.reflect.*; |
| 4 | import java.util.*; |
| 5 | |
| 6 | public class CharacterHandler extends Handler { |
| 7 | |
| 8 | @Override void encode(Encoder app, Object object, Map<Object, Type> visited) |
| 9 | throws Exception { |
| 10 | Character c = (Character) object; |
| 11 | int v = (int) c.charValue(); |
| 12 | app.append( v+"" ); |
| 13 | } |
| 14 | |
| 15 | @Override Object decode(boolean s) { |
| 16 | return s ? 't' : 'f'; |
| 17 | } |
| 18 | |
| 19 | @Override Object decode(String s) { |
| 20 | return (char) Integer.parseInt(s); |
| 21 | } |
| 22 | |
| 23 | @Override Object decode(Number s) { |
| 24 | return (char) s.shortValue(); |
| 25 | } |
| 26 | |
| 27 | @Override Object decode() { |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | } |