diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-01-16 02:31:34 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-01-16 02:31:34 +0000 |
commit | e3efaf2a9ad82deb1644ccab8c1469719a0c5b65 (patch) | |
tree | dc1b3f3c787dd5900e80aaeca1a46cd9696d230b /java/com/xagasoft/gats/GatsObject.java | |
parent | 66f972a288916824d9001c1931bf4c5db1bed82b (diff) | |
download | libgats-e3efaf2a9ad82deb1644ccab8c1469719a0c5b65.tar.gz libgats-e3efaf2a9ad82deb1644ccab8c1469719a0c5b65.tar.bz2 libgats-e3efaf2a9ad82deb1644ccab8c1469719a0c5b65.tar.xz libgats-e3efaf2a9ad82deb1644ccab8c1469719a0c5b65.zip |
Lots of documentation, an example program, and also some visibility cleanup.
Diffstat (limited to 'java/com/xagasoft/gats/GatsObject.java')
-rw-r--r-- | java/com/xagasoft/gats/GatsObject.java | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/java/com/xagasoft/gats/GatsObject.java b/java/com/xagasoft/gats/GatsObject.java index 8c398e8..fc3fb5a 100644 --- a/java/com/xagasoft/gats/GatsObject.java +++ b/java/com/xagasoft/gats/GatsObject.java | |||
@@ -3,6 +3,13 @@ package com.xagasoft.gats; | |||
3 | import java.io.InputStream; | 3 | import java.io.InputStream; |
4 | import java.io.OutputStream; | 4 | import java.io.OutputStream; |
5 | 5 | ||
6 | /** | ||
7 | * The abstract base class of all Gats storage classes. You probably don't | ||
8 | * need to worry about these functions at all, maybe getType. The IO functions | ||
9 | * in this class shouldn't really be used since they won't contain the proper | ||
10 | * packet header info. See com.xagasoft.gats.GatsOutputStream and | ||
11 | * com.xagasoft.gats.GatsInputStream for that. | ||
12 | */ | ||
6 | public abstract class GatsObject | 13 | public abstract class GatsObject |
7 | { | 14 | { |
8 | public final static int INTEGER = 1; | 15 | public final static int INTEGER = 1; |
@@ -12,12 +19,29 @@ public abstract class GatsObject | |||
12 | public final static int DICTIONARY = 5; | 19 | public final static int DICTIONARY = 5; |
13 | public final static int BOOLEAN = 6; | 20 | public final static int BOOLEAN = 6; |
14 | 21 | ||
22 | /** | ||
23 | * Gets the type of the current object, type can be one of INTEGER, FLOAT, | ||
24 | * STRING, LIST, DICTIONARY, or BOOLEAN. | ||
25 | */ | ||
15 | public abstract int getType(); | 26 | public abstract int getType(); |
16 | 27 | ||
17 | public abstract void read( InputStream is, char cType ) throws java.io.IOException; | 28 | /** |
18 | public abstract void write( OutputStream os ) throws java.io.IOException; | 29 | * Read an object from the given input stream, with a particular type, this |
30 | * function is used internally. | ||
31 | */ | ||
32 | abstract void read( InputStream is, char cType ) throws java.io.IOException; | ||
19 | 33 | ||
20 | public static GatsObject read( InputStream is ) throws java.io.IOException | 34 | /** |
35 | * Write the current object to the output stream. | ||
36 | */ | ||
37 | abstract void write( OutputStream os ) throws java.io.IOException; | ||
38 | |||
39 | /** | ||
40 | * Static function that returns a new object deserialized from an input | ||
41 | * stream. This still doesn't take advantage of packet data, so you | ||
42 | * probably shouldn't use this yourself. | ||
43 | */ | ||
44 | static GatsObject read( InputStream is ) throws java.io.IOException | ||
21 | { | 45 | { |
22 | char type = (char)is.read(); | 46 | char type = (char)is.read(); |
23 | GatsObject goRet = null; | 47 | GatsObject goRet = null; |