blob: 799f73c8e8a5d4ab4b82e02a276ab53c0c4bcf4c [file] [log] [blame]
Stuart McCullochbb014372012-06-07 21:57:32 +00001package aQute.lib.json;
2
3import java.lang.reflect.*;
4import java.util.*;
5
6public class CharacterHandler extends Handler {
7
Stuart McCulloch2286f232012-06-15 13:27:53 +00008 @Override
9 void encode(Encoder app, Object object, Map<Object,Type> visited) throws Exception {
10 Character c = (Character) object;
Stuart McCullochd4826102012-06-26 16:34:24 +000011 int v = c.charValue();
Stuart McCulloch2286f232012-06-15 13:27:53 +000012 app.append(v + "");
Stuart McCullochbb014372012-06-07 21:57:32 +000013 }
Stuart McCulloch2286f232012-06-15 13:27:53 +000014
15 @Override
Stuart McCullocha21b9e82012-08-02 13:26:25 +000016 Object decode(Decoder dec, boolean s) {
Stuart McCullochbb014372012-06-07 21:57:32 +000017 return s ? 't' : 'f';
18 }
19
Stuart McCulloch2286f232012-06-15 13:27:53 +000020 @Override
Stuart McCullocha21b9e82012-08-02 13:26:25 +000021 Object decode(Decoder dec, String s) {
Stuart McCullochbb014372012-06-07 21:57:32 +000022 return (char) Integer.parseInt(s);
23 }
24
Stuart McCulloch2286f232012-06-15 13:27:53 +000025 @Override
Stuart McCullocha21b9e82012-08-02 13:26:25 +000026 Object decode(Decoder dec, Number s) {
Stuart McCullochbb014372012-06-07 21:57:32 +000027 return (char) s.shortValue();
28 }
29
Stuart McCulloch2286f232012-06-15 13:27:53 +000030 @Override
Stuart McCullocha21b9e82012-08-02 13:26:25 +000031 Object decode(Decoder dec) {
Stuart McCullochbb014372012-06-07 21:57:32 +000032 return 0;
33 }
34
35}