aboutsummaryrefslogtreecommitdiff
path: root/java/com/xagasoft
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-04-21 18:13:29 +0000
committerMike Buland <eichlan@xagasoft.com>2011-04-21 18:13:29 +0000
commitf0918e61039a18947a31efe01d23b7607acf9c92 (patch)
tree8fc4b6af2f20d45991ff99e77e72d1ac42d5d168 /java/com/xagasoft
parent2442c7203b480bb8517494c479f2f48fb7c82637 (diff)
downloadlibgats-f0918e61039a18947a31efe01d23b7607acf9c92.tar.gz
libgats-f0918e61039a18947a31efe01d23b7607acf9c92.tar.bz2
libgats-f0918e61039a18947a31efe01d23b7607acf9c92.tar.xz
libgats-f0918e61039a18947a31efe01d23b7607acf9c92.zip
Strings work now.
Diffstat (limited to 'java/com/xagasoft')
-rw-r--r--java/com/xagasoft/gats/GatsObject.java2
-rw-r--r--java/com/xagasoft/gats/GatsString.java51
2 files changed, 51 insertions, 2 deletions
diff --git a/java/com/xagasoft/gats/GatsObject.java b/java/com/xagasoft/gats/GatsObject.java
index 031dc90..1538c93 100644
--- a/java/com/xagasoft/gats/GatsObject.java
+++ b/java/com/xagasoft/gats/GatsObject.java
@@ -28,7 +28,7 @@ public abstract class GatsObject
28 break; 28 break;
29 29
30 case 's': 30 case 's':
31 // goRet = new GatsString(); 31 goRet = new GatsString();
32 break; 32 break;
33 33
34 case '0': 34 case '0':
diff --git a/java/com/xagasoft/gats/GatsString.java b/java/com/xagasoft/gats/GatsString.java
index 89edc21..e512ade 100644
--- a/java/com/xagasoft/gats/GatsString.java
+++ b/java/com/xagasoft/gats/GatsString.java
@@ -5,17 +5,66 @@ import java.io.OutputStream;
5 5
6public class GatsString extends GatsObject 6public class GatsString extends GatsObject
7{ 7{
8 private byte[] aValue = null;
9
10 public GatsString()
11 {
12 }
13
14 public GatsString( String sValue )
15 {
16 this.aValue = sValue.getBytes();
17 }
18
19 public GatsString( byte[] aValue )
20 {
21 this.aValue = aValue;
22 }
23
24 public byte[] getValue()
25 {
26 return aValue;
27 }
28
29 public void setValue( String sValue )
30 {
31 this.aValue = sValue.getBytes();
32 }
33
34 public void setValue( byte[] aValue )
35 {
36 this.aValue = aValue;
37 }
38
39 public String toString()
40 {
41 return new String( aValue );
42 }
43
8 public int getType() 44 public int getType()
9 { 45 {
10 return GatsObject.STRING; 46 return GatsObject.STRING;
11 } 47 }
12 48
13 public void read( InputStream is, char cType ) 49 public void read( InputStream is, char cType ) throws java.io.IOException
14 { 50 {
51 long lSize = GatsInteger.readPackedInt( is );
52 aValue = new byte[(int)lSize];
53 is.read( aValue );
15 } 54 }
16 55
17 public void write( OutputStream os ) throws java.io.IOException 56 public void write( OutputStream os ) throws java.io.IOException
18 { 57 {
58 os.write( (int)'s' );
59 if( aValue == null )
60 {
61 GatsInteger.writePackedInt( os, 0 );
62 }
63 else
64 {
65 GatsInteger.writePackedInt( os, aValue.length );
66 os.write( aValue );
67 }
19 } 68 }
20}; 69};
21 70