aboutsummaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to '')
-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