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/GatsString.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'java/com/xagasoft/gats/GatsString.java') diff --git a/java/com/xagasoft/gats/GatsString.java b/java/com/xagasoft/gats/GatsString.java index e512ade..e119aec 100644 --- a/java/com/xagasoft/gats/GatsString.java +++ b/java/com/xagasoft/gats/GatsString.java @@ -3,6 +3,17 @@ package com.xagasoft.gats; import java.io.InputStream; import java.io.OutputStream; +/** + * Represents a Gats string, that is, a string of 8-bit bytes. Unlike the + * standard Java string, a Gats string is a string of 8-bit bytes, not 16-bit + * UCS characters. If you want to transmit textual data, we highly recommend + * encoding it into UTF-8. You can do this by constructing a GatsString from + * a java string thusly: new GatsString( myStr.getBytes("UTF8") ) + *

+ * If you pass a java string into a GatsString instead of an array of bytes it + * will simply call the getBytes function. This may not be what you want in + * many cases, but will work great for simple cases. + */ public class GatsString extends GatsObject { private byte[] aValue = null; @@ -46,14 +57,14 @@ public class GatsString extends GatsObject return GatsObject.STRING; } - public void read( InputStream is, char cType ) throws java.io.IOException + void read( InputStream is, char cType ) throws java.io.IOException { long lSize = GatsInteger.readPackedInt( is ); aValue = new byte[(int)lSize]; is.read( aValue ); } - public void write( OutputStream os ) throws java.io.IOException + void write( OutputStream os ) throws java.io.IOException { os.write( (int)'s' ); if( aValue == null ) -- cgit v1.2.3