Hi, java.text.NumberFromat is missing a public final format(Object obj, StringBuffer sb, FieldPosition pos) method. (Since it is not very clearly documented I just made a choice to format Doubles/Floats as doubles and all other Numbers as longs. See the javadoc.) NumberFormat.diff attached. This also means that the (empty stub) method can be removed from ChoiceFormat. ChoiceFormat.diff attached. I found these problems (plus the problem with Double/Float) while trying to use the DecimalFormat class from libgcj. If you want to use it with Classpath you will also need to add a (package local) getExponential() method to DecimalFormatSymbols. DecimalFormatSymbols.diff attached. Cheers, Mark P.S. Not tested, it just compiles :) P.P.S. Still working on java.util.jar, libgcj contained only some stubs.
Index: java/text/NumberFormat.java =================================================================== RCS file: /gd/gnu/anoncvsroot/classpath/java/text/NumberFormat.java,v retrieving revision 1.1 diff -u -r1.1 NumberFormat.java --- NumberFormat.java 1998/11/15 04:33:15 1.1 +++ NumberFormat.java 1999/12/22 12:55:19 @@ -517,6 +517,37 @@ /*************************************************************************/ /** + * This method formats the specified <code>Object</code> as a number + * and appends it to the specified <code>StringBuffer</code>. + * The specified object must be an instance of <code>Number</code> + * or an <code>IllegalArgumentException</code> will be thrown. + * If the object is an instance of <code>Double</code> or <code>Float</code> + * it will be formatted as a <code>double</code>, otherwise as a + * <code>long</code>. + * + * @param obj The <code>Object</code> to format. + * @param sb The <code>StringBuffer</code> to append the resultant + * <code>String</code> to. + * @param pos The desired <code>FieldPosition</code>. + * + * @return The <code>StringBuffer</code> supplied on input, with the + * formatted Object appended. + */ +public final StringBuffer +format(Object obj, StringBuffer sb, FieldPosition pos) +{ + if (!(obj instanceof Number)) + throw new IllegalArgumentException("Invalid object type: " + obj); + + if ((obj instanceof Float) || (obj instanceof Double)) + return(format(((Number)obj).doubleValue(), sb, pos)); + else + return(format(((Number)obj).longValue(), sb, pos)); +} + +/*************************************************************************/ + +/** * This method parses the specified string into a <code>Number</code>. This * will be a <code>Long</code> if possible, otherwise it will be a * <code>Double</code>. If no number can be parsed, an exception will be
Index: java/text/ChoiceFormat.java =================================================================== RCS file: /gd/gnu/anoncvsroot/classpath/java/text/ChoiceFormat.java,v retrieving revision 1.3 diff -u -r1.3 ChoiceFormat.java --- ChoiceFormat.java 1999/11/18 02:24:04 1.3 +++ ChoiceFormat.java 1999/12/22 12:55:19 @@ -348,16 +348,6 @@ /*************************************************************************/ -// Method I need - -public StringBuffer -format(Object obj, StringBuffer sb, FieldPosition status) -{ - return(null); -} - -/*************************************************************************/ - /** * I'm not sure what this method is really supposed to do, as it is * not documented.
Index: java/text/DecimalFormatSymbols.java =================================================================== RCS file: /gd/gnu/anoncvsroot/classpath/java/text/DecimalFormatSymbols.java,v retrieving revision 1.2 diff -u -r1.2 DecimalFormatSymbols.java --- DecimalFormatSymbols.java 1999/04/09 02:11:52 1.2 +++ DecimalFormatSymbols.java 1999/12/22 12:55:19 @@ -272,6 +272,23 @@ /*************************************************************************/ /** + * This method returns the character used to represent an exponential in + * a format pattern string. + * <p> + * XXX - This a a package local addition that is + * added to make the DecimalFormat class from libgcj work. + * + * @return The character used to represent an exponential in a format pattern. + */ +char +getExponential() +{ + return(exponential); +} + +/*************************************************************************/ + +/** * This method sets the character used to represents a digit in a format * string to the specified value. *