[Webfunds-commits] java/webfunds/ricardian Contract.java DirContractStore.java DirSOXStore.java SOXServer.java

Ian Grigg iang@cypherpunks.ai
Thu, 12 Apr 2001 00:57:55 -0400 (AST)


iang        01/04/12 00:57:54

  Modified:    webfunds/ricardian Contract.java DirContractStore.java
                        DirSOXStore.java SOXServer.java
  Log:
  fixed for working with Log, as replacement for PrintWriter

Revision  Changes    Path
1.54      +3 -3      java/webfunds/ricardian/Contract.java

Index: Contract.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/Contract.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- Contract.java	2001/04/06 22:36:41	1.53
+++ Contract.java	2001/04/12 04:57:53	1.54
@@ -1,4 +1,4 @@
-/* $Id: Contract.java,v 1.53 2001/04/06 22:36:41 iang Exp $
+/* $Id: Contract.java,v 1.54 2001/04/12 04:57:53 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -13,7 +13,6 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.PrintStream;
-import java.io.PrintWriter;
 import java.net.URL;
 import java.net.MalformedURLException;
 import java.security.KeyException;
@@ -38,6 +37,7 @@
 import java.io.OutputStreamWriter;
 
 import webfunds.util.Armoury;
+import webfunds.util.Log;
 
 import webfunds.util.IniFileReader;
 import webfunds.util.FormattedFileException;
@@ -1818,7 +1818,7 @@
         }
         File fil = new File(arg[0]);
         Contract con = Contract.getContract(fil);
-        con.debug(new PrintWriter(System.err, true));
+        con.debug(new Log());
 
         System.err.println("Contract Read:" + con.getClass());
         System.err.println("Name is " + con.getName());



1.21      +4 -5      java/webfunds/ricardian/DirContractStore.java

Index: DirContractStore.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/DirContractStore.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- DirContractStore.java	2001/04/06 22:32:49	1.20
+++ DirContractStore.java	2001/04/12 04:57:54	1.21
@@ -1,5 +1,5 @@
 /*
- * $Id: DirContractStore.java,v 1.20 2001/04/06 22:32:49 iang Exp $
+ * $Id: DirContractStore.java,v 1.21 2001/04/12 04:57:54 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -8,7 +8,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.io.PrintWriter;
 
 import java.util.Hashtable;
 import java.util.Stack;
@@ -16,6 +15,7 @@
 
 import java.net.URL;
 
+import webfunds.util.Log;
 import webfunds.util.Panic;
 
 import webfunds.sox.*;
@@ -98,7 +98,7 @@
      * @param storedir a directory with contracts
      * @param bug place to put debugging during construction
      */
-    public DirContractStore(File storedir, PrintWriter bug)
+    public DirContractStore(File storedir, Log bug)
         throws ContractDirectoryException
     {
         debug(bug, "     Cons; ");
@@ -622,9 +622,8 @@
         }
 
         File d = new File(arg[0]);
-        PrintWriter bug = new PrintWriter(System.err, true);
+        Log bug = new Log();
         DirContractStore store = new DirContractStore(d, bug);
-        // store.debug(new PrintWriter(System.err, true));
 
         System.err.println("Started: " + store);
         Contract[] cons = store.getAllContracts();



1.17      +7 -7      java/webfunds/ricardian/DirSOXStore.java

Index: DirSOXStore.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/DirSOXStore.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- DirSOXStore.java	2001/04/06 22:41:06	1.16
+++ DirSOXStore.java	2001/04/12 04:57:54	1.17
@@ -1,5 +1,5 @@
 /*
- * $Id: DirSOXStore.java,v 1.16 2001/04/06 22:41:06 iang Exp $
+ * $Id: DirSOXStore.java,v 1.17 2001/04/12 04:57:54 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -8,7 +8,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.io.PrintWriter;
 
 import java.util.Hashtable;
 import java.util.Stack;
@@ -17,6 +16,7 @@
 import java.net.URL;
 import java.net.MalformedURLException;
 
+import webfunds.util.Log;
 import webfunds.utils.Debug;
 
 import webfunds.comms.CommsManager;
@@ -85,7 +85,7 @@
      * @param storedir a directory with server files
      * @param bug place to put debugging during construction
      */
