[Webfunds-commits] java/webfunds/ricardian Contract.java Currency.java Share.java
Ian Grigg
iang@cypherpunks.ai
Thu, 9 Nov 2000 09:19:29 -0400 (AST)
iang 00/11/09 09:19:29
Modified: webfunds/ricardian Contract.java Currency.java Share.java
Log:
1. added getSymbol
2. fixed up static errors in Contract (still a mess)
3. fixed bug with share
Revision Changes Path
1.48 +24 -20 java/webfunds/ricardian/Contract.java
Index: Contract.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/Contract.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- Contract.java 2000/10/07 18:13:22 1.47
+++ Contract.java 2000/11/09 13:19:28 1.48
@@ -1,4 +1,4 @@
-/* $Id: Contract.java,v 1.47 2000/10/07 18:13:22 iang Exp $
+/* $Id: Contract.java,v 1.48 2000/11/09 13:19:28 iang Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -378,9 +378,7 @@
{
String s = "Warning! canonical differs (" +
version2 + "): set [local] digest_version=2 ?";
- if (errors.length() > 0)
- errors += "; ";
- errors += s;
+ error(s);
// System.err.println(s);
}
@@ -389,8 +387,16 @@
protected static String errors = "";
/** @return "" if no errors detected, else descriptive string */
- public static String getErrors() { return errors; }
+ public static String getErrors() { return errors; }
+ public static void resetErrors() { errors = ""; }
+ public static void error(String e)
+ {
+ if (errors.length() > 0)
+ errors += "; ";
+ errors += e;
+ }
+
public static final String BEGIN = "-----BEGIN ";
public static final String X509_BEGIN = BEGIN + "SIGNED DATA-----";
public static final String PGP_BEGIN = BEGIN + "PGP SIGNED MESSAGE-----";
@@ -416,11 +422,7 @@
String[] lines = IniFileReader.toLines(data, v);
if (IniFileReader.getNumErrors() != 0)
- {
- if (errors.length() > 0)
- errors += "; ";
- errors += IniFileReader.getLastErrors();
- }
+ error(IniFileReader.getLastErrors());
//String line;
int lineNum = 0;
@@ -773,15 +775,13 @@
return CURRENCY_TYPE;
else if(BOND_WORD.equalsIgnoreCase(type))
return BOND_TYPE;
- else if(BOND_WORD.equalsIgnoreCase(type))
+ else if(SHARE_WORD.equalsIgnoreCase(type))
return SHARE_TYPE;
else if(SERVER_WORD.equalsIgnoreCase(type))
return SERVER_TYPE;
- if (errors.length() > 0)
- errors += "; ";
- errors += "Unknown type of contract: " + type;
- System.err.println(errors);
+ error("Unknown type of contract: " + type);
+ // System.err.println(errors);
return UNKNOWN_TYPE;
}
@@ -809,20 +809,24 @@
* First check if the application has assigned a local
* name for this contract.
*/
-//logmsg("getting appl / contract_name");
String s = getApplicationName();
-//logmsg("got-" + s);
if (s != null && !"".equals(s))
return s;
-//logmsg("getting " + type + " / name");
s = getField(type, "name");
-//logmsg("got;" + s);
if (s != null && !"".equals(s))
return s ;
-//logmsg("returning" + name);
return name ; // else, return hash name
+ }
+
+ /**
+ * Get the single shortest name for display of this contract.
+ * Can be overridden in subclass if better name in type field.
+ */
+ public String getSymbol()
+ {
+ return getName();
}
/**
1.10 +20 -1 java/webfunds/ricardian/Currency.java
Index: Currency.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/Currency.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Currency.java 2000/09/24 23:12:08 1.9
+++ Currency.java 2000/11/09 13:19:28 1.10
@@ -1,5 +1,5 @@
/*
- * $Id: Currency.java,v 1.9 2000/09/24 23:12:08 iang Exp $
+ * $Id: Currency.java,v 1.10 2000/11/09 13:19:28 iang Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -83,4 +83,23 @@
}
public int getType() { return Contract.CURRENCY_TYPE; }
+
+ /**
+ * Get the symbol for the currency.
+ */
+ public String getSymbol()
+ {
+ String s;
+
+ s = getField(type, "symbol"); // optional, like $
+ if (s != null && !"".equals(s))
+ return s ;
+
+ s = getField(type, "tla");
+ if (s != null && !"".equals(s))
+ return s ;
+
+ // not a good currency then
+ return super.getSymbol();
+ }
}
1.2 +15 -1 java/webfunds/ricardian/Share.java
Index: Share.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/Share.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Share.java 2000/09/24 23:12:08 1.1
+++ Share.java 2000/11/09 13:19:28 1.2
@@ -1,5 +1,5 @@
/*
- * $Id: Share.java,v 1.1 2000/09/24 23:12:08 iang Exp $
+ * $Id: Share.java,v 1.2 2000/11/09 13:19:28 iang Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -18,4 +18,18 @@
}
public int getType() { return Contract.CURRENCY_TYPE; }
+
+ /**
+ * Get the symbol for the share.
+ */
+ public String getSymbol()
+ {
+ String s;
+ s = getField(type, "symbol");
+ if (s != null && !"".equals(s))
+ return s ;
+
+ // not a good share then
+ return super.getSymbol();
+ }
}