[e-cvs] cvs commit: e/src/jsrc/org/erights/e/meta/java/math BigIntegerMakerSugar.java BigIntegerSugar.java
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Tue, 24 Jul 2001 07:52:16 -0400
markm 01/07/24 07:52:16
Modified: src/esrc/org/erights/e/tools/html html2txt.emaker
src/esrc/scripts updoc.e
src/jsrc/net/captp/jcomm LocatorUnum.java Sturdifier.java
src/jsrc/net/vattp/data EARL.java NetAddr.java
src/jsrc/org/erights/e/develop/trace TraceDateToString.java
TraceMessageStringifier.java
src/jsrc/org/erights/e/extern/timer Timer.java
src/jsrc/org/erights/e/meta/java/math
BigIntegerMakerSugar.java BigIntegerSugar.java
Added: src/jsrc/org/erights/e/develop/format ETimeFormat.java
Log:
time now in ISO8601
Revision Changes Path
1.13 +89 -7 e/src/esrc/org/erights/e/tools/html/html2txt.emaker
Index: html2txt.emaker
===================================================================
RCS file: /cvs/e/src/esrc/org/erights/e/tools/html/html2txt.emaker,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- html2txt.emaker 2001/03/26 06:23:47 1.12
+++ html2txt.emaker 2001/07/24 11:52:15 1.13
@@ -1,9 +1,9 @@
+def first__quasiParser := <import:org.erights.e.tools.text.first__quasiParser>
def parseInt(str) :integer {
<import:java.lang.Integer> parseInt(str)
}
-
def entity2txt(entity) :Twine {
switch (entity) {
match =="lt" { "<" }
@@ -24,17 +24,99 @@
}
}
+# Taken from the HTML4.0 definition
+def blockElements := [
+ "ADDRESS",
+ "BLOCKQUOTE",
+ "CENTER",
+ "DIR",
+ "DIV",
+ "DL",
+ "FIELDSET",
+ "FORM",
+ "H1",
+ "H2",
+ "H3",
+ "H4",
+ "H5",
+ "H6",
+ "HR",
+ "ISINDEX",
+ "MENU",
+ "NOFRAMES",
+ "NOSCRIPT",
+ "OL",
+ "P",
+ "PRE",
+ "TABLE",
+ "UL",
+
+ "DD",
+ "DT",
+ "FRAMESET",
+ "LI",
+ "TBODY",
+ "TD",
+ "TFOOT",
+ "TH",
+ "THEAD",
+ "TR"
+] asKeys()
+
+def firstWhiteSpace := first__quasiParser matchMaker("@{0}[ \t\n]@{1}")
+
def html2txt(var html) :Twine {
var result := ""
- while (html =~ rx`(?ms)(@text.*?)(@thing(<.*?>|&.*?;))(@rest.*)`) {
- result += text
- switch (thing) {
- match `<@_>` {}
- match `&@entity;` {
+ while (html =~ first`@left[&<]@right`) {
+ result += left
+ switch (right) {
+ match `<@{var tag}>@rest` {
+ if (tag =~ `@_<@_`) {
+ throw(`"<$tag>" isn't really a tag`)
+ }
+ if (firstWhiteSpace matchBind([], tag) =~ [name, _]) {
+ tag := name
+ }
+ if (blockElements maps(tag toUpperCase())) {
+ # If the tag starts a block element, then output a newline.
+ result += "\n"
+ }
+ html := rest
+ }
+ match `&@entity;@rest` {
result += entity2txt(entity)
+ html := rest
}
+ match _ {
+ result += right(0,1)
+ html := right(1,right size())
+ }
}
- html := rest
}
result + html
}
+
+
+ ? def html2txt := <import:org.erights.e.tools.html.html2txt>
+ # value: <html2txt>
+
+ ? html2txt("foo<pre>bar")
+ # value: "foo\n\
+ # bar"
+
+ ? html2txt("foo<b>bar")
+ # value: "foobar"
+
+ ? html2txt("3 < 4")
+ # value: "3 < 4"
+
+ ? html2txt("3 < 4<b>5")
+ # problem: "< 4<b>" isn't really a tag
+ #
+ # throw("\"< 4<b>\" isn\'t really a tag")
+ # <e object>()
+ # org.erights.e.elang.interp.Loop@3914b3(<e object>)
+ # <html2txt>("3 < 4<b>5")
+ # <interp> evalPrint(e`html2txt run("3 < 4<b>5")`)
+
+ ?
\ No newline at end of file
1.8 +2 -79 e/src/esrc/scripts/updoc.e
Index: updoc.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/updoc.e,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- updoc.e 2001/07/16 03:34:12 1.7
+++ updoc.e 2001/07/24 11:52:15 1.8
@@ -8,83 +8,8 @@
def URL := URLMaker asType()
def SyntaxException :=
<unsafe:org.erights.e.elang.syntax.SyntaxException> asType()
+def html2txt := <import:org.erights.e.tools.html.html2txt>
-
-# XXX Prototype the next html2txt
-# def html2txt := <import:org.erights.e.tools.html.html2txt>
-def FirstCharSplitterMaker :=
- <import:org.erights.e.elib.quasi.FirstCharSplitter>
-# XXX should be proper hash-cache
-def mmCache := [] asMap() diverge()
-def first__quasiParser {
- to matchMaker(template) :any {
- def optResult := mmCache get(template, null)
- if (optResult != null) {
- optResult
- } else {
- # XXX special case for now
- def `@@{0}[@specials]@@{1}` := template
- def splitter := FirstCharSplitterMaker new(specials)
- def FirstCharMatchMaker {
- to matchBind([], specimen) :any {
- def index := splitter findIn(specimen)
- if (index == -1) {
- null
- } else {
- [specimen(0, index), specimen(index, specimen size())]
- }
- }
- }
- }
- }
-}
-
-def parseInt(str) :integer {
- <import:java.lang.Integer> parseInt(str)
-}
-
-def entity2txt(entity) :Twine {
- switch (entity) {
- match =="lt" { "<" }
- match =="gt" { ">" }
- match =="quot" { "\"" }
- match =="amp" { "&" }
-
- # there is a unicode non-breaking space character,
- # but we use ascii space instead. This means our
- # transformation isn't reversible
- match =="nbsp" { " " }
-
- # does html accept other radii?
- match rx`^#(@digits[0-9]+)$$` {
- "" + parseInt(digits) asChar()
- }
- match _ { `&$entity;` }
- }
-}
-
-def html2txt(var html) :Twine {
- var result := ""
- while (html =~ first`@left[&<]@right`) {
- result += left
- switch (right) {
- match `<@_>@rest` {
- html := rest
- }
- match `&@entity;@rest` {
- result += entity2txt(entity)
- html := rest
- }
- match _ {
- result += right(0,1)
- html := right(1,right size())
- }
- }
- }
- result + html
-}
-
-
# Prints an output record
def printBlock(keyword, str, out) {
@@ -477,7 +402,7 @@
}
} else {
def path := filedir getPath()
- if (endsWithAny(path, [".updoc", ".emaker", ".txt"])) {
+ if (endsWithAny(path, [".updoc", ".e", ".emaker", ".txt"])) {
out lnPrint(`$path:`)
# XXX Once E is faster, and the simple__quasiParser is fixed
# to pass source info through (preserving twine-ness), then
@@ -513,5 +438,3 @@
updoc(filedir, stdout)
}
stdout println()
-
-
1.4 +22 -0 e/src/jsrc/net/captp/jcomm/LocatorUnum.java
Index: LocatorUnum.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/LocatorUnum.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LocatorUnum.java 2001/07/22 05:29:55 1.3
+++ LocatorUnum.java 2001/07/24 11:52:15 1.4
@@ -29,7 +29,29 @@
import org.erights.e.elib.tables.ConstList;
/**
+ * Each instance of this class represents a presence of the pervasive
+ * LocatorUnum service.
+ * <p>
+ * For Una in general: To hold a reference to any presence of the Unum is
+ * conceptually to hold a reference to the Unum as a whole. Therefore, a
+ * reference to the Unum may as well always be a reference to a local
+ * presence of the Unum. Since it can be, and since this would provide better
+ * service, we specify that all references to an Unum will be local.
+ * <p>
+ * Therefore, an encoded reference to a presence of Unum that's local to the
+ * sending side will be decoded as a reference to a presence of the same Unum
+ * local to the receiving side. Therefore, a fulfilled reference to an Unum is
+ * always
+ * <a href="http://www.erights.org/elib/concurrency/refmech.html">Near</a>,
+ * and therefore a reference to an Unum is always eventually Near or Broken.
+ * <p>
+ * The LocatorUnum is the only Unum built in to E itself, and the only Unum
+ * currently supported. It represents the pervasive vatID/swissNumber lookup
+ * service built jointly out of all vats and VLSes. It is used only by
+ * SturdyRefs to establish their authority to perform a lookup, and to enable
+ * SturdyRefs to maintain this authority as they are copied between vats.
*
+ * @author Mark S. Miller
*/
public class LocatorUnum {
1.5 +0 -1 e/src/jsrc/net/captp/jcomm/Sturdifier.java
Index: Sturdifier.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/Sturdifier.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Sturdifier.java 2001/07/22 05:29:55 1.4
+++ Sturdifier.java 2001/07/24 11:52:15 1.5
@@ -21,7 +21,6 @@
import java.io.IOException;
import java.math.BigInteger;
-import java.util.Date;
import net.captp.tables.SwissTable;
import net.captp.tables.Vine;
import net.vattp.data.NetConfig;
1.2 +49 -39 e/src/jsrc/net/vattp/data/EARL.java
Index: EARL.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/vattp/data/EARL.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EARL.java 2000/12/21 22:15:18 1.1
+++ EARL.java 2001/07/24 11:52:15 1.2
@@ -23,6 +23,8 @@
import java.io.IOException;
import java.math.BigInteger;
import java.net.MalformedURLException;
+import java.text.ParseException;
+import org.erights.e.develop.format.ETimeFormat;
import org.erights.e.develop.trace.Trace;
import org.erights.e.elib.base.TextWriter;
import org.erights.e.elib.tables.ConstList;
@@ -32,23 +34,39 @@
/**
* A parsed URI designating an E object. Created by parsing of a
* human-readible reference to an E-object. The human
- * readable form is:
- * "cap://searchpath/vatID/swissStr[/expirationDate]".
+ * readable form is: <pre>
+ * "cap://searchpath/vatID/swissStr[/expirationDate]".
+ * </pre>
+ * where <ul>
+ * <li><p>The "searchpath" is a semicolon-separated list of network
+ * addresses to search to locate the vat designated by the "vatID". At
+ * these addresses may be found either vats or VLSes.</p>
+ * <p>Each network address is expected to be of the form parsed by
+ * {@link NetAddr#NetAddr(String)}.</p></li>
+ * <li><p>The "vatID", which is the identity of a vat -- a public key
+ * fingerprint encoded in base 64. A vatID designates any vat that
+ * authenticates using the corresponding private key. It is generally
+ * assumed that there is only one such live vat at any moment, but this
+ * assumption is unenforceable.</p></li>
+ * <li><p>The "swissStr" is the Swiss number of the object within that
+ * vat. It is an unguessable secret number, encoded in base 64, whose
+ * knowledge demonstrates authority to invoke the object it
+ * designates.</p></li>
+ * <li><p>"expirationDate" is the optional registration expiration date.
+ * as the difference, measured in milliseconds, between the expiration
+ * time and midnight, January 1, 1970 UTC (known as the epoch). If the
+ * expiration date is omitted or is equal to Long.MAX_VALUE
+ * milliseconds since the epoch, then the expiration is assumed to be
+ * infinite.</p>
+ * <p>The format of this date field is according to
+ * {@link org.erights.e.develop.format.ETimeFormat#formatTime(long)}</p></li>
+ * </ul>
+ * <p>Note that base 64 is supported by
+ * {@link BigIntegerSugar#toString64(BigInteger)} and
+ * {@link BigIntegerMakerSugar#fromString64(String)}.</p>
*
- * <p>where "searchpath" is a list of network addresses to search to locate
- * the "vatID", which is the identity of a vat.
- * "swissStr" is the ID (Swiss number) of the object within that vat.
- * expirationDate is the registration expiration date.
- * It is the base
- * 36 representation of the difference, measured in milliseconds,
- * between the expiration time and midnight, January 1, 1970 UTC.
- * It may be omitted. If it is omitted, then the
- * expiration is assumed to be infinite. A value equal to Long.MAX_VALUE
- * will also be treated as infinite expiration.
- * <p>Note that base 36 is supported by Long.parseLong(String,36),
- * and Long.toString(long,36).
- * @author Bill Frantz
- * based on work by Eric Messick.
+ * @author Bill Frantz based on work by Eric Messick.
+ * @author Mark Miller (changed the date format and some comments)
*/
public class EARL {
@@ -61,17 +79,15 @@
/**
* Construct an EARL given the components of the URI.
*
- * @param searchPath si the search path, a semi-colon separated list of
- * domain names and/or IP addresses.
+ * @param searchPath The search path, a list of domain names and/or IP
+ * addresses.
* @param vatID is the vatID for the object, a base-36 encoded
* public key fingerprint.
- * @param swissStr is the swissStr for the object, a base-36 encoded Swiss
- * number.
+ * @param swissNum is the swissNumber for the object.
* @param expiration is the registration expiration date. It is
- * the difference, measured in milliseconds,
- * between the expiration time and midnight, January 1, 1970 UTC.
- * A value equal to Long.MAX_VALUE
- * will also be treated as infinite expiration.
+ * the difference, measured in milliseconds, between the expiration
+ * time and midnight, January 1, 1970 UTC (the epoch). A value equal
+ * to Long.MAX_VALUE will also be treated as infinite expiration.
*/
public EARL(ConstList searchPath,
String vatID,
@@ -85,24 +101,17 @@
String flattenedSearchPath = flattenSearchPath(mySearchPath);
myURI = "cap://" + flattenedSearchPath + "/" + vatID + "/" + mySwissStr;
if (Long.MAX_VALUE != expiration) {
- myURI += "/" + Long.toString(expiration, 36);
+ myURI += "/" + ETimeFormat.formatTime(expiration);
}
}
/**
* Construct an EARL given the URI string.
*
- * @param uri is an URI of the form:
- * "cap://searchpath/vatID/swissStr[/expirationDate]".
- * expirationDate is the registration expiration date.
- * It is the base
- * 36 representation of the difference, measured in milliseconds,
- * between the expiration time and midnight, January 1, 1970 UTC.
- * It may be omitted. If it is omitted, then the
- * expiration is assumed to be infinite. A value equal to
- * Long.MAX_VALUE will also be treated as infinite expiration.
- * <p>Note that base 36 is supported by Long.parseLong(String,36),
- * and Long.toString(long,36).
+ * @param uri is an URI of the form: <pre>
+ * "cap://searchpath/vatID/swissStr[/expirationDate]".
+ * </pre>
+ * See the class comment for an explanation of the fields of this format.
*/
public EARL(String uri) throws MalformedURLException {
myURI = uri;
@@ -110,7 +119,8 @@
}
/**
- * Return the expiration date string for this EARL.
+ * Return the expiration date string for this EARL. Infinite expiration
+ * is indicated as Long.MAX_VALUE.
*/
public long expiration() {
return myExpiration;
@@ -198,8 +208,8 @@
if (rest.length() > i) {
rest = rest.substring(i+1);
try {
- myExpiration = Long.parseLong(rest, 36);
- } catch(NumberFormatException e) {
+ myExpiration = ETimeFormat.parseTime(rest);
+ } catch (ParseException e) {
throw new MalformedURLException("Parsing expiration date \""
+ rest + "\" "+ e.toString());
}
1.2 +30 -31 e/src/jsrc/net/vattp/data/NetAddr.java
Index: NetAddr.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/vattp/data/NetAddr.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NetAddr.java 2000/12/21 22:15:18 1.1
+++ NetAddr.java 2001/07/24 11:52:15 1.2
@@ -26,13 +26,11 @@
import java.net.UnknownHostException;
/**
- A simple class which represents an extended IP address -- an IP address
- together with a port number.
- @author Bill Frantz
-
- Based on work by Eric Messick and Chip Morningstar
- 25-March-1997
-*/
+ * A simple class which represents an extended IP address -- an IP address
+ * together with a port number.
+ *
+ * @author Bill Frantz (Based on work by Eric Messick and Chip Morningstar)
+ */
public class NetAddr {
/** null means a port associated with all local IP addresses */
private InetAddress myOptIP;
@@ -46,21 +44,21 @@
* may be both of these separated by a slash, in which case only the
* part after the slash is significant. If the significant part
* of the hostname is absent, then the port is associated with all
- * local IP addresses.
+ * local IP addresses.
+ * <p>
+ * Examples: <pre>
+ * "the-earth.communities.com/205.162.51.187:4568"
+ * "the-earth.communities.com:4568"
+ * "205.162.51.187:4568"
+ * "the-earth.communities.com"
+ * ":4568"
+ * ""
+ * null
+ * </pre>
*
- * <p>Examples:
- * <p> "the-earth.communities.com/205.162.51.187:4568"
- * <p> "the-earth.communities.com:4568"
- * <p> "205.162.51.187:4568"
- * <p> "the-earth.communities.com"
- * <p> ":4568"
- * <p> ""
- * <p> null
- *
* @param optAddr is the network address.
- *
* @exception UnknownHostException is thrown if the host name can not
- * be resolved.
+ * be resolved.
*/
public NetAddr(String optAddr) throws UnknownHostException {
if (optAddr == null) {
@@ -120,6 +118,18 @@
}
/**
+ * @return A hash code that accounts for both the IP address and port.
+ */
+ public int hashCode() {
+ int result = myPortNumber;
+ if (null == myOptIP) {
+ return myPortNumber;
+ } else {
+ return myOptIP.hashCode() ^ myPortNumber;
+ }
+ }
+
+ /**
* Return my IP address, or null indicating all local IP addresses.
* @return my IP address
*/
@@ -136,19 +146,8 @@
}
/**
- * @return A hash code that accounts for both the IP address and port.
- */
- public int hashCode() {
- int result = myPortNumber;
- if (null == myOptIP) {
- return myPortNumber;
- } else {
- return myOptIP.hashCode() ^ myPortNumber;
- }
- }
-
- /**
* Produce a printable representation of this.
+ *
* @return A nicely formatted string representing this address.
*/
public String toString() {
1.1 e/src/jsrc/org/erights/e/develop/format/ETimeFormat.java
Index: ETimeFormat.java
===================================================================
package org.erights.e.develop.format;
/*
The contents of this file are subject to the Electric Communities E Open
Source Code License Version 1.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License
at http://www.communities.com/EL/.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is the Distributed E Language Implementation, released
July 20, 1998.
The Initial Developer of the Original Code is Electric Communities.
Copyright (C) 1998 Electric Communities. All Rights Reserved.
Contributor(s): ______________________________________.
*/
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import java.util.Date;
/**
* Just converts back and forth between milliseconds since the epoch
* (standard binary time representation) and ISO8601/UTC (standard
* sortable textual respresentation) but enhanced to represent milliseconds.
* <p>
* @see <a href="http://www.w3.org/TR/1998/NOTE-datetime-19980827">w3c's
* explanation of </a>
* @see <a href="http://www.w3.org/TR/REC-html40/types.html#type-datetime"
* >html4.0's explanation</a>
*
* @author Mark S. Miller
*/
public class ETimeFormat {
static private final DateFormat SortableFormat =
new SimpleDateFormat("yyyy-MM-dd!HH:mm:ss.SSS%");
static {
TimeZone utc = TimeZone.getTimeZone("UTC");
SortableFormat.setTimeZone(utc);
}
/**
* Shows millis since epoch as a sortable absolute date/time string that
* can be included in a single URI field (no "#"s or "/"s).
* <p>
* The format must also be independent of Locale, the default current
* TimeZone, or the current time. In the terminology of <a
* href="http://www.w3.org/TR/1998/NOTE-datetime-19980827">ISO601</a>,
* the actual format is "YYYY-MM-DDThh:mm:ss.sssTZD", where the value of
* TZD (timezone) is "Z", indicating UTC (Universal Standard Time, which
* is just another name for GMT).
* <p>
* It would be good if the format returned could also be used
* within filenames, but unfortunately this conflicts with the
* familiar use of colon (":") to represent clock time, as
* mandated by ISO8601. Clients (such as the Trace system) that
* need to embed the result in a filename should do a
* <code>.replace(':','~')</code>. {@link #parseTime(String)}
* will handle either colons or tildes in its input.
*/
static public String formatTime(long millis) {
String formatted = SortableFormat.format(new Date(millis));
return formatted.replace('!','T').replace('%','Z');
}
/**
* Given a sortableTime string in the format returned by millisToDate,
* return the corresponding number of seconds since the epoch.
*/
static public long parseTime(String sortableTime) throws ParseException {
sortableTime = sortableTime.replace('T','!')
.replace('Z','%')
.replace('~',':');
return SortableFormat.parse(sortableTime).getTime();
}
}
1.2 +13 -53 e/src/jsrc/org/erights/e/develop/trace/TraceDateToString.java
Index: TraceDateToString.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/develop/trace/TraceDateToString.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TraceDateToString.java 2000/09/20 01:26:08 1.1
+++ TraceDateToString.java 2001/07/24 11:52:16 1.2
@@ -21,13 +21,11 @@
/*
* Trace and Logging Package. Written by Brian Marick,
* July-September 1997, for Electric Communities, Inc.
- * Copyright (c) 1997 by Electric Communities. All Rights Reserved.
*/
import java.util.Date;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
+import org.erights.e.develop.format.ETimeFormat;
/**
* Convert java.util.Dates into suitable Strings for the Trace system.
@@ -42,65 +40,27 @@
* <p>
* Note that the construction of strings in this class is one of the
* bottlenecks in this code.
+ * <p>
+ * Changed to use ISO8601 according to {@link ETimeFormat}.
+ *
+ * @author Brian Marick
+ * @author Mark Miller (modified to use ISO8601)
*/
class TraceDateToString {
- /* The Calendar used for translating Dates. */
- private static Calendar theCalendar = new GregorianCalendar();
/**
- * Returns a string like 1997/04/23. Note that strings of this
- * form can be sorted by date, unlike M/D/Y or D/M/Y, or the
- * standard java form that omits zero padding. By being in obviously
- * non-European and non-US order (because of the year), no one
- * gets confused as to which field is the day and which is the
- * month. Note finally: no Year 2000 problem.
+ * XXX should fix the tracing package to use 'long millis' instead of
+ * 'Date date'
*/
- /*package*/ final static String dateString (Date date) {
- theCalendar.setTime(date);
- return theCalendar.get(Calendar.YEAR) + "/" +
- zeroFill(theCalendar.get(Calendar.MONTH)) + "/" +
- zeroFill(theCalendar.get(Calendar.DAY_OF_MONTH));
+ /*package*/ final static String dateTimeString (Date date) {
+ return ETimeFormat.formatTime(date.getTime());
}
/**
- * Return time in form YYYYMMDDHHMMSS. This is a terse sortable
- * time. Fields are zero-padded as needed.
+ * This must return one that can be used within a filename, so
+ * convert ":"s to "~"s.
*/
/*package*/ final static String terseCompleteDateString(Date date) {
- theCalendar.setTime(date);
- return "" + theCalendar.get(Calendar.YEAR) +
- zeroFill(theCalendar.get(Calendar.MONTH)) +
- zeroFill(theCalendar.get(Calendar.DAY_OF_MONTH)) +
- zeroFill(theCalendar.get(Calendar.HOUR_OF_DAY)) +
- zeroFill(theCalendar.get(Calendar.MINUTE)) +
- zeroFill(theCalendar.get(Calendar.SECOND));
- }
-
- /**
- * Return time in form HH:MM:SS. Fields are zero-padded as
- * needed.
- */
- /*package*/ final static String timeString (Date date) {
- theCalendar.setTime(date);
- return zeroFill(theCalendar.get(Calendar.HOUR_OF_DAY)) + ":" +
- zeroFill(theCalendar.get(Calendar.MINUTE)) + ":" +
- zeroFill(theCalendar.get(Calendar.SECOND)) + "." +
- zero3Fill(theCalendar.get(Calendar.MILLISECOND));
- }
- private final static String zeroFill(int number) {
- if (number <= 9) {
- return "0" + String.valueOf(number);
- } else {
- return String.valueOf(number);
- }
- }
- private final static String zero3Fill(long number) {
- if (number <= 9) {
- return "00" + String.valueOf(number);
- } else if (number <= 99) {
- return "0" + String.valueOf(number);
- } else {
- return String.valueOf(number);
- }
+ return ETimeFormat.formatTime(date.getTime()).replace(':','~');
}
}
1.11 +3 -6 e/src/jsrc/org/erights/e/develop/trace/TraceMessageStringifier.java
Index: TraceMessageStringifier.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/develop/trace/TraceMessageStringifier.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TraceMessageStringifier.java 2000/11/07 06:41:07 1.10
+++ TraceMessageStringifier.java 2001/07/24 11:52:16 1.11
@@ -99,12 +99,9 @@
/*package*/ String toString(TraceMessage message) {
buffer.setLength(0);
buffer.append("=== ");
- if (myShowDate) {
- buffer.append(TraceDateToString.dateString(message.date));
- buffer.append(' ');
- }
- if (myShowTime) {
- buffer.append(TraceDateToString.timeString(message.date));
+ //MSM: XXX should merge these flags now that we've merged their meaning
+ if (myShowDate || myShowTime) {
+ buffer.append(TraceDateToString.dateTimeString(message.date));
buffer.append(' ');
}
if (myShowLocation) {
1.14 +3 -33 e/src/jsrc/org/erights/e/extern/timer/Timer.java
Index: Timer.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/extern/timer/Timer.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Timer.java 2001/07/22 05:29:55 1.13
+++ Timer.java 2001/07/24 11:52:16 1.14
@@ -20,11 +20,6 @@
*/
import java.io.IOException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.TimeZone;
-import java.util.Date;
import org.erights.e.elib.base.TextWriter;
import org.erights.e.elib.base.Thunk;
import org.erights.e.elib.prim.PendingEvent;
@@ -51,14 +46,6 @@
static private final Object[] NO_ARGS = {};
- static private final DateFormat SortableFormat =
- new SimpleDateFormat("yyyy.MM.dd-HH:mm:ss:SSS-zz");
-
- static {
- TimeZone gmt = TimeZone.getTimeZone("GMT");
- SortableFormat.setTimeZone(gmt);
- }
-
/** The single permitted instance of this class */
static private Timer TheTimer = new Timer();
@@ -81,25 +68,6 @@
}
/**
- * Shows millis since epoch as a sortable absolute date string that can
- * be included in a filename or a single URI field (no "#"s or "/"s). <p>
- *
- * The actual format is "yyyy.MM.dd-HH:mm:ss:SSS-zz" as interpreter by
- * {@link java.text.SimpleDateFormat}.
- */
- public String millisToDate(long millis) {
- return SortableFormat.format(new Date(millis));
- }
-
- /**
- * Given a sortableDate string in the format returned by millisToDate,
- * return the corresponding number of seconds since the epoch.
- */
- public long dateToMillis(String sortableDate) throws ParseException {
- return SortableFormat.parse(sortableDate).getTime();
- }
-
- /**
* Sets a timeout for the specified number of milliseconds. After the timer
* expires, target is eventually sent the run() message.
*
@@ -171,7 +139,9 @@
}
/**
- * Return the single permitted Timer object.
+ * XXX Return the single permitted Timer object. <p>
+ *
+ * There shouldn't be a single one.
*/
static public Timer theTimer() {
return TheTimer;
1.5 +5 -4 e/src/jsrc/org/erights/e/meta/java/math/BigIntegerMakerSugar.java
Index: BigIntegerMakerSugar.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/meta/java/math/BigIntegerMakerSugar.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BigIntegerMakerSugar.java 2001/07/14 12:57:25 1.4
+++ BigIntegerMakerSugar.java 2001/07/24 11:52:16 1.5
@@ -39,13 +39,14 @@
private BigIntegerMakerSugar() {}
/**
- * Convert a base 64 string to a byte array
+ * Convert a base 64 string to an integer.
*
- * @param s is the string in base 64 notation, with an optional leading
- * '-'.
+ * @param s The string in base 64 notation, with an optional leading
+ * '-', in the format produced by
+ * {@link BigIntegerSugar#toString64(BigInteger)}.
* @return the integer.
* @exception NumberFormatException if there is an invalid base 64
- * character in the input string.
+ * character in the input string.
*/
static public BigInteger fromString64(String s)
throws NumberFormatException {
1.23 +14 -4 e/src/jsrc/org/erights/e/meta/java/math/BigIntegerSugar.java
Index: BigIntegerSugar.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/meta/java/math/BigIntegerSugar.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- BigIntegerSugar.java 2001/05/01 08:42:04 1.22
+++ BigIntegerSugar.java 2001/07/24 11:52:16 1.23
@@ -298,12 +298,22 @@
/**
* Convert an integer to a base 64 string, with an optional leading minus
- * sign.
- *
- *@return a string which represents the integer in base 64 encoding.
+ * sign. <p>
+ *
* A negative integer is encoded as a "-" followed by the encoding of the
* absolute magnitude. For a positive integer, the encoded length will
- * be (4 * b.length)/3, rounded up to the next integer character length.
+ * be (4 * b.length)/3, rounded up to the next integral (non-fractional)
+ * character length. <p>
+ *
+ * Each base 64 digit is encoded by one of the characters <ul>
+ * <li>'0'..'9' for 0..9</li>
+ * <li>'A'..'Z' for 10..35</li>
+ * <li>'a'..'z' for 37..61</li>
+ * <li>'=' for 62</li>
+ * <li>'_' for 63</li>
+ * </pre>
+ *
+ * @return a string which represents the integer in base 64 encoding.
*/
static public String toString64(BigInteger self) {
if (self.signum() < 0) {