Merged gcj-eclipse branch to trunk.

From-SVN: r120621
This commit is contained in:
Tom Tromey
2007-01-09 19:58:05 +00:00
parent c648dedbde
commit 97b8365caf
17478 changed files with 606493 additions and 100744 deletions
@@ -1,5 +1,5 @@
/* AttributedCharacterIterator.java -- Iterate over attributes
Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -53,7 +53,10 @@ import java.util.Set;
* that is defined for a particular value across an entire range of
* characters or which is undefined over a range of characters.
*
* @since 1.2
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @since 1.2
*/
public interface AttributedCharacterIterator extends CharacterIterator
{
@@ -68,7 +71,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
* This is the attribute for the language of the text. The value of
* attributes of this key type are instances of <code>Locale</code>.
*/
public static final Attribute LANGUAGE = new Attribute ("LANGUAGE");
public static final Attribute LANGUAGE = new Attribute("language");
/**
* This is the attribute for the reading form of text. This is used
@@ -77,7 +80,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
* instances of <code>Annotation</code> which wrappers a
* <code>String</code>.
*/
public static final Attribute READING = new Attribute ("READING");
public static final Attribute READING = new Attribute("reading");
/**
* This is the attribute for input method segments. The value of attributes
@@ -85,7 +88,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
* a <code>String</code>.
*/
public static final Attribute INPUT_METHOD_SEGMENT =
new Attribute ("INPUT_METHOD_SEGMENT");
new Attribute("input_method_segment");
/**
* The name of the attribute key
@@ -98,7 +101,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @param name The name of this attribute key.
*/
protected Attribute (String name)
protected Attribute(String name)
{
this.name = name;
}
@@ -156,7 +159,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
* @return <code>true</code> if the specified object is equal to this one,
* <code>false</code> otherwise.
*/
public final boolean equals (Object obj)
public final boolean equals(Object obj)
{
if (obj == this)
return true;
@@ -192,7 +195,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return A list of keys
*/
Set getAllAttributeKeys();
Set<Attribute> getAllAttributeKeys();
/**
* Returns a <code>Map</code> of the attributes defined for the current
@@ -200,7 +203,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return A <code>Map</code> of the attributes for the current character.
*/
Map getAttributes();
Map<Attribute, Object> getAttributes();
/**
* Returns the value of the specified attribute for the
@@ -211,7 +214,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return The value of the specified attribute
*/
Object getAttribute (AttributedCharacterIterator.Attribute attrib);
Object getAttribute(AttributedCharacterIterator.Attribute attrib);
/**
* Returns the index of the first character in the run that
@@ -230,7 +233,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return The start index of the run.
*/
int getRunStart (Set attribs);
int getRunStart(Set<? extends Attribute> attribs);
/**
* Returns the index of the first character in the run that
@@ -240,7 +243,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return The start index of the run.
*/
int getRunStart (AttributedCharacterIterator.Attribute attrib);
int getRunStart(AttributedCharacterIterator.Attribute attrib);
/**
* Returns the index of the character after the end of the run
@@ -259,7 +262,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return The end index of the run.
*/
int getRunLimit (Set attribs);
int getRunLimit(Set<? extends Attribute> attribs);
/**
* Returns the index of the character after the end of the run
@@ -269,6 +272,6 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return The end index of the run.
*/
int getRunLimit (AttributedCharacterIterator.Attribute attrib);
int getRunLimit(AttributedCharacterIterator.Attribute attrib);
} // interface AttributedCharacterIterator
@@ -1,5 +1,5 @@
/* AttributedString.java -- Models text with attributes
Copyright (C) 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,8 +50,11 @@ import java.util.Set;
* This class models a <code>String</code> with attributes over various
* subranges of the string. It allows applications to access this
* information via the <code>AttributedCharacterIterator</code> interface.
*
* @since 1.2
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @since 1.2
*/
public class AttributedString
{
@@ -66,23 +69,23 @@ public class AttributedString
Map attribs;
/** The beginning index of the attributes */
int begin_index;
int beginIndex;
/** The ending index of the attributes */
int end_index;
int endIndex;
/**
* Creates a new attribute range.
*
* @param attribs the attributes.
* @param begin_index the start index.
* @param end_index the end index.
* @param beginIndex the start index.
* @param endIndex the end index.
*/
AttributeRange(Map attribs, int begin_index, int end_index)
AttributeRange(Map attribs, int beginIndex, int endIndex)
{
this.attribs = attribs;
this.begin_index = begin_index;
this.end_index = end_index;
this.beginIndex = beginIndex;
this.endIndex = endIndex;
}
} // Inner class AttributeRange
@@ -116,7 +119,8 @@ public class AttributedString
* @param str The <code>String</code> to be attributed.
* @param attributes The attribute list.
*/
public AttributedString(String str, Map attributes)
public AttributedString(String str,
Map<? extends AttributedCharacterIterator.Attribute, ?> attributes)
{
this(str);
@@ -147,13 +151,13 @@ public class AttributedString
*
* @param aci The <code>AttributedCharacterIterator</code> containing the
* text and attribute information.
* @param begin_index The beginning index of the text subrange.
* @param end_index The ending index of the text subrange.
* @param beginIndex The beginning index of the text subrange.
* @param endIndex The ending index of the text subrange.
*/
public AttributedString(AttributedCharacterIterator aci, int begin_index,
int end_index)
public AttributedString(AttributedCharacterIterator aci, int beginIndex,
int endIndex)
{
this(aci, begin_index, end_index, null);
this(aci, beginIndex, endIndex, null);
}
/**
@@ -181,9 +185,9 @@ public class AttributedString
StringBuffer sb = new StringBuffer("");
// Get the valid attribute list
Set all_attribs = aci.getAllAttributeKeys();
Set allAttribs = aci.getAllAttributeKeys();
if (attributes != null)
all_attribs.retainAll(Arrays.asList(attributes));
allAttribs.retainAll(Arrays.asList(attributes));
// Loop through and extract the attributes
char c = aci.setIndex(begin);
@@ -193,7 +197,7 @@ public class AttributedString
{
sb.append(c);
Iterator iter = all_attribs.iterator();
Iterator iter = allAttribs.iterator();
while(iter.hasNext())
{
Object obj = iter.next();
@@ -206,9 +210,10 @@ public class AttributedString
(AttributedCharacterIterator.Attribute)obj;
// Make sure the attribute is defined.
int rl = aci.getRunLimit(attrib);
if (rl == -1)
Object attribObj = aci.getAttribute(attrib);
if (attribObj == null)
continue;
int rl = aci.getRunLimit(attrib);
if (rl > end)
rl = end;
rl -= begin;
@@ -220,22 +225,21 @@ public class AttributedString
// If the attribute run starts before the beginning index, we
// need to junk it if it is an Annotation.
Object attrib_obj = aci.getAttribute(attrib);
rs -= begin;
rs -= begin;
if (rs < 0)
{
if (attrib_obj instanceof Annotation)
if (attribObj instanceof Annotation)
continue;
rs = 0;
}
// Create a map object. Yes this will only contain one attribute
Map new_map = new Hashtable();
new_map.put(attrib, attrib_obj);
Map newMap = new Hashtable();
newMap.put(attrib, attribObj);
// Add it to the attribute list.
accum.add(new AttributeRange(new_map, rs, rl));
accum.add(new AttributeRange(newMap, rs, rl));
}
c = aci.next();
@@ -290,27 +294,28 @@ public class AttributedString
* specified subrange of the string.
*
* @param attributes The list of attributes.
* @param begin_index The beginning index.
* @param end_index The ending index
* @param beginIndex The beginning index.
* @param endIndex The ending index
*
* @throws NullPointerException if <code>attributes</code> is
* <code>null</code>.
* @throws IllegalArgumentException if the subrange is not valid.
*/
public void addAttributes(Map attributes, int begin_index, int end_index)
public void addAttributes(Map<? extends AttributedCharacterIterator.Attribute, ?> attributes,
int beginIndex, int endIndex)
{
if (attributes == null)
throw new NullPointerException("null attribute");
if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
(end_index <= begin_index))
if ((beginIndex < 0) || (endIndex > sci.getEndIndex()) ||
(endIndex <= beginIndex))
throw new IllegalArgumentException("bad range");
AttributeRange[] new_list = new AttributeRange[attribs.length + 1];
System.arraycopy(attribs, 0, new_list, 0, attribs.length);
attribs = new_list;
attribs[attribs.length - 1] = new AttributeRange(attributes, begin_index,
end_index);
attribs[attribs.length - 1] = new AttributeRange(attributes, beginIndex,
endIndex);
}
/**
@@ -351,20 +356,20 @@ public class AttributedString
* returned.
*
* @param attributes A list of attributes to include in the returned iterator.
* @param begin_index The beginning index of the subrange.
* @param end_index The ending index of the subrange.
* @param beginIndex The beginning index of the subrange.
* @param endIndex The ending index of the subrange.
*
* @return An <code>AttributedCharacterIterator</code> for this string.
*/
public AttributedCharacterIterator getIterator(
AttributedCharacterIterator.Attribute[] attributes,
int begin_index, int end_index)
int beginIndex, int endIndex)
{
if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
(end_index < begin_index))
if ((beginIndex < 0) || (endIndex > sci.getEndIndex()) ||
(endIndex < beginIndex))
throw new IllegalArgumentException("bad range");
return(new AttributedStringIterator(sci, attribs, begin_index, end_index,
return(new AttributedStringIterator(sci, attribs, beginIndex, endIndex,
attributes));
}
@@ -1,5 +1,5 @@
/* AttributedStringIterator.java -- Class to iterate over AttributedString
Copyright (C) 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -71,12 +71,21 @@ class AttributedStringIterator implements AttributedCharacterIterator
/*************************************************************************/
/**
* Creates a new instance.
*
* @param sci an iterator for the string content.
* @param attribs the attribute ranges.
* @param beginIndex the start index.
* @param endIndex the end index.
* @param restricts the attributes that the user is interested in.
*/
AttributedStringIterator(StringCharacterIterator sci,
AttributedString.AttributeRange[] attribs,
int begin_index, int end_index,
int beginIndex, int endIndex,
AttributedCharacterIterator.Attribute[] restricts)
{
this.ci = new StringCharacterIterator(sci, begin_index, end_index);
this.ci = new StringCharacterIterator(sci, beginIndex, endIndex);
this.attribs = attribs;
this.restricts = restricts;
}
@@ -154,8 +163,8 @@ class AttributedStringIterator implements AttributedCharacterIterator
for (int i = 0; i < attribs.length; i++)
{
if (attribs[i].begin_index > getEndIndex()
|| attribs[i].end_index <= getBeginIndex())
if (attribs[i].beginIndex > getEndIndex()
|| attribs[i].endIndex <= getBeginIndex())
continue;
Set key_set = attribs[i].attribs.keySet();
@@ -178,7 +187,7 @@ class AttributedStringIterator implements AttributedCharacterIterator
public int getRunLimit()
{
return(getRunLimit(getAttributes().keySet()));
return getRunLimit(getAllAttributeKeys());
}
public int getRunLimit(AttributedCharacterIterator.Attribute attrib)
@@ -333,7 +342,7 @@ class AttributedStringIterator implements AttributedCharacterIterator
return null;
for (int i = attribs.length - 1; i >= 0; i--)
{
if (pos >= attribs[i].begin_index && pos < attribs[i].end_index)
if (pos >= attribs[i].beginIndex && pos < attribs[i].endIndex)
{
Set keys = attribs[i].attribs.keySet();
if (keys.contains(key))
@@ -373,8 +382,8 @@ class AttributedStringIterator implements AttributedCharacterIterator
for (int i = 0; i < attribs.length; i++)
{
if ((ci.getIndex() >= attribs[i].begin_index) &&
(ci.getIndex() < attribs[i].end_index))
if ((ci.getIndex() >= attribs[i].beginIndex) &&
(ci.getIndex() < attribs[i].endIndex))
m.putAll(attribs[i].attribs);
}
+2 -1
View File
@@ -991,7 +991,8 @@ public final class Bidi
&& dir != Character.DIRECTIONALITY_ARABIC_NUMBER
&& dir != Character.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
&& dir != Character.DIRECTIONALITY_SEGMENT_SEPARATOR
&& dir != Character.DIRECTIONALITY_WHITESPACE)
&& dir != Character.DIRECTIONALITY_WHITESPACE
&& dir != Character.DIRECTIONALITY_PARAGRAPH_SEPARATOR)
return true;
}
+1 -16
View File
@@ -65,7 +65,7 @@ import java.util.Arrays;
* @author Tom Tromey (tromey@cygnus.com)
* @date March 25, 1999
*/
public final class CollationKey implements Comparable
public class CollationKey implements Comparable<CollationKey>
{
/**
* This is the <code>Collator</code> this object was created from.
@@ -111,21 +111,6 @@ public final class CollationKey implements Comparable
return key.length - ck.key.length;
}
/**
* This method compares the specified object to this one. The specified
* object must be an instance of <code>CollationKey</code> or an exception
* will be thrown. An integer is returned which indicates whether the
* specified object is less than, greater than, or equal to this object.
*
* @param obj The <code>Object</code> to compare against this one.
*
* @return A negative integer if this object is less than the specified object, 0 if it is equal or a positive integer if it is greater than the specified object.
*/
public int compareTo (Object obj)
{
return compareTo ((CollationKey) obj);
}
/**
* This method tests the specified <code>Object</code> for equality with
* this object. This will be true if and only if:
+1 -1
View File
@@ -70,7 +70,7 @@ import java.util.ResourceBundle;
* @author Aaron M. Renn (arenn@urbanophile.com)
* @date March 18, 1999
*/
public abstract class Collator implements Comparator, Cloneable
public abstract class Collator implements Comparator<Object>, Cloneable
{
/**
* This constant is a strength value which indicates that only primary
File diff suppressed because it is too large Load Diff
@@ -63,13 +63,13 @@ import java.util.ResourceBundle;
* API docs for JDK 1.2 from http://www.javasoft.com.
* Status: Believed complete and correct to 1.2.
*/
public final class DecimalFormatSymbols implements Cloneable, Serializable
public class DecimalFormatSymbols implements Cloneable, Serializable
{
public Object clone ()
{
try
{
return super.clone ();
return super.clone();
}
catch(CloneNotSupportedException e)
{
@@ -396,7 +396,7 @@ public class MessageFormat extends Format
* @param pattern 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);
StringBuffer sb = new StringBuffer ();
+13 -8
View File
@@ -218,18 +218,21 @@ public abstract class NumberFormat extends Format implements Cloneable
public final String format (long number)
{
StringBuffer sbuf = new StringBuffer(50);
format (number, sbuf, null);
format (number, sbuf, new FieldPosition(0));
return sbuf.toString();
}
public final StringBuffer format (Object obj, StringBuffer sbuf,
FieldPosition pos)
/**
* @specnote this method was final in releases before 1.5
*/
public StringBuffer format (Object obj, StringBuffer sbuf,
FieldPosition pos)
{
if (obj instanceof Number)
return format(((Number) obj).doubleValue(), sbuf, pos);
else
throw new IllegalArgumentException
("Cannot format given Object as a Number");
throw new
IllegalArgumentException("Cannot format given Object as a Number");
}
/**
@@ -351,7 +354,7 @@ public abstract class NumberFormat extends Format implements Cloneable
{
NumberFormat format;
format = computeInstance (loc, "currencyFormat", "$#,##0.00;($#,##0.00)");
format = computeInstance (loc, "currencyFormat", "\u00A4#,##0.00;(\u00A4#,##0.00)");
format.setMaximumFractionDigits(format.getCurrency().getDefaultFractionDigits());
return format;
}
@@ -720,7 +723,9 @@ public abstract class NumberFormat extends Format implements Cloneable
public final String format (double number)
{
StringBuffer sbuf = new StringBuffer(50);
format (number, sbuf, null);
FieldPosition position = new FieldPosition(0);
format (number, sbuf, position);
return sbuf.toString();
}
@@ -917,7 +917,25 @@ public class SimpleDateFormat extends DateFormat
|| ((ch < 'a' || ch > 'z')
&& (ch < 'A' || ch > 'Z')))
{
if (! expect (dateStr, pos, ch))
if (quote_start == -1 && ch == ' ')
{
// A single unquoted space in the pattern may match
// any number of spaces in the input.
int index = pos.getIndex();
int save = index;
while (index < dateStr.length()
&& Character.isWhitespace(dateStr.charAt(index)))
++index;
if (index > save)
pos.setIndex(index);
else
{
// Didn't see any whitespace.
pos.setErrorIndex(index);
return null;
}
}
else if (! expect (dateStr, pos, ch))
return null;
continue;
}