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>
* include/jvm.h: Declare _Jv_RegisterResource.
......
......@@ -350,21 +350,9 @@ public class DecimalFormat extends NumberFormat
public Object clone ()
{
return new DecimalFormat (this);
}
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;
DecimalFormat c = (DecimalFormat) super.clone ();
c.symbols = (DecimalFormatSymbols) symbols.clone ();
return c;
}
public DecimalFormat ()
......
......@@ -33,6 +33,7 @@ import java.util.Vector;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @author Jorge Aliss <jaliss@hotmail.com>
* @date March 3, 1999
*/
/* Written using "Java Class Libraries", 2nd edition, plus online
......@@ -40,7 +41,6 @@ import java.util.Vector;
* Status: Believed complete and correct to 1.2, except serialization.
* and parsing.
*/
final class MessageFormatElement
{
// Argument number.
......@@ -263,6 +263,11 @@ public class MessageFormat extends Format
return index;
}
/**
* Applies the specified pattern to this MessageFormat.
*
* @param aPattern The Pattern
*/
public void applyPattern (String newPattern)
{
pattern = newPattern;
......@@ -280,14 +285,19 @@ public class MessageFormat extends Format
elts.copyInto(elements);
}
/**
* Overrides Format.clone()
*/
public Object clone ()
{
MessageFormat c = new MessageFormat ();
c.setLocale(locale);
c.applyPattern(pattern);
return (Object) c;
MessageFormat c = (MessageFormat) super.clone ();
c.elements = (MessageFormatElement[]) elements.clone ();
return c;
}
/**
* Overrides Format.equals(Object obj)
*/
public boolean equals (Object obj)
{
if (! (obj instanceof MessageFormat))
......@@ -297,6 +307,12 @@ public class MessageFormat extends Format
&& 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[])
{
MessageFormat mf = new MessageFormat (pattern);
......@@ -305,6 +321,13 @@ public class MessageFormat extends Format
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,
FieldPosition ignore)
{
......@@ -358,6 +381,13 @@ public class MessageFormat extends Format
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,
FieldPosition ignore)
{
......@@ -377,6 +407,10 @@ public class MessageFormat extends Format
return format (args, appendBuf, ignore);
}
/**
* Returns an array with the Formats for
* the arguments.
*/
public Format[] getFormats ()
{
Format[] f = new Format[elements.length];
......@@ -385,11 +419,17 @@ public class MessageFormat extends Format
return f;
}
/**
* Returns the locale.
*/
public Locale getLocale ()
{
return locale;
}
/**
* Overrides Format.hashCode()
*/
public int hashCode ()
{
// FIXME: not a very good hash.
......@@ -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)
{
locale = Locale.getDefault();
......@@ -506,11 +552,23 @@ public class MessageFormat extends Format
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)
{
elements[variableNum].setFormat = newFormat;
}
/**
* Sets the formats for the arguments.
*
* @param formats An array of Format objects.
*/
public void setFormats (Format[] newFormats)
{
if (newFormats.length < elements.length)
......@@ -520,6 +578,11 @@ public class MessageFormat extends Format
elements[i].setFormat = newFormats[i];
}
/**
* Sets the locale.
*
* @param locale A Locale
*/
public void setLocale (Locale loc)
{
locale = loc;
......@@ -530,6 +593,9 @@ public class MessageFormat extends Format
}
}
/**
* Returns the pattern.
*/
public String toPattern ()
{
return pattern;
......
// 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.
......@@ -39,7 +39,10 @@ public class RuleBasedCollator extends Collator
{
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().
......@@ -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.
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