diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-04-21 17:19:19 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-04-21 17:19:19 +0000 |
commit | 49216a230c331791b06df1527c3245c88e991c20 (patch) | |
tree | 3ac2a22fdc1e2d30cd960cd4fe77e137a3a0a846 /java/com/xagasoft/gats/GatsObject.java | |
parent | cd3a919b88c401fd86b1f4c853ee60898f2cb24a (diff) | |
download | libgats-49216a230c331791b06df1527c3245c88e991c20.tar.gz libgats-49216a230c331791b06df1527c3245c88e991c20.tar.bz2 libgats-49216a230c331791b06df1527c3245c88e991c20.tar.xz libgats-49216a230c331791b06df1527c3245c88e991c20.zip |
Gats for java is getting closer.
Diffstat (limited to 'java/com/xagasoft/gats/GatsObject.java')
-rw-r--r-- | java/com/xagasoft/gats/GatsObject.java | 62 |
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 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | import java.io.InputStream; | ||
4 | |||
5 | public 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 | |||