summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authoreea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-11 19:50:25 +0000
committereea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-11 19:50:25 +0000
commitdfcfa53f0cbb9cb3dbe3360d09f3d02c8843bd03 (patch)
tree96817ac78a56aea6792f9d0c5408c342f3e54b9d /java
parentf41a0e16183e20810a315d91ed44b634287bae1d (diff)
downloadATCD-dfcfa53f0cbb9cb3dbe3360d09f3d02c8843bd03.tar.gz
Finally changes SOCKStream so it doesn't have all the deprecation warnings.
It's also a lot easier to understand since I use DataInputStreams and DataOutputStreams. NOTE: We can't use the Reader/Writer Java classes since they don't allow reading/writing bytes without losing C++ compatibility.
Diffstat (limited to 'java')
-rw-r--r--java/src/SOCKStream.java30
-rw-r--r--java/src/ServiceConfig.java7
2 files changed, 24 insertions, 13 deletions
diff --git a/java/src/SOCKStream.java b/java/src/SOCKStream.java
index 017c2e0e24e..f255b7bc44a 100644
--- a/java/src/SOCKStream.java
+++ b/java/src/SOCKStream.java
@@ -57,7 +57,7 @@ public class SOCKStream
this.iStream_ = new DataInputStream(new BufferedInputStream(s.getInputStream()));
- this.oStream_ = new PrintStream(new DataOutputStream(new BufferedOutputStream(s.getOutputStream())));
+ this.oStream_ = new DataOutputStream(new BufferedOutputStream(s.getOutputStream()));
}
/* Get the underlying Socket.
@@ -91,7 +91,9 @@ public class SOCKStream
// Get the data out
String buf = s.toString ();
- this.oStream_.println(buf);
+ //this.oStream_.println(buf);
+ this.oStream_.writeChars(buf.toString());
+ this.oStream_.writeChar('\n');
this.oStream_.flush ();
return buf.length ();
@@ -104,7 +106,10 @@ public class SOCKStream
*/
public int send (String s) throws IOException
{
- this.oStream_.println(s);
+ this.oStream_.writeChars(s);
+ this.oStream_.writeChar('\n');
+
+ //this.oStream_.println(s);
this.oStream_.flush();
return s.length ();
@@ -132,13 +137,16 @@ public class SOCKStream
*/
public int recv (StringBuffer s) throws IOException
{
- String temp = this.iStream_.readLine ();
- s.append (temp);
+ int len = 0;
+ char in = (char)this.iStream_.readByte();
+
+ while (in != '\n') {
+ s.append(in);
+ in = (char)this.iStream_.readByte();
+ len++;
+ }
- if (temp == null) // Possible if user sends just a line feed, but
- return -1; // not checking would cause a null ptr exception
- else
- return temp.length ();
+ return len;
}
/**
@@ -180,7 +188,7 @@ public class SOCKStream
*/
public void outputStream (OutputStream oStream)
{
- this.oStream_ = new PrintStream(new DataOutputStream(new BufferedOutputStream(oStream)));
+ this.oStream_ = new DataOutputStream(new BufferedOutputStream(oStream));
}
/**
@@ -206,5 +214,5 @@ public class SOCKStream
// = The input and output streams (by default null)
private DataInputStream iStream_;
- private PrintStream oStream_;
+ private DataOutputStream oStream_;
}
diff --git a/java/src/ServiceConfig.java b/java/src/ServiceConfig.java
index e4d5b966d5f..ac5b7f48650 100644
--- a/java/src/ServiceConfig.java
+++ b/java/src/ServiceConfig.java
@@ -210,8 +210,10 @@ public class ServiceConfig
if (in.ttype == StreamTokenizer.TT_WORD) {
commandName = in.sval;
- // This is a hack, but it should work until CUP is easier
- // to deal with when multiple parsers are needed
+ // **** This should be changed so that instantiation is only done
+ // when we find out the type (ServiceObject or something else) a few
+ // words later. Right now it works because we only have ServiceObjects
+ // to load.
if (commandName.equals("load"))
result = new AddServiceObjectNode();
else
@@ -256,6 +258,7 @@ public class ServiceConfig
state = ServiceConfig.CLASS_TYPE;
break;
case ServiceConfig.CLASS_TYPE:
+ // This is only Service_Object or ServiceObject at this time
if (in.ttype == StreamTokenizer.TT_WORD)
classType = in.sval;
else