aboutsummaryrefslogtreecommitdiff
path: root/java/com/xagasoft/gats/GatsInteger.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--java/com/xagasoft/gats/GatsInteger.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/java/com/xagasoft/gats/GatsInteger.java b/java/com/xagasoft/gats/GatsInteger.java
index 139e8ab..0ea5122 100644
--- a/java/com/xagasoft/gats/GatsInteger.java
+++ b/java/com/xagasoft/gats/GatsInteger.java
@@ -3,6 +3,10 @@ package com.xagasoft.gats;
3import java.io.OutputStream; 3import java.io.OutputStream;
4import java.io.InputStream; 4import java.io.InputStream;
5 5
6/**
7 * Represents a simple java long value. This does not handle arbitrary
8 * precision integer values, a class to handle that is forthcoming.
9 */
6public class GatsInteger extends GatsObject 10public class GatsInteger extends GatsObject
7{ 11{
8 private long iValue = 0; 12 private long iValue = 0;
@@ -36,19 +40,23 @@ public class GatsInteger extends GatsObject
36 return GatsObject.INTEGER; 40 return GatsObject.INTEGER;
37 }; 41 };
38 42
39 public void read( InputStream is, char cType ) throws java.io.IOException 43 void read( InputStream is, char cType ) throws java.io.IOException
40 44
41 { 45 {
42 iValue = readPackedInt( is ); 46 iValue = readPackedInt( is );
43 } 47 }
44 48
45 public void write( OutputStream os ) throws java.io.IOException 49 void write( OutputStream os ) throws java.io.IOException
46 { 50 {
47 os.write( (int)'i' ); 51 os.write( (int)'i' );
48 writePackedInt( os, iValue ); 52 writePackedInt( os, iValue );
49 } 53 }
50 54
51 /** 55 /**
56 * This is a general helper function used by several parts of the Gats
57 * system.
58 * It reads a "packed integer" from the given input stream, and returns the
59 * value.
52 * Possible TODO: have this return a Number, and construct either a Long 60 * Possible TODO: have this return a Number, and construct either a Long
53 * or BigInteger when appropriate. 61 * or BigInteger when appropriate.
54 */ 62 */
@@ -72,6 +80,11 @@ public class GatsInteger extends GatsObject
72 return rOut; 80 return rOut;
73 } 81 }
74 82
83 /**
84 * This is a general helper function used by several parts of the Gats
85 * system.
86 * It writes a "packed integer" to the given output stream.
87 */
75 public static void writePackedInt( OutputStream os, long iIn ) throws java.io.IOException 88 public static void writePackedInt( OutputStream os, long iIn ) throws java.io.IOException
76 { 89 {
77 int b; 90 int b;