Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame^] | 1 | package aQute.lib.json; |
| 2 | |
| 3 | import java.io.*; |
| 4 | import java.lang.reflect.*; |
| 5 | import java.util.*; |
| 6 | |
| 7 | public class BooleanHandler extends Handler { |
| 8 | |
| 9 | @Override void encode(Encoder app, Object object, Map<Object, Type> visited) |
| 10 | throws IOException, Exception { |
| 11 | app.append( object.toString()); |
| 12 | } |
| 13 | |
| 14 | @Override Object decode(boolean s) { |
| 15 | return s; |
| 16 | } |
| 17 | |
| 18 | @Override Object decode(String s) { |
| 19 | return Boolean.parseBoolean(s); |
| 20 | } |
| 21 | |
| 22 | @Override Object decode(Number s) { |
| 23 | return s.intValue() != 0; |
| 24 | } |
| 25 | |
| 26 | @Override Object decode() { |
| 27 | return false; |
| 28 | } |
| 29 | |
| 30 | } |