aboutsummaryrefslogtreecommitdiff
path: root/java/com
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--java/com/xagasoft/gats/Boolean.java10
-rw-r--r--java/com/xagasoft/gats/Dictionary.java10
-rw-r--r--java/com/xagasoft/gats/Float.java10
-rw-r--r--java/com/xagasoft/gats/GatsStream.java6
-rw-r--r--java/com/xagasoft/gats/Integer.java71
-rw-r--r--java/com/xagasoft/gats/List.java10
-rw-r--r--java/com/xagasoft/gats/String.java10
-rw-r--r--java/com/xagasoft/gats/Type.java16
8 files changed, 143 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 @@
1package com.xagasoft.gats;
2
3public 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 @@
1package com.xagasoft.gats;
2
3public 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 @@
1package com.xagasoft.gats;
2
3public 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 @@
1package com.xagasoft.gats;
2
3public 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 @@
1package com.xagasoft.gats;
2
3import java.io.OutputStream;
4import java.io.InputStream;
5
6public 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 @@
1package com.xagasoft.gats;
2
3public 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 @@
1package com.xagasoft.gats;
2
3public 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 @@
1package com.xagasoft.gats;
2
3public 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