From 380b36be3352cd9a5c93dbd67db25346166a8547 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 11 Jun 2012 04:05:22 +0000 Subject: All languages now support Null except for python and php, python is proving slightly trickier. --- java/com/xagasoft/gats/GatsNull.java | 40 ++++++++++++++++++++++++++++++++++ java/com/xagasoft/gats/GatsObject.java | 5 +++++ 2 files changed, 45 insertions(+) create mode 100644 java/com/xagasoft/gats/GatsNull.java (limited to 'java/com') diff --git a/java/com/xagasoft/gats/GatsNull.java b/java/com/xagasoft/gats/GatsNull.java new file mode 100644 index 0000000..7919433 --- /dev/null +++ b/java/com/xagasoft/gats/GatsNull.java @@ -0,0 +1,40 @@ +package com.xagasoft.gats; + +import java.io.InputStream; +import java.io.OutputStream; + +/** + * Represents a null value. This is really is the simplest type, GatsBoolean is + * a damn liar. This doesn't have any value, it's just null. + */ +public class GatsNull extends GatsObject +{ + private boolean bValue = false; + + /** + * Construct a new GatsNull, the default value is false. + */ + public GatsNull() + { + } + + public int getType() + { + return GatsObject.NULL; + } + + public String toString() + { + return "(null)"; + } + + void read( InputStream is, char cType ) throws java.io.IOException + { + } + + void write( OutputStream os ) throws java.io.IOException + { + os.write( (int)'n' ); + } +}; + diff --git a/java/com/xagasoft/gats/GatsObject.java b/java/com/xagasoft/gats/GatsObject.java index 47602b3..e26ab7b 100644 --- a/java/com/xagasoft/gats/GatsObject.java +++ b/java/com/xagasoft/gats/GatsObject.java @@ -18,6 +18,7 @@ public abstract class GatsObject public final static int LIST = 4; public final static int DICTIONARY = 5; public final static int BOOLEAN = 6; + public final static int NULL = 7; /** * Gets the type of the current object, type can be one of INTEGER, FLOAT, @@ -74,6 +75,10 @@ public abstract class GatsObject goRet = new GatsFloat(); break; + case 'n': + goRet = new GatsNull(); + break; + case 'e': return null; -- cgit v1.2.3