diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-04-21 17:40:13 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-04-21 17:40:13 +0000 |
commit | 4fb4a056c52d3a96b6ef9a4ceb5ce39fc716a9aa (patch) | |
tree | 138b749f3e209d61a63abd1258947850404ca87d /java/com/xagasoft/gats | |
parent | 49216a230c331791b06df1527c3245c88e991c20 (diff) | |
download | libgats-4fb4a056c52d3a96b6ef9a4ceb5ce39fc716a9aa.tar.gz libgats-4fb4a056c52d3a96b6ef9a4ceb5ce39fc716a9aa.tar.bz2 libgats-4fb4a056c52d3a96b6ef9a4ceb5ce39fc716a9aa.tar.xz libgats-4fb4a056c52d3a96b6ef9a4ceb5ce39fc716a9aa.zip |
It...builds?
Diffstat (limited to 'java/com/xagasoft/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/GatsBoolean.java | 17 | ||||
-rw-r--r-- | java/com/xagasoft/gats/GatsDictionary.java | 17 | ||||
-rw-r--r-- | java/com/xagasoft/gats/GatsFloat.java | 17 | ||||
-rw-r--r-- | java/com/xagasoft/gats/GatsInputStream.java | 22 | ||||
-rw-r--r-- | java/com/xagasoft/gats/GatsInteger.java (renamed from java/com/xagasoft/gats/Integer.java) | 43 | ||||
-rw-r--r-- | java/com/xagasoft/gats/GatsList.java | 17 | ||||
-rw-r--r-- | java/com/xagasoft/gats/GatsObject.java | 23 | ||||
-rw-r--r-- | java/com/xagasoft/gats/GatsOutputStream.java | 4 | ||||
-rw-r--r-- | java/com/xagasoft/gats/GatsString.java | 17 | ||||
-rw-r--r-- | java/com/xagasoft/gats/List.java | 10 | ||||
-rw-r--r-- | java/com/xagasoft/gats/String.java | 10 |
14 files changed, 148 insertions, 79 deletions
diff --git a/java/com/xagasoft/gats/Boolean.java b/java/com/xagasoft/gats/Boolean.java deleted file mode 100644 index 692247a..0000000 --- a/java/com/xagasoft/gats/Boolean.java +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class Boolean extends GatsObject | ||
4 | { | ||
5 | public int getGatsObject() | ||
6 | { | ||
7 | return GatsObject.BOOLEAN; | ||
8 | } | ||
9 | }; | ||
10 | |||
diff --git a/java/com/xagasoft/gats/Dictionary.java b/java/com/xagasoft/gats/Dictionary.java deleted file mode 100644 index d96ff76..0000000 --- a/java/com/xagasoft/gats/Dictionary.java +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class Dictionary extends GatsObject | ||
4 | { | ||
5 | public int getGatsObject() | ||
6 | { | ||
7 | return GatsObject.DICTIONARY; | ||
8 | } | ||
9 | }; | ||
10 | |||
diff --git a/java/com/xagasoft/gats/Float.java b/java/com/xagasoft/gats/Float.java deleted file mode 100644 index d0a9604..0000000 --- a/java/com/xagasoft/gats/Float.java +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class Float extends GatsObject | ||
4 | { | ||
5 | public int getGatsObject() | ||
6 | { | ||
7 | return GatsObject.FLOAT; | ||
8 | } | ||
9 | }; | ||
10 | |||
diff --git a/java/com/xagasoft/gats/GatsBoolean.java b/java/com/xagasoft/gats/GatsBoolean.java new file mode 100644 index 0000000..8fec64a --- /dev/null +++ b/java/com/xagasoft/gats/GatsBoolean.java | |||
@@ -0,0 +1,17 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | import java.io.InputStream; | ||
4 | import java.io.OutputStream; | ||
5 | |||
6 | public class GatsBoolean extends GatsObject | ||
7 | { | ||
8 | public int getType() | ||
9 | { | ||
10 | return GatsObject.BOOLEAN; | ||
11 | } | ||
12 | |||
13 | public void read( InputStream is, char cType ) | ||
14 | { | ||
15 | } | ||
16 | }; | ||
17 | |||
diff --git a/java/com/xagasoft/gats/GatsDictionary.java b/java/com/xagasoft/gats/GatsDictionary.java new file mode 100644 index 0000000..1cf126e --- /dev/null +++ b/java/com/xagasoft/gats/GatsDictionary.java | |||
@@ -0,0 +1,17 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | import java.io.InputStream; | ||
4 | import java.io.OutputStream; | ||
5 | |||
6 | public class GatsDictionary extends GatsObject | ||
7 | { | ||
8 | public int getType() | ||
9 | { | ||
10 | return GatsObject.DICTIONARY; | ||
11 | } | ||
12 | |||
13 | public void read( InputStream is, char cType ) | ||
14 | { | ||
15 | } | ||
16 | }; | ||
17 | |||
diff --git a/java/com/xagasoft/gats/GatsFloat.java b/java/com/xagasoft/gats/GatsFloat.java new file mode 100644 index 0000000..b98c73a --- /dev/null +++ b/java/com/xagasoft/gats/GatsFloat.java | |||
@@ -0,0 +1,17 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | import java.io.InputStream; | ||
4 | import java.io.OutputStream; | ||
5 | |||
6 | public class GatsFloat extends GatsObject | ||
7 | { | ||
8 | public int getType() | ||
9 | { | ||
10 | return GatsObject.FLOAT; | ||
11 | } | ||
12 | |||
13 | public void read( InputStream is, char cType ) | ||
14 | { | ||
15 | } | ||
16 | }; | ||
17 | |||
diff --git a/java/com/xagasoft/gats/GatsInputStream.java b/java/com/xagasoft/gats/GatsInputStream.java index e787d56..e1c4781 100644 --- a/java/com/xagasoft/gats/GatsInputStream.java +++ b/java/com/xagasoft/gats/GatsInputStream.java | |||
@@ -2,6 +2,7 @@ package com.xagasoft.gats; | |||
2 | 2 | ||
3 | import java.io.InputStream; | 3 | import java.io.InputStream; |
4 | import java.io.ByteArrayOutputStream; | 4 | import java.io.ByteArrayOutputStream; |
5 | import java.io.ByteArrayInputStream; | ||
5 | import java.io.DataInputStream; | 6 | import java.io.DataInputStream; |
6 | 7 | ||
7 | public class GatsInputStream | 8 | public class GatsInputStream |
@@ -16,7 +17,7 @@ public class GatsInputStream | |||
16 | this.is = is; | 17 | this.is = is; |
17 | } | 18 | } |
18 | 19 | ||
19 | public GatsObject readObject() | 20 | public GatsObject readObject() throws java.io.IOException |
20 | { | 21 | { |
21 | do | 22 | do |
22 | { | 23 | { |
@@ -24,7 +25,7 @@ public class GatsInputStream | |||
24 | { | 25 | { |
25 | byte aBuf[] = new byte[5-baos.size()]; | 26 | byte aBuf[] = new byte[5-baos.size()]; |
26 | int iRead = is.read( aBuf ); | 27 | int iRead = is.read( aBuf ); |
27 | baos.write( ret, iRead ); | 28 | baos.write( aBuf, 0, iRead ); |
28 | 29 | ||
29 | if( baos.size() < 5 ) | 30 | if( baos.size() < 5 ) |
30 | return null; | 31 | return null; |
@@ -36,7 +37,7 @@ public class GatsInputStream | |||
36 | ByteArrayInputStream bais = new ByteArrayInputStream( | 37 | ByteArrayInputStream bais = new ByteArrayInputStream( |
37 | baos.toByteArray() | 38 | baos.toByteArray() |
38 | ); | 39 | ); |
39 | DataInputStream dis( bais ); | 40 | DataInputStream dis = new DataInputStream( bais ); |
40 | iVer = dis.readUnsignedByte(); | 41 | iVer = dis.readUnsignedByte(); |
41 | iSize = dis.readInt(); | 42 | iSize = dis.readInt(); |
42 | } | 43 | } |
@@ -49,7 +50,7 @@ public class GatsInputStream | |||
49 | iGoal = 1500; | 50 | iGoal = 1500; |
50 | 51 | ||
51 | int iRead = is.read( aBuf ); | 52 | int iRead = is.read( aBuf ); |
52 | baos.write( abuf, 0, iRead ); | 53 | baos.write( aBuf, 0, iRead ); |
53 | 54 | ||
54 | if( iRead < iGoal ) | 55 | if( iRead < iGoal ) |
55 | return null; | 56 | return null; |
@@ -63,14 +64,13 @@ public class GatsInputStream | |||
63 | ); | 64 | ); |
64 | bais.skip( 5 ); | 65 | bais.skip( 5 ); |
65 | 66 | ||
66 | GatsObject goRet = GatsObject::read( bais ); | 67 | GatsObject goRet = GatsObject.read( bais ); |
67 | iVer = 0; | 68 | iVer = 0; |
68 | 69 | ||
69 | return goRet; | 70 | return goRet; |
70 | } | 71 | } |
71 | 72 | ||
72 | 73 | private boolean skipReadNulls() | |
73 | private bool skipReadNulls() | ||
74 | { | 74 | { |
75 | if( baos.size() == 0 ) | 75 | if( baos.size() == 0 ) |
76 | return false; | 76 | return false; |
@@ -79,17 +79,17 @@ public class GatsInputStream | |||
79 | if( aBuf[0] != 0 ) | 79 | if( aBuf[0] != 0 ) |
80 | return true; | 80 | return true; |
81 | 81 | ||
82 | for( int j = 1; j < aBuf.size; j++ ) | 82 | for( int j = 1; j < aBuf.length; j++ ) |
83 | { | 83 | { |
84 | if( aBuf[j] != 0 ) | 84 | if( aBuf[j] != 0 ) |
85 | { | 85 | { |
86 | baos.clear(); | 86 | baos.reset(); |
87 | baos.write( aBuf, j, aBuf.size-j ); | 87 | baos.write( aBuf, j, aBuf.length-j ); |
88 | return true; | 88 | return true; |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | baos.clear(); | 92 | baos.reset(); |
93 | return true; | 93 | return true; |
94 | } | 94 | } |
95 | }; | 95 | }; |
diff --git a/java/com/xagasoft/gats/Integer.java b/java/com/xagasoft/gats/GatsInteger.java index ab3d6de..1093ab2 100644 --- a/java/com/xagasoft/gats/Integer.java +++ b/java/com/xagasoft/gats/GatsInteger.java | |||
@@ -3,19 +3,51 @@ package com.xagasoft.gats; | |||
3 | import java.io.OutputStream; | 3 | import java.io.OutputStream; |
4 | import java.io.InputStream; | 4 | import java.io.InputStream; |
5 | 5 | ||
6 | public class Integer extends GatsObject | 6 | public class GatsInteger extends GatsObject |
7 | { | 7 | { |
8 | public int getGatsObject() | 8 | private long iValue = 0; |
9 | |||
10 | public GatsInteger() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | public GatsInteger( long iValue ) | ||
15 | { | ||
16 | this.iValue = iValue; | ||
17 | } | ||
18 | |||
19 | public long getValue() | ||
20 | { | ||
21 | return iValue; | ||
22 | } | ||
23 | |||
24 | public void setValue( long iValue ) | ||
25 | { | ||
26 | this.iValue = iValue; | ||
27 | } | ||
28 | |||
29 | public int getType() | ||
9 | { | 30 | { |
10 | return GatsObject.INTEGER; | 31 | return GatsObject.INTEGER; |
11 | }; | 32 | }; |
12 | 33 | ||
34 | public void read( InputStream is, char cType ) throws java.io.IOException | ||
35 | |||
36 | { | ||
37 | iValue = readPackedInt( is ); | ||
38 | } | ||
39 | |||
40 | public void write( OutputStream os ) throws java.io.IOException | ||
41 | { | ||
42 | os.write( (int)'i' ); | ||
43 | writePackedInt( os, iValue ); | ||
44 | } | ||
45 | |||
13 | /** | 46 | /** |
14 | * Possible TODO: have this return a Number, and construct either a Long | 47 | * Possible TODO: have this return a Number, and construct either a Long |
15 | * or BigInteger when appropriate. | 48 | * or BigInteger when appropriate. |
16 | */ | 49 | */ |
17 | public static long readPackedInt( InputStream is ) | 50 | public static long readPackedInt( InputStream is ) throws java.io.IOException |
18 | throws java.io.IOException | ||
19 | { | 51 | { |
20 | int b; | 52 | int b; |
21 | long rOut = 0; | 53 | long rOut = 0; |
@@ -35,8 +67,7 @@ public class Integer extends GatsObject | |||
35 | return rOut; | 67 | return rOut; |
36 | } | 68 | } |
37 | 69 | ||
38 | public static void writePackedInt( OutputStream os, long iIn ) | 70 | public static void writePackedInt( OutputStream os, long iIn ) throws java.io.IOException |
39 | throws java.io.IOException | ||
40 | { | 71 | { |
41 | int b; | 72 | int b; |
42 | 73 | ||
diff --git a/java/com/xagasoft/gats/GatsList.java b/java/com/xagasoft/gats/GatsList.java new file mode 100644 index 0000000..7c238be --- /dev/null +++ b/java/com/xagasoft/gats/GatsList.java | |||
@@ -0,0 +1,17 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | import java.io.InputStream; | ||
4 | import java.io.OutputStream; | ||
5 | |||
6 | public class GatsList extends GatsObject | ||
7 | { | ||
8 | public int getType() | ||
9 | { | ||
10 | return GatsObject.LIST; | ||
11 | } | ||
12 | |||
13 | public void read( InputStream is, char cType ) | ||
14 | { | ||
15 | } | ||
16 | }; | ||
17 | |||
diff --git a/java/com/xagasoft/gats/GatsObject.java b/java/com/xagasoft/gats/GatsObject.java index 63fcf36..852a18c 100644 --- a/java/com/xagasoft/gats/GatsObject.java +++ b/java/com/xagasoft/gats/GatsObject.java | |||
@@ -1,6 +1,7 @@ | |||
1 | package com.xagasoft.gats; | 1 | package com.xagasoft.gats; |
2 | 2 | ||
3 | import java.io.InputStream; | 3 | import java.io.InputStream; |
4 | import java.io.OutputStream; | ||
4 | 5 | ||
5 | public abstract class GatsObject | 6 | public abstract class GatsObject |
6 | { | 7 | { |
@@ -13,45 +14,45 @@ public abstract class GatsObject | |||
13 | 14 | ||
14 | public abstract int getType(); | 15 | public abstract int getType(); |
15 | 16 | ||
16 | public abstract void read( InputStream is, char cType ); | 17 | public abstract void read( InputStream is, char cType ) throws java.io.IOException; |
17 | 18 | ||
18 | public static GatsObject read( InputStream is ) | 19 | public static GatsObject read( InputStream is ) throws java.io.IOException |
19 | { | 20 | { |
20 | char type = is.read(); | 21 | char type = (char)is.read(); |
21 | GatsObject goRet; | 22 | GatsObject goRet = null; |
22 | switch( type ) | 23 | switch( type ) |
23 | { | 24 | { |
24 | case 'i': | 25 | case 'i': |
25 | goRet = new Integer(); | 26 | goRet = new GatsInteger(); |
26 | break; | 27 | break; |
27 | 28 | ||
28 | case 's': | 29 | case 's': |
29 | goRet = new String(); | 30 | // goRet = new GatsString(); |
30 | break; | 31 | break; |
31 | 32 | ||
32 | case '0': | 33 | case '0': |
33 | case '1': | 34 | case '1': |
34 | goRet = new Boolean(); | 35 | // goRet = new GatsBoolean(); |
35 | break; | 36 | break; |
36 | 37 | ||
37 | case 'l': | 38 | case 'l': |
38 | goRet = new List(); | 39 | // goRet = new GatsList(); |
39 | break; | 40 | break; |
40 | 41 | ||
41 | case 'd': | 42 | case 'd': |
42 | goRet = new Dictionary(); | 43 | // goRet = new GatsDictionary(); |
43 | break; | 44 | break; |
44 | 45 | ||
45 | case 'f': | 46 | case 'f': |
46 | case 'F': | 47 | case 'F': |
47 | goRet = new Float(); | 48 | // goRet = new GatsFloat(); |
48 | break; | 49 | break; |
49 | 50 | ||
50 | case 'e': | 51 | case 'e': |
51 | return null; | 52 | return null; |
52 | 53 | ||
53 | default: | 54 | default: |
54 | throw new Exception("Invalid gats type discovered: " + (char)type ); | 55 | throw new java.io.IOException("Invalid gats type discovered: " + (char)type ); |
55 | } | 56 | } |
56 | 57 | ||
57 | goRet.read( is, type ); | 58 | goRet.read( is, type ); |
diff --git a/java/com/xagasoft/gats/GatsOutputStream.java b/java/com/xagasoft/gats/GatsOutputStream.java index f3020f4..0ba452d 100644 --- a/java/com/xagasoft/gats/GatsOutputStream.java +++ b/java/com/xagasoft/gats/GatsOutputStream.java | |||
@@ -1,7 +1,9 @@ | |||
1 | package com.xagasoft.gats; | 1 | package com.xagasoft.gats; |
2 | 2 | ||
3 | import java.io.InputStream; | ||
4 | import java.io.OutputStream; | ||
5 | |||
3 | public class GatsOutputStream | 6 | public class GatsOutputStream |
4 | { | 7 | { |
5 | public GatsOutputStream( | ||
6 | }; | 8 | }; |
7 | 9 | ||
diff --git a/java/com/xagasoft/gats/GatsString.java b/java/com/xagasoft/gats/GatsString.java new file mode 100644 index 0000000..07456b5 --- /dev/null +++ b/java/com/xagasoft/gats/GatsString.java | |||
@@ -0,0 +1,17 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | import java.io.InputStream; | ||
4 | import java.io.OutputStream; | ||
5 | |||
6 | public class GatsString extends GatsObject | ||
7 | { | ||
8 | public int getType() | ||
9 | { | ||
10 | return GatsObject.STRING; | ||
11 | } | ||
12 | |||
13 | public void read( InputStream is, char cType ) | ||
14 | { | ||
15 | } | ||
16 | }; | ||
17 | |||
diff --git a/java/com/xagasoft/gats/List.java b/java/com/xagasoft/gats/List.java deleted file mode 100644 index dbc729b..0000000 --- a/java/com/xagasoft/gats/List.java +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class List extends GatsObject | ||
4 | { | ||
5 | public int getGatsObject() | ||
6 | { | ||
7 | return GatsObject.LIST; | ||
8 | } | ||
9 | }; | ||
10 | |||
diff --git a/java/com/xagasoft/gats/String.java b/java/com/xagasoft/gats/String.java deleted file mode 100644 index 301a98a..0000000 --- a/java/com/xagasoft/gats/String.java +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | package com.xagasoft.gats; | ||
2 | |||
3 | public class String extends GatsObject | ||
4 | { | ||
5 | public int getGatsObject() | ||
6 | { | ||
7 | return GatsObject.STRING; | ||
8 | } | ||
9 | }; | ||
10 | |||