aboutsummaryrefslogtreecommitdiff
path: root/java/com/xagasoft/gats/GatsObject.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/xagasoft/gats/GatsObject.java')
-rw-r--r--java/com/xagasoft/gats/GatsObject.java62
1 files changed, 62 insertions, 0 deletions
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 @@
1package com.xagasoft.gats;
2
3import java.io.InputStream;
4
5public abstract class GatsObject
6{
7 public final static int INTEGER = 1;
8 public final static int FLOAT = 2;
9 public final static int STRING = 3;
10 public final static int LIST = 4;
11 public final static int DICTIONARY = 5;
12 public final static int BOOLEAN = 6;
13
14 public abstract int getType();
15
16 public abstract void read( InputStream is, char cType );
17
18 public static GatsObject read( InputStream is )
19 {
20 char type = is.read();
21 GatsObject goRet;
22 switch( type )
23 {
24 case 'i':
25 goRet = new Integer();
26 break;
27
28 case 's':
29 goRet = new String();
30 break;
31
32 case '0':
33 case '1':
34 goRet = new Boolean();
35 break;
36
37 case 'l':
38 goRet = new List();
39 break;
40
41 case 'd':
42 goRet = new Dictionary();
43 break;
44
45 case 'f':
46 case 'F':
47 goRet = new Float();
48 break;
49
50 case 'e':
51 return null;
52
53 default:
54 throw new Exception("Invalid gats type discovered: " + (char)type );
55 }
56
57 goRet.read( is, type );
58
59 return goRet;
60 }
61};
62