blob: 9dfbaf4ad58baa75126a35ac174e9caa09f2a88c [file] [log] [blame]
Stuart McCullochbb014372012-06-07 21:57:32 +00001package aQute.lib.json;
2
3import java.io.*;
4import java.lang.reflect.*;
5import java.util.*;
6
7public class BooleanHandler extends Handler {
8
Stuart McCulloch2286f232012-06-15 13:27:53 +00009 @Override
10 void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception {
11 app.append(object.toString());
Stuart McCullochbb014372012-06-07 21:57:32 +000012 }
Stuart McCulloch2286f232012-06-15 13:27:53 +000013
14 @Override
Stuart McCullocha21b9e82012-08-02 13:26:25 +000015 Object decode(Decoder dec, boolean s) {
Stuart McCullochbb014372012-06-07 21:57:32 +000016 return s;
17 }
18
Stuart McCulloch2286f232012-06-15 13:27:53 +000019 @Override
Stuart McCullocha21b9e82012-08-02 13:26:25 +000020 Object decode(Decoder dec, String s) {
Stuart McCullochbb014372012-06-07 21:57:32 +000021 return Boolean.parseBoolean(s);
22 }
23
Stuart McCulloch2286f232012-06-15 13:27:53 +000024 @Override
Stuart McCullocha21b9e82012-08-02 13:26:25 +000025 Object decode(Decoder dec, Number s) {
Stuart McCullochbb014372012-06-07 21:57:32 +000026 return s.intValue() != 0;
27 }
28
Stuart McCulloch2286f232012-06-15 13:27:53 +000029 @Override
Stuart McCullocha21b9e82012-08-02 13:26:25 +000030 Object decode(Decoder dec) {
Stuart McCullochbb014372012-06-07 21:57:32 +000031 return false;
32 }
33
34}