[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] NumberFormat
From: |
Guilhem Lavaux |
Subject: |
[PATCH] NumberFormat |
Date: |
Fri, 21 Nov 2003 20:56:56 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 |
Hi,
Here is just a patch to review about NumberFormat.Field before I check
it in. It implements java.text.NumberFormat.Field it is quite
straightforward using the documentation.
Regards,
Guilhem.
ChangeLog entry:
2003-11-21 Guilhem Lavaux <address@hidden>
* java/text/NumberFormat.java
(NumberFormat.Field): New implemented class to match Java 1.4
Index: java/text/NumberFormat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/NumberFormat.java,v
retrieving revision 1.4
diff -u -r1.4 NumberFormat.java
--- java/text/NumberFormat.java 22 Jan 2002 22:27:01 -0000 1.4
+++ java/text/NumberFormat.java 21 Nov 2003 19:52:44 -0000
@@ -79,6 +79,98 @@
*/
public static final int FRACTION_FIELD = 1;
+ public static class Field extends Format.Field
+ {
+ static final long serialVersionUID = 7494728892700160890L;
+
+ /**
+ * Attribute set to all characters containing digits of the integer
+ * part.
+ */
+ public static final NumberFormat.Field INTEGER = new Field("integer");
+
+ /**
+ * Attribute set to all characters containing digits of the fractional
+ * part.
+ */
+ public static final NumberFormat.Field FRACTION = new Field("fraction");
+
+ /**
+ * Attribute set to all characters containing digits of the exponential
+ * part.
+ */
+ public static final NumberFormat.Field EXPONENT = new Field("exponent");
+
+ /**
+ * Attribute set to all characters containing a decimal separator.
+ */
+ public static final NumberFormat.Field DECIMAL_SEPARATOR = new
Field("decimal separator");
+
+ /**
+ * Attribute set to all characters containing a sign (plus or minus).
+ */
+ public static final NumberFormat.Field SIGN = new Field("sign");
+
+ /**
+ * Attribute set to all characters containing a grouping separator (e.g. a
comma,
+ * a white space,...).
+ */
+ public static final NumberFormat.Field GROUPING_SEPARATOR = new
Field("grouping separator");
+
+ /**
+ * Attribute set to all characters containing an exponential symbol (e.g.
'E')
+ */
+ public static final NumberFormat.Field EXPONENT_SYMBOL = new
Field("exponent symbol");
+
+ /**
+ * Attribute set to all characters containing a percent symbol (e.g. '%')
+ */
+ public static final NumberFormat.Field PERCENT = new Field("percent");
+
+ /**
+ * Attribute set to all characters containing a permille symbol.
+ */
+ public static final NumberFormat.Field PERMILLE = new Field("permille");
+
+ /**
+ * Attribute set to all characters containing the currency unit.
+ */
+ public static final NumberFormat.Field CURRENCY = new Field("currency");
+
+ /**
+ * Attribute set to all characters containing the exponent sign.
+ */
+ public static final NumberFormat.Field EXPONENT_SIGN = new Field("exponent
sign");
+
+ private static final NumberFormat.Field[] allFields =
+ {
+ INTEGER, FRACTION, EXPONENT, DECIMAL_SEPARATOR, SIGN,
+ GROUPING_SEPARATOR, EXPONENT_SYMBOL, PERCENT,
+ PERMILLE, CURRENCY, EXPONENT_SIGN
+ };
+
+ // For deserialization purpose
+ private Field()
+ {
+ super("");
+ }
+
+ private Field(String s)
+ {
+ super(s);
+ }
+
+ protected Object readResolve() throws InvalidObjectException
+ {
+ String s = getName();
+ for (int i=0;i<allFields.length;i++)
+ if (s.equals(allFields[i].getName()))
+ return allFields[i];
+
+ throw new InvalidObjectException("no such NumberFormat field called " +
s);
+ }
+ }
+
/**
* This method is a specialization of the format method that performs
* a simple formatting of the specified <code>long</code> number.
- [PATCH] NumberFormat,
Guilhem Lavaux <=