From e3efaf2a9ad82deb1644ccab8c1469719a0c5b65 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 16 Jan 2012 02:31:34 +0000 Subject: Lots of documentation, an example program, and also some visibility cleanup. --- java/com/xagasoft/gats/GatsObject.java | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'java/com/xagasoft/gats/GatsObject.java') 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; import java.io.InputStream; import java.io.OutputStream; +/** + * The abstract base class of all Gats storage classes. You probably don't + * need to worry about these functions at all, maybe getType. The IO functions + * in this class shouldn't really be used since they won't contain the proper + * packet header info. See com.xagasoft.gats.GatsOutputStream and + * com.xagasoft.gats.GatsInputStream for that. + */ public abstract class GatsObject { public final static int INTEGER = 1; @@ -12,12 +19,29 @@ public abstract class GatsObject public final static int DICTIONARY = 5; public final static int BOOLEAN = 6; + /** + * Gets the type of the current object, type can be one of INTEGER, FLOAT, + * STRING, LIST, DICTIONARY, or BOOLEAN. + */ public abstract int getType(); - public abstract void read( InputStream is, char cType ) throws java.io.IOException; - public abstract void write( OutputStream os ) throws java.io.IOException; + /** + * Read an object from the given input stream, with a particular type, this + * function is used internally. + */ + abstract void read( InputStream is, char cType ) throws java.io.IOException; - public static GatsObject read( InputStream is ) throws java.io.IOException + /** + * Write the current object to the output stream. + */ + abstract void write( OutputStream os ) throws java.io.IOException; + + /** + * Static function that returns a new object deserialized from an input + * stream. This still doesn't take advantage of packet data, so you + * probably shouldn't use this yourself. + */ + static GatsObject read( InputStream is ) throws java.io.IOException { char type = (char)is.read(); GatsObject goRet = null; -- cgit v1.2.3