-    public DirSOXStore(File dir, PrintWriter bug)
+    public DirSOXStore(File dir, Log bug)
     {
         debug(bug, "      dS: ");
         initHashtables();
@@ -135,7 +135,7 @@
             {
                 SOXServer soxfile;
                 try {
-                    soxfile = SOXServer.getInstance(f, getDebug());
+                    soxfile = SOXServer.getInstance(f, getLog());
                 } catch (SOXServerException ex) {
                     ex.printStackTrace(System.err);
                     logmsg("removing " + name);
@@ -398,7 +398,7 @@
             if (url == null)
                 continue ;
 
-            sox = SOXServer.getInstance(url, comms, getDebug());
+            sox = SOXServer.getInstance(url, comms, getLog());
             if (sox != null)
                 return sox ;
             // might want to keep searching here, if we are refreshing
@@ -418,7 +418,7 @@
         //return soxes.get(name);
 
         File f = new File(dir, name);
-        SOXServer soxfile = SOXServer.getInstance(f, getDebug());
+        SOXServer soxfile = SOXServer.getInstance(f, getLog());
         return soxfile ;
     }
 
@@ -541,7 +541,7 @@
         }
 
         File d = new File(arg[0]);
-        PrintWriter bug = new PrintWriter(System.err, true);
+        Log bug = new Log();
         DirContractStore cons = new DirContractStore(d, bug);
         DirSOXStore store = new DirSOXStore(d, bug);
         System.err.println("Started: " + store);



1.21      +13 -13    java/webfunds/ricardian/SOXServer.java

Index: SOXServer.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/SOXServer.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- SOXServer.java	2001/04/08 21:42:47	1.20
+++ SOXServer.java	2001/04/12 04:57:54	1.21
@@ -1,5 +1,5 @@
 /*
- * $Id: SOXServer.java,v 1.20 2001/04/08 21:42:47 iang Exp $
+ * $Id: SOXServer.java,v 1.21 2001/04/12 04:57:54 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -15,6 +15,8 @@
 import java.util.Enumeration;
 import java.util.Vector;
 
+import webfunds.util.Log;
+
 import webfunds.utils.Diagnostics;
 
 import webfunds.util.Panic;
@@ -68,13 +70,12 @@
     // implements Diagnostics  - EXPERIMENTAL !!!
     // mixing these classes is a bit non-OO.  But, it seems many need both.
     // another option would be to extend from Debug.
-    protected PrintWriter bug = null;
+    protected Log bug = null;
     protected String      fix = "      ss- ";
     public void logmsg(String s)  { if (bug != null) bug.println(fix + s); }
     public PrintWriter getDebug() { return bug ; }
-    // hmm, no autoflush.
-    public PrintWriter err()
-    { return (bug == null) ? new PrintWriter(System.err, true) : bug ; }
+    public Log getLog() { return bug ; }
+    public PrintWriter err() { return (bug == null) ? new Log() : bug ; }
 
 
 
@@ -88,11 +89,11 @@
 
 ///////  Constructors  /////////////////////////////////////////////
 
-    public SOXServer(byte[] fileData, String name, PrintWriter bug)
+    public SOXServer(byte[] fileData, String name, Log bug)
         throws SOXServerException
     {
         if (bug != null)
-            this.bug = new PrintWriter(bug, true);
+            this.bug = new Log();
         this.fileData  = fileData;
         this.originalName = name;
         init();
@@ -179,7 +180,7 @@
      *
      * @param file name for SOXServer file
      */
-    public static SOXServer getInstance(File serverfile, PrintWriter bug)
+    public static SOXServer getInstance(File serverfile, Log bug)
         throws SOXServerException
     {
 
@@ -209,7 +210,7 @@
      *
      *  XXX: deprecate!
      */
-    public static SOXServer getInstance(URL url, PrintWriter bug)
+    public static SOXServer getInstance(URL url, Log bug)
         throws SOXServerException, SOXLaterException
     {
         CommsManager comms = new BasicCommsManager(bug);
@@ -223,7 +224,7 @@
      * @param comms where to get a comms requestor from
      */
     public static SOXServer getInstance(URL url, CommsManager comms,
-                                        PrintWriter bug)
+                                        Log bug)
         throws SOXServerException, SOXLaterException
     {
         String proto = url.getProtocol();
@@ -347,7 +348,7 @@
         }
 
         logmsg("smart with " + urls.length + " urls");
-        SmartIssuer smart = new SmartIssuer(urls, cert, comms, getDebug());
+        SmartIssuer smart = new SmartIssuer(urls, cert, comms, getLog());
 
         //
         //  Pass the URLs of other non-SOX servers to the SmartIssuer
@@ -660,7 +661,7 @@
 
         String name = arg[0];
         SOXServer sox = null;
-        PrintWriter bug = new PrintWriter(System.err);
+        Log bug = new Log();
         CommsManager comms = new BasicCommsManager(bug);
 
         try
@@ -681,7 +682,6 @@
             ex.printStackTrace(bug);
             System.exit(1);
         }
-        // sox.debug(new PrintWriter(System.err, true));
         System.err.println("SOXServer: " + sox.getName());
         String[] names = sox.getAllNames();
         for (int i = 0; i < names.length; i++)