diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-03-10 22:48:18 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-03-10 22:48:18 +0000 |
commit | b251853a7d1bade6a8a49f3ae331f62fb4c59afc (patch) | |
tree | 4174e6c22c22310ed2a891b8303dea4f3a4acd4f | |
parent | fa127ac5a7b380d41d98eb789e0d51d061c6dea3 (diff) | |
download | libgats-b251853a7d1bade6a8a49f3ae331f62fb4c59afc.tar.gz libgats-b251853a7d1bade6a8a49f3ae331f62fb4c59afc.tar.bz2 libgats-b251853a7d1bade6a8a49f3ae331f62fb4c59afc.tar.xz libgats-b251853a7d1bade6a8a49f3ae331f62fb4c59afc.zip |
The beginings of java gats.
-rw-r--r-- | java/com/xagasoft/gats/Boolean.java | 10 | ||||
-rw-r--r-- | java/com/xagasoft/gats/Dictionary.java | 10 | ||||
-rw-r--r-- | java/com/xagasoft/gats/Float.java | 10 | ||||
-rw-r--r-- | java/com/xagasoft/gats/GatsStream.java | 6 | ||||
-rw-r--r-- | java/com/xagasoft/gats/Integer.java | 71 | ||||
-rw-r--r-- | java/com/xagasoft/gats/List.java | 10 | ||||
-rw-r--r-- | java/com/xagasoft/gats/String.java | 10 | ||||
-rw-r--r-- | java/com/xagasoft/gats/Type.java | 16 | ||||
-rw-r--r-- | java/default.bld | 6 |
9 files changed, 149 insertions, 0 deletions
diff --git a/java/com/xagasoft/gats/Boolean.java b/java/com/xagasoft/gats/Boolean.java new file mode 100644 index 0000000..eb83ecd --- /dev/null +++ b/java/com/xagasoft/gats/Boolean.java | |||
@@ -0,0 +1,10 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class Boolean extends Type | ||
4 | { | ||
5 | public int getType() | ||
6 | { | ||
7 | return Type.BOOLEAN; | ||
8 | } | ||
9 | }; | ||
10 | |||
diff --git a/java/com/xagasoft/gats/Dictionary.java b/java/com/xagasoft/gats/Dictionary.java new file mode 100644 index 0000000..1166899 --- /dev/null +++ b/java/com/xagasoft/gats/Dictionary.java | |||
@@ -0,0 +1,10 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class Dictionary extends Type | ||
4 | { | ||
5 | public int getType() | ||
6 | { | ||
7 | return Type.DICTIONARY; | ||
8 | } | ||
9 | }; | ||
10 | |||
diff --git a/java/com/xagasoft/gats/Float.java b/java/com/xagasoft/gats/Float.java new file mode 100644 index 0000000..60d5cf0 --- /dev/null +++ b/java/com/xagasoft/gats/Float.java | |||
@@ -0,0 +1,10 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class Float extends Type | ||
4 | { | ||
5 | public int getType() | ||
6 | { | ||
7 | return Type.FLOAT; | ||
8 | } | ||
9 | }; | ||
10 | |||
diff --git a/java/com/xagasoft/gats/GatsStream.java b/java/com/xagasoft/gats/GatsStream.java new file mode 100644 index 0000000..0cbd775 --- /dev/null +++ b/java/com/xagasoft/gats/GatsStream.java | |||
@@ -0,0 +1,6 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class GatsStream | ||
4 | { | ||
5 | }; | ||
6 | |||
diff --git a/java/com/xagasoft/gats/Integer.java b/java/com/xagasoft/gats/Integer.java new file mode 100644 index 0000000..7da12d4 --- /dev/null +++ b/java/com/xagasoft/gats/Integer.java | |||
@@ -0,0 +1,71 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | import java.io.OutputStream; | ||
4 | import java.io.InputStream; | ||
5 | |||
6 | public class Integer extends Type | ||
7 | { | ||
8 | public int getType() | ||
9 | { | ||
10 | return Type.INTEGER; | ||
11 | }; | ||
12 | |||
13 | /** | ||
14 | * Possible TODO: have this return a Number, and construct either a Long | ||
15 | * or BigInteger when appropriate. | ||
16 | */ | ||
17 | public static long readPackedInt( InputStream is ) | ||
18 | throws java.io.IOException | ||
19 | { | ||
20 | int b; | ||
21 | long rOut = 0; | ||
22 | boolean bNeg; | ||
23 | |||
24 | b = is.read(); | ||
25 | bNeg = (b&0x40) == 0x40; | ||
26 | rOut |= b&0x3F; | ||
27 | int c = 0; | ||
28 | while( (b&0x80) == 0x80 ) | ||
29 | { | ||
30 | b = is.read(); | ||
31 | rOut |= (long)(b&0x7F) << (6+7*(c++)); | ||
32 | } | ||
33 | if( bNeg ) | ||
34 | return -rOut; | ||
35 | return rOut; | ||
36 | } | ||
37 | |||
38 | public static void writePackedInt( OutputStream os, long iIn ) | ||
39 | throws java.io.IOException | ||
40 | { | ||
41 | int b; | ||
42 | |||
43 | if( iIn < 0 ) | ||
44 | { | ||
45 | iIn = -iIn; | ||
46 | b = (int)(iIn&0x3F); | ||
47 | if( iIn > b ) | ||
48 | b |= 0x80 | 0x40; | ||
49 | else | ||
50 | b |= 0x40; | ||
51 | } | ||
52 | else | ||
53 | { | ||
54 | b = (int)(iIn&0x3F); | ||
55 | if( iIn > b ) | ||
56 | b |= 0x80; | ||
57 | } | ||
58 | os.write( b ); | ||
59 | iIn = iIn >> 6; | ||
60 | |||
61 | while( iIn > 0 ) | ||
62 | { | ||
63 | b = (int)(iIn&0x7F); | ||
64 | if( iIn > b ) | ||
65 | b |= 0x80; | ||
66 | os.write( b ); | ||
67 | iIn = iIn >> 7; | ||
68 | } | ||
69 | } | ||
70 | }; | ||
71 | |||
diff --git a/java/com/xagasoft/gats/List.java b/java/com/xagasoft/gats/List.java new file mode 100644 index 0000000..99d10e9 --- /dev/null +++ b/java/com/xagasoft/gats/List.java | |||
@@ -0,0 +1,10 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class List extends Type | ||
4 | { | ||
5 | public int getType() | ||
6 | { | ||
7 | return Type.LIST; | ||
8 | } | ||
9 | }; | ||
10 | |||
diff --git a/java/com/xagasoft/gats/String.java b/java/com/xagasoft/gats/String.java new file mode 100644 index 0000000..b89d042 --- /dev/null +++ b/java/com/xagasoft/gats/String.java | |||
@@ -0,0 +1,10 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class String extends Type | ||
4 | { | ||
5 | public int getType() | ||
6 | { | ||
7 | return Type.STRING; | ||
8 | } | ||
9 | }; | ||
10 | |||
diff --git a/java/com/xagasoft/gats/Type.java b/java/com/xagasoft/gats/Type.java new file mode 100644 index 0000000..d6bff4d --- /dev/null +++ b/java/com/xagasoft/gats/Type.java | |||
@@ -0,0 +1,16 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public abstract class Type | ||
4 | { | ||
5 | public final static int INTEGER = 1; | ||
6 | public final static int FLOAT = 2; | ||
7 | public final static int STRING = 3; | ||
8 | public final static int LIST = 4; | ||
9 | public final static int DICTIONARY = 5; | ||
10 | public final static int BOOLEAN = 6; | ||
11 | |||
12 | public abstract int getType(); | ||
13 | |||
14 | |||
15 | }; | ||
16 | |||
diff --git a/java/default.bld b/java/default.bld new file mode 100644 index 0000000..ea35c78 --- /dev/null +++ b/java/default.bld | |||
@@ -0,0 +1,6 @@ | |||
1 | target "libgats.jar" | ||
2 | { | ||
3 | rule "jar"; | ||
4 | input files("com/xagasoft/gats/*.java"); | ||
5 | } | ||
6 | |||