Commit 89066f10 by Tom Tromey Committed by Tom Tromey

RuleBasedCollator.java (clone): Rewrote.

	* java/text/RuleBasedCollator.java (clone): Rewrote.
	(RuleBasedCollator(RuleBasedCollator)): Removed.
	* java/text/MessageFormat.java: Re-merged from Classpath.
	* java/text/DecimalFormat.java: Re-merged from Classpath.

From-SVN: r45458
parent cffb2601
2001-09-06 Tom Tromey <tromey@redhat.com>
* java/text/RuleBasedCollator.java (clone): Rewrote.
(RuleBasedCollator(RuleBasedCollator)): Removed.
* java/text/MessageFormat.java: Re-merged from Classpath.
* java/text/DecimalFormat.java: Re-merged from Classpath.
2001-09-06 Anthony Green <green@redhat.com> 2001-09-06 Anthony Green <green@redhat.com>
* include/jvm.h: Declare _Jv_RegisterResource. * include/jvm.h: Declare _Jv_RegisterResource.
......
...@@ -350,21 +350,9 @@ public class DecimalFormat extends NumberFormat ...@@ -350,21 +350,9 @@ public class DecimalFormat extends NumberFormat
public Object clone () public Object clone ()
{ {
return new DecimalFormat (this); DecimalFormat c = (DecimalFormat) super.clone ();
} c.symbols = (DecimalFormatSymbols) symbols.clone ();
return c;
private DecimalFormat (DecimalFormat dup)
{
decimalSeparatorAlwaysShown = dup.decimalSeparatorAlwaysShown;
groupingSize = dup.groupingSize;
minExponentDigits = dup.minExponentDigits;
multiplier = dup.multiplier;
negativePrefix = dup.negativePrefix;
negativeSuffix = dup.negativeSuffix;
positivePrefix = dup.positivePrefix;
positiveSuffix = dup.positiveSuffix;
symbols = (DecimalFormatSymbols) dup.symbols.clone();
useExponentialNotation = dup.useExponentialNotation;
} }
public DecimalFormat () public DecimalFormat ()
......
...@@ -33,6 +33,7 @@ import java.util.Vector; ...@@ -33,6 +33,7 @@ import java.util.Vector;
/** /**
* @author Tom Tromey <tromey@cygnus.com> * @author Tom Tromey <tromey@cygnus.com>
* @author Jorge Aliss <jaliss@hotmail.com>
* @date March 3, 1999 * @date March 3, 1999
*/ */
/* Written using "Java Class Libraries", 2nd edition, plus online /* Written using "Java Class Libraries", 2nd edition, plus online
...@@ -40,7 +41,6 @@ import java.util.Vector; ...@@ -40,7 +41,6 @@ import java.util.Vector;
* Status: Believed complete and correct to 1.2, except serialization. * Status: Believed complete and correct to 1.2, except serialization.
* and parsing. * and parsing.
*/ */
final class MessageFormatElement final class MessageFormatElement
{ {
// Argument number. // Argument number.
...@@ -263,6 +263,11 @@ public class MessageFormat extends Format ...@@ -263,6 +263,11 @@ public class MessageFormat extends Format
return index; return index;
} }
/**
* Applies the specified pattern to this MessageFormat.
*
* @param aPattern The Pattern
*/
public void applyPattern (String newPattern) public void applyPattern (String newPattern)
{ {
pattern = newPattern; pattern = newPattern;
...@@ -280,14 +285,19 @@ public class MessageFormat extends Format ...@@ -280,14 +285,19 @@ public class MessageFormat extends Format
elts.copyInto(elements); elts.copyInto(elements);
} }
/**
* Overrides Format.clone()
*/
public Object clone () public Object clone ()
{ {
MessageFormat c = new MessageFormat (); MessageFormat c = (MessageFormat) super.clone ();
c.setLocale(locale); c.elements = (MessageFormatElement[]) elements.clone ();
c.applyPattern(pattern); return c;
return (Object) c;
} }
/**
* Overrides Format.equals(Object obj)
*/
public boolean equals (Object obj) public boolean equals (Object obj)
{ {
if (! (obj instanceof MessageFormat)) if (! (obj instanceof MessageFormat))
...@@ -297,6 +307,12 @@ public class MessageFormat extends Format ...@@ -297,6 +307,12 @@ public class MessageFormat extends Format
&& locale.equals(mf.locale)); && locale.equals(mf.locale));
} }
/**
* A convinience method to format patterns.
*
* @param aPattern The pattern used when formatting.
* @param arguments The array containing the objects to be formatted.
*/
public static String format (String pattern, Object arguments[]) public static String format (String pattern, Object arguments[])
{ {
MessageFormat mf = new MessageFormat (pattern); MessageFormat mf = new MessageFormat (pattern);
...@@ -305,6 +321,13 @@ public class MessageFormat extends Format ...@@ -305,6 +321,13 @@ public class MessageFormat extends Format
return mf.format(arguments, sb, fp).toString(); return mf.format(arguments, sb, fp).toString();
} }
/**
* Returns the pattern with the formatted objects.
*
* @param source The array containing the objects to be formatted.
* @param result The StringBuffer where the text is appened.
* @param fp A FieldPosition object (it is ignored).
*/
public final StringBuffer format (Object arguments[], StringBuffer appendBuf, public final StringBuffer format (Object arguments[], StringBuffer appendBuf,
FieldPosition ignore) FieldPosition ignore)
{ {
...@@ -358,6 +381,13 @@ public class MessageFormat extends Format ...@@ -358,6 +381,13 @@ public class MessageFormat extends Format
return appendBuf; return appendBuf;
} }
/**
* Returns the pattern with the formatted objects.
*
* @param source The object to be formatted.
* @param result The StringBuffer where the text is appened.
* @param fp A FieldPosition object (it is ignored).
*/
public final StringBuffer format (Object singleArg, StringBuffer appendBuf, public final StringBuffer format (Object singleArg, StringBuffer appendBuf,
FieldPosition ignore) FieldPosition ignore)
{ {
...@@ -377,6 +407,10 @@ public class MessageFormat extends Format ...@@ -377,6 +407,10 @@ public class MessageFormat extends Format
return format (args, appendBuf, ignore); return format (args, appendBuf, ignore);
} }
/**
* Returns an array with the Formats for
* the arguments.
*/
public Format[] getFormats () public Format[] getFormats ()
{ {
Format[] f = new Format[elements.length]; Format[] f = new Format[elements.length];
...@@ -385,11 +419,17 @@ public class MessageFormat extends Format ...@@ -385,11 +419,17 @@ public class MessageFormat extends Format
return f; return f;
} }
/**
* Returns the locale.
*/
public Locale getLocale () public Locale getLocale ()
{ {
return locale; return locale;
} }
/**
* Overrides Format.hashCode()
*/
public int hashCode () public int hashCode ()
{ {
// FIXME: not a very good hash. // FIXME: not a very good hash.
...@@ -400,6 +440,12 @@ public class MessageFormat extends Format ...@@ -400,6 +440,12 @@ public class MessageFormat extends Format
{ {
} }
/**
* Creates a new MessageFormat object with
* the specified pattern
*
* @param aPattern The Pattern
*/
public MessageFormat (String pattern) public MessageFormat (String pattern)
{ {
locale = Locale.getDefault(); locale = Locale.getDefault();
...@@ -506,11 +552,23 @@ public class MessageFormat extends Format ...@@ -506,11 +552,23 @@ public class MessageFormat extends Format
return parse (sourceStr, pos); return parse (sourceStr, pos);
} }
/**
* Sets the format for the argument at an specified
* index.
*
* @param index The index.
* @format The Format object.
*/
public void setFormat (int variableNum, Format newFormat) public void setFormat (int variableNum, Format newFormat)
{ {
elements[variableNum].setFormat = newFormat; elements[variableNum].setFormat = newFormat;
} }
/**
* Sets the formats for the arguments.
*
* @param formats An array of Format objects.
*/
public void setFormats (Format[] newFormats) public void setFormats (Format[] newFormats)
{ {
if (newFormats.length < elements.length) if (newFormats.length < elements.length)
...@@ -520,6 +578,11 @@ public class MessageFormat extends Format ...@@ -520,6 +578,11 @@ public class MessageFormat extends Format
elements[i].setFormat = newFormats[i]; elements[i].setFormat = newFormats[i];
} }
/**
* Sets the locale.
*
* @param locale A Locale
*/
public void setLocale (Locale loc) public void setLocale (Locale loc)
{ {
locale = loc; locale = loc;
...@@ -530,6 +593,9 @@ public class MessageFormat extends Format ...@@ -530,6 +593,9 @@ public class MessageFormat extends Format
} }
} }
/**
* Returns the pattern.
*/
public String toPattern () public String toPattern ()
{ {
return pattern; return pattern;
......
// RuleBasedCollator.java - Concrete class for locale-based string compare. // RuleBasedCollator.java - Concrete class for locale-based string compare.
/* Copyright (C) 1999, 2000 Free Software Foundation /* Copyright (C) 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -39,7 +39,10 @@ public class RuleBasedCollator extends Collator ...@@ -39,7 +39,10 @@ public class RuleBasedCollator extends Collator
{ {
public Object clone () public Object clone ()
{ {
return new RuleBasedCollator (this); RuleBasedCollator c = (RuleBasedCollator) super.clone ();
c.map = (Hashtable) map.clone ();
c.prefixes = (Hashtable) map.clone ();
return c;
} }
// A helper for CollationElementIterator.next(). // A helper for CollationElementIterator.next().
...@@ -352,17 +355,6 @@ public class RuleBasedCollator extends Collator ...@@ -352,17 +355,6 @@ public class RuleBasedCollator extends Collator
} }
} }
// This is a helper for clone.
private RuleBasedCollator (RuleBasedCollator other)
{
frenchAccents = other.frenchAccents;
rules = other.rules;
decmp = other.decmp;
strength = other.strength;
map = other.map;
prefixes = other.prefixes;
}
// True if we are using French-style accent ordering. // True if we are using French-style accent ordering.
private boolean frenchAccents; private boolean frenchAccents;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment