aboutsummaryrefslogtreecommitdiff
path: root/java/com/xagasoft/gats/GatsString.java
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-01-16 02:31:34 +0000
committerMike Buland <eichlan@xagasoft.com>2012-01-16 02:31:34 +0000
commite3efaf2a9ad82deb1644ccab8c1469719a0c5b65 (patch)
treedc1b3f3c787dd5900e80aaeca1a46cd9696d230b /java/com/xagasoft/gats/GatsString.java
parent66f972a288916824d9001c1931bf4c5db1bed82b (diff)
downloadlibgats-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/GatsString.java')
-rw-r--r--java/com/xagasoft/gats/GatsString.java15
1 files changed, 13 insertions, 2 deletions
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;
3import java.io.InputStream; 3import java.io.InputStream;
4import java.io.OutputStream; 4import java.io.OutputStream;
5 5
6/**
7 * Represents a Gats string, that is, a string of 8-bit bytes. Unlike the
8 * standard Java string, a Gats string is a string of 8-bit bytes, not 16-bit
9 * UCS characters. If you want to transmit textual data, we highly recommend
10 * encoding it into UTF-8. You can do this by constructing a GatsString from
11 * a java string thusly: new GatsString( myStr.getBytes("UTF8") )
12 * <p>
13 * If you pass a java string into a GatsString instead of an array of bytes it
14 * will simply call the getBytes function. This may not be what you want in
15 * many cases, but will work great for simple cases.
16 */
6public class GatsString extends GatsObject 17public class GatsString extends GatsObject
7{ 18{
8 private byte[] aValue = null; 19 private byte[] aValue = null;
@@ -46,14 +57,14 @@ public class GatsString extends GatsObject
46 return GatsObject.STRING; 57 return GatsObject.STRING;
47 } 58 }
48 59
49 public void read( InputStream is, char cType ) throws java.io.IOException 60 void read( InputStream is, char cType ) throws java.io.IOException
50 { 61 {
51 long lSize = GatsInteger.readPackedInt( is ); 62 long lSize = GatsInteger.readPackedInt( is );
52 aValue = new byte[(int)lSize]; 63 aValue = new byte[(int)lSize];
53 is.read( aValue ); 64 is.read( aValue );
54 } 65 }
55 66
56 public void write( OutputStream os ) throws java.io.IOException 67 void write( OutputStream os ) throws java.io.IOException
57 { 68 {
58 os.write( (int)'s' ); 69 os.write( (int)'s' );
59 if( aValue == null ) 70 if( aValue == null )