From 49216a230c331791b06df1527c3245c88e991c20 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 21 Apr 2011 17:19:19 +0000 Subject: Gats for java is getting closer. --- java/com/xagasoft/gats/GatsObject.java | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 java/com/xagasoft/gats/GatsObject.java (limited to 'java/com/xagasoft/gats/GatsObject.java') diff --git a/java/com/xagasoft/gats/GatsObject.java b/java/com/xagasoft/gats/GatsObject.java new file mode 100644 index 0000000..63fcf36 --- /dev/null +++ b/java/com/xagasoft/gats/GatsObject.java @@ -0,0 +1,62 @@ +package com.xagasoft.gats; + +import java.io.InputStream; + +public abstract class GatsObject +{ + public final static int INTEGER = 1; + public final static int FLOAT = 2; + public final static int STRING = 3; + public final static int LIST = 4; + public final static int DICTIONARY = 5; + public final static int BOOLEAN = 6; + + public abstract int getType(); + + public abstract void read( InputStream is, char cType ); + + public static GatsObject read( InputStream is ) + { + char type = is.read(); + GatsObject goRet; + switch( type ) + { + case 'i': + goRet = new Integer(); + break; + + case 's': + goRet = new String(); + break; + + case '0': + case '1': + goRet = new Boolean(); + break; + + case 'l': + goRet = new List(); + break; + + case 'd': + goRet = new Dictionary(); + break; + + case 'f': + case 'F': + goRet = new Float(); + break; + + case 'e': + return null; + + default: + throw new Exception("Invalid gats type discovered: " + (char)type ); + } + + goRet.read( is, type ); + + return goRet; + } +}; + -- cgit v1.2.3