blob: 23605bf8a52cf9980a43e7ac09d48f099eee2689 [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
16 Object decode(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
21 Object decode(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
26 Object decode(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
31 Object decode() {
Stuart McCullochbb014372012-06-07 21:57:32 +000032 return 0;
33 }
34
35}