summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2012-07-31 15:19:43 +0100
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2012-07-31 15:19:43 +0100
commit9c9198d0e7ba1870d9e813010755f193da2b47f1 (patch)
tree10b09621707b02cdfaf0ad067b36bf18ca990f99
parent008bd6c69141806e442de85064be15a19e745169 (diff)
downloadclasspath-9c9198d0e7ba1870d9e813010755f193da2b47f1.tar.gz
Fix warnings in java.text.* and gnu.java.text.*
2012-07-03 Andrew John Hughes <gnu_andrew@member.fsf.org> Update copyright headers throughout. * gnu/java/text/AttributedFormatBuffer.java: (ranges): Add generic type information. (attributes): Likewise. (aRanges): Rename from a_ranges. (aAttributes): Add generic type information and rename from a_attributes. Convert to a list of maps rather than an array for type safety. (defaultAttr): Replace prefix with static import. (AttributedFormatBuffer(CPStringBuilder): Add generic typing. (addAttribute(int,Attribute)): Drop prefix, rename new_range to newRange. Add generic types. Use Integer.valueOf in place of new Integer. (append(String,Attribute)): Drop prefix. (append(String,int[],List)): Replace array with list. Use Integer.valueOf instead of new Integer. (append(char,Attribute)): Drop prefix. (setDefaultAttribute(Attribute)): Likewise. (getDefaultAttribute()): Likewise. (sync()): Rename a_ranges to aRanges. Drop unneeded casts. Replace array with list. (getRanges()): Rename a_ranges to aRanges. (getAttributes()): Replace map with list. Rename a_attributes to aAttributes. * gnu/java/text/FormatBuffer.java: Add static import for Attribute. * gnu/java/text/FormatCharacterIterator.java: (attributes): Replace array with list. (FormatCharacterIterator()): Likewise. (FormatCharacterIterator(String,int,List)): Switch from array to list. Update documentation. (getAllAttributeKeys()): Add generic type. Switch from array to list. (getAttributes()): Likewise. (getAttribute(Attribute)): Likewise. (getRunLimit(Set)): Likewise. (getRunLimit(Attribute)): Likewise. (getRunStart(Set)): Likewise. (getRunStart(Attribute)): Likewise. (mergeAttributes(List,int[])): Likewise. Use List in preference to Vector. Use newRanges & newAttributes rather than new_ranges and new_attributes. (append(AttributedCharacterIterator)): Likewise. (append(String,HashMap)): Likewise. (addAttributes(Map,int,int)): Likewise. (dumpTable()): Use startRange instead of start_range. Add generic types. * gnu/java/text/StringFormatBuffer.java, Add static import for Attribute. * java/text/AttributedString.java: Add static import for Attribute. (attribs): Add generic type. (AttributeRange(Map,int,int)): Likewise. (AttributedString(String,Map)): Likewise. (AttributedString(AttributedCharacterIterator, int, int, Attribute)): Drop prefix, add generic types. (addAttribute(Attribute,Object)): Drop prefix. (addAttribute(Attribute,Object,int,int)): Likewise and add generic types. (addAttributes(Map,int,int)): Add generic types. (getIterator(Attribute)): Drop prefix. (getIterator(Attribute[])): Likewise. * java/text/AttributedStringIterator.java: Add static import for Attribute. (getAllAttributeKeys()): Add generic type. (getRunLimit(Attribute)): Add generic type, drop prefix. (getRunLimit(Set)): Add generic types. (getRunStart(Attribute)): Add generic type, drop prefix. (getRunStart(Set)): Add generic types. (getAttributes()): Likewise. * java/text/Bidi.java: (formatterIndices): Add generic type. (reinsertFormattingCodes()): Drop redundant cast. * java/text/BreakIterator.java: (getInstance(String,Locale)): Add generic type to Class. * java/text/ChoiceFormat.java: (stringVec): Add generic type. (limitVec): Likewise. (applyPattern(String)): Remove redundant cast. * java/text/CollationElementIterator.java: (textDecomposition): Renamed from text_decomposition. (textIndexes): Renamed from text_indexes. (setText(String)): Add generic types. Rename a_element to aElement. Rename a_idx to aIdx. Rename key_old to keyOld. Use Integer.valueOf rather than new Integer. * java/text/DecimalFormat.java: (attributes): Add generic type. (formatToCharacterIterator(Object)): Remove redundant cast. * java/text/MessageFormat.java: (Field()): Remove unneeded warning suppression. * java/text/NumberFormat.java: (Field()): Likewise. Signed-off-by: Andrew John Hughes <gnu_andrew@member.fsf.org>
-rw-r--r--ChangeLog98
-rw-r--r--gnu/java/text/AttributedFormatBuffer.java61
-rw-r--r--gnu/java/text/FormatBuffer.java17
-rw-r--r--gnu/java/text/FormatCharacterIterator.java223
-rw-r--r--gnu/java/text/StringFormatBuffer.java19
-rw-r--r--java/text/AttributedString.java44
-rw-r--r--java/text/AttributedStringIterator.java43
-rw-r--r--java/text/Bidi.java10
-rw-r--r--java/text/BreakIterator.java4
-rw-r--r--java/text/ChoiceFormat.java8
-rw-r--r--java/text/CollationElementIterator.java73
-rw-r--r--java/text/DecimalFormat.java6
-rw-r--r--java/text/MessageFormat.java3
-rw-r--r--java/text/NumberFormat.java3
14 files changed, 367 insertions, 245 deletions
diff --git a/ChangeLog b/ChangeLog
index b572709d2..74ca3616b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,101 @@
+2012-07-03 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ Update copyright headers throughout.
+ * gnu/java/text/AttributedFormatBuffer.java:
+ (ranges): Add generic type information.
+ (attributes): Likewise.
+ (aRanges): Rename from a_ranges.
+ (aAttributes): Add generic type information and
+ rename from a_attributes. Convert to a list of
+ maps rather than an array for type safety.
+ (defaultAttr): Replace prefix with static import.
+ (AttributedFormatBuffer(CPStringBuilder): Add generic
+ typing.
+ (addAttribute(int,Attribute)): Drop prefix, rename
+ new_range to newRange. Add generic types.
+ Use Integer.valueOf in place of new Integer.
+ (append(String,Attribute)): Drop prefix.
+ (append(String,int[],List)): Replace array with list.
+ Use Integer.valueOf instead of new Integer.
+ (append(char,Attribute)): Drop prefix.
+ (setDefaultAttribute(Attribute)): Likewise.
+ (getDefaultAttribute()): Likewise.
+ (sync()): Rename a_ranges to aRanges. Drop unneeded casts.
+ Replace array with list.
+ (getRanges()): Rename a_ranges to aRanges.
+ (getAttributes()): Replace map with list. Rename a_attributes
+ to aAttributes.
+ * gnu/java/text/FormatBuffer.java:
+ Add static import for Attribute.
+ * gnu/java/text/FormatCharacterIterator.java:
+ (attributes): Replace array with list.
+ (FormatCharacterIterator()): Likewise.
+ (FormatCharacterIterator(String,int,List)): Switch from
+ array to list. Update documentation.
+ (getAllAttributeKeys()): Add generic type. Switch
+ from array to list.
+ (getAttributes()): Likewise.
+ (getAttribute(Attribute)): Likewise.
+ (getRunLimit(Set)): Likewise.
+ (getRunLimit(Attribute)): Likewise.
+ (getRunStart(Set)): Likewise.
+ (getRunStart(Attribute)): Likewise.
+ (mergeAttributes(List,int[])): Likewise. Use List
+ in preference to Vector. Use newRanges & newAttributes
+ rather than new_ranges and new_attributes.
+ (append(AttributedCharacterIterator)): Likewise.
+ (append(String,HashMap)): Likewise.
+ (addAttributes(Map,int,int)): Likewise.
+ (dumpTable()): Use startRange instead of start_range.
+ Add generic types.
+ * gnu/java/text/StringFormatBuffer.java,
+ Add static import for Attribute.
+ * java/text/AttributedString.java:
+ Add static import for Attribute.
+ (attribs): Add generic type.
+ (AttributeRange(Map,int,int)): Likewise.
+ (AttributedString(String,Map)): Likewise.
+ (AttributedString(AttributedCharacterIterator, int, int,
+ Attribute)): Drop prefix, add generic types.
+ (addAttribute(Attribute,Object)): Drop prefix.
+ (addAttribute(Attribute,Object,int,int)): Likewise
+ and add generic types.
+ (addAttributes(Map,int,int)): Add generic types.
+ (getIterator(Attribute)): Drop prefix.
+ (getIterator(Attribute[])): Likewise.
+ * java/text/AttributedStringIterator.java:
+ Add static import for Attribute.
+ (getAllAttributeKeys()): Add generic type.
+ (getRunLimit(Attribute)): Add generic type, drop
+ prefix.
+ (getRunLimit(Set)): Add generic types.
+ (getRunStart(Attribute)): Add generic type, drop
+ prefix.
+ (getRunStart(Set)): Add generic types.
+ (getAttributes()): Likewise.
+ * java/text/Bidi.java:
+ (formatterIndices): Add generic type.
+ (reinsertFormattingCodes()): Drop redundant cast.
+ * java/text/BreakIterator.java:
+ (getInstance(String,Locale)): Add generic type to Class.
+ * java/text/ChoiceFormat.java:
+ (stringVec): Add generic type.
+ (limitVec): Likewise.
+ (applyPattern(String)): Remove redundant cast.
+ * java/text/CollationElementIterator.java:
+ (textDecomposition): Renamed from text_decomposition.
+ (textIndexes): Renamed from text_indexes.
+ (setText(String)): Add generic types. Rename a_element
+ to aElement. Rename a_idx to aIdx. Rename key_old to
+ keyOld. Use Integer.valueOf rather than new Integer.
+ * java/text/DecimalFormat.java:
+ (attributes): Add generic type.
+ (formatToCharacterIterator(Object)): Remove redundant cast.
+ * java/text/MessageFormat.java:
+ (Field()): Remove unneeded warning suppression.
+ * java/text/NumberFormat.java:
+ (Field()): Likewise.
+
2012-07-01 Andrew John Hughes <ahughes@redhat.com>
PR classpath/44052
diff --git a/gnu/java/text/AttributedFormatBuffer.java b/gnu/java/text/AttributedFormatBuffer.java
index 2a89ae097..3633be920 100644
--- a/gnu/java/text/AttributedFormatBuffer.java
+++ b/gnu/java/text/AttributedFormatBuffer.java
@@ -1,5 +1,5 @@
/* AttributedFormatBuffer.java -- Implements an attributed FormatBuffer.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,10 @@ import gnu.java.lang.CPStringBuilder;
import java.text.AttributedCharacterIterator;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.text.AttributedCharacterIterator.Attribute;
/**
* This class is an implementation of a FormatBuffer with attributes.
@@ -53,12 +57,12 @@ import java.util.HashMap;
public class AttributedFormatBuffer implements FormatBuffer
{
private final CPStringBuilder buffer;
- private final ArrayList ranges;
- private final ArrayList attributes;
- private int[] a_ranges;
- private HashMap[] a_attributes;
+ private final ArrayList<Integer> ranges;
+ private final ArrayList<Map<Attribute,Object>> attributes;
+ private int[] aRanges;
+ private List<Map<Attribute,Object>> aAttributes;
private int startingRange;
- AttributedCharacterIterator.Attribute defaultAttr;
+ Attribute defaultAttr;
/**
* This constructor accepts a StringBuffer. If the buffer contains
@@ -67,8 +71,8 @@ public class AttributedFormatBuffer implements FormatBuffer
public AttributedFormatBuffer(CPStringBuilder buffer)
{
this.buffer = new CPStringBuilder(buffer);
- this.ranges = new ArrayList();
- this.attributes = new ArrayList();
+ this.ranges = new ArrayList<Integer>();
+ this.attributes = new ArrayList<Map<Attribute,Object>>();
this.defaultAttr = null;
if (buffer.length() != 0)
{
@@ -94,23 +98,23 @@ public class AttributedFormatBuffer implements FormatBuffer
* and attributes it adds exactly one attribute for the range of characters
* comprised between the last entry in 'ranges' and the specified new range.
*
- * @param new_range A new range to insert in the list.
+ * @param newRange A new range to insert in the list.
* @param attr A new attribute to insert in the list.
*/
- private final void addAttribute(int new_range, AttributedCharacterIterator.Attribute attr)
+ private final void addAttribute(int newRange, Attribute attr)
{
- HashMap map;
+ Map<Attribute,Object> map;
if (attr != null)
{
- map = new HashMap();
+ map = new HashMap<Attribute,Object>();
map.put(attr, attr);
attributes.add(map);
}
else
attributes.add(null);
- ranges.add(new Integer(new_range));
+ ranges.add(Integer.valueOf(newRange));
}
public void append(String s)
@@ -120,7 +124,7 @@ public class AttributedFormatBuffer implements FormatBuffer
buffer.append(s);
}
- public void append(String s, AttributedCharacterIterator.Attribute attr)
+ public void append(String s, Attribute attr)
{
setDefaultAttribute(attr);
startingRange = buffer.length();
@@ -128,7 +132,7 @@ public class AttributedFormatBuffer implements FormatBuffer
setDefaultAttribute(null);
}
- public void append(String s, int[] ranges, HashMap[] attrs)
+ public void append(String s, int[] ranges, List<Map<Attribute,Object>> attrs)
{
int curPos = buffer.length();
@@ -137,8 +141,8 @@ public class AttributedFormatBuffer implements FormatBuffer
{
for (int i = 0; i < ranges.length; i++)
{
- this.ranges.add(new Integer(ranges[i] + curPos));
- this.attributes.add(attrs[i]);
+ this.ranges.add(Integer.valueOf(ranges[i] + curPos));
+ this.attributes.add(attrs.get(i));
}
}
startingRange = buffer.length();
@@ -152,14 +156,14 @@ public class AttributedFormatBuffer implements FormatBuffer
buffer.append(c);
}
- public void append(char c, AttributedCharacterIterator.Attribute attr)
+ public void append(char c, Attribute attr)
{
setDefaultAttribute(attr);
buffer.append(c);
setDefaultAttribute(null);
}
- public void setDefaultAttribute(AttributedCharacterIterator.Attribute attr)
+ public void setDefaultAttribute(Attribute attr)
{
if (attr == defaultAttr)
return;
@@ -174,7 +178,7 @@ public class AttributedFormatBuffer implements FormatBuffer
startingRange = currentPos;
}
- public AttributedCharacterIterator.Attribute getDefaultAttribute()
+ public Attribute getDefaultAttribute()
{
return defaultAttr;
}
@@ -209,12 +213,11 @@ public class AttributedFormatBuffer implements FormatBuffer
addAttribute(buffer.length(), defaultAttr);
- a_ranges = new int[ranges.size()];
- for (int i = 0; i < a_ranges.length; i++)
- a_ranges[i] = ((Integer)(ranges.get (i))).intValue();
+ aRanges = new int[ranges.size()];
+ for (int i = 0; i < aRanges.length; i++)
+ aRanges[i] = ranges.get (i).intValue();
- a_attributes = new HashMap[attributes.size()];
- System.arraycopy(attributes.toArray(), 0, a_attributes, 0, a_attributes.length);
+ aAttributes = new ArrayList<Map<Attribute,Object>>(attributes);
}
/**
@@ -235,17 +238,17 @@ public class AttributedFormatBuffer implements FormatBuffer
*/
public int[] getRanges()
{
- return a_ranges;
+ return aRanges;
}
/**
* This method returns the array containing the map on the
* attributes.
*
- * @return An array of {@link java.util.Map} containing the attributes.
+ * @return A {@link java.util.List} of {@link java.util.Map}s containing the attributes.
*/
- public HashMap[] getAttributes()
+ public List<Map<Attribute,Object>> getAttributes()
{
- return a_attributes;
+ return aAttributes;
}
}
diff --git a/gnu/java/text/FormatBuffer.java b/gnu/java/text/FormatBuffer.java
index 590b16cce..2922897ee 100644
--- a/gnu/java/text/FormatBuffer.java
+++ b/gnu/java/text/FormatBuffer.java
@@ -1,5 +1,5 @@
/* FormatBuffer.java -- General interface to build attributed strings.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,10 @@ exception statement from your version. */
package gnu.java.text;
import java.text.AttributedCharacterIterator;
-import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.text.AttributedCharacterIterator.Attribute;
/**
* This interface describes a modifiable buffer which contains attributed
@@ -67,7 +70,7 @@ public interface FormatBuffer
* @param s The string to append to the buffer.
* @param attr Attribute to use for the string in the buffer.
*/
- public void append(String s, AttributedCharacterIterator.Attribute attr);
+ public void append(String s, Attribute attr);
/**
* This method appends a simple string to the buffer. This part of
@@ -79,7 +82,7 @@ public interface FormatBuffer
* to the string.
* @param attrs The attributes of the string in the buffer.
*/
- public void append(String s, int[] ranges, HashMap[] attrs);
+ public void append(String s, int[] ranges, List<Map<Attribute,Object>> attrs);
/**
* This method appends a simple char to the buffer. This part of
@@ -97,7 +100,7 @@ public interface FormatBuffer
* @param c The character to append to the buffer.
* @param attr Attribute to use for the character in the buffer.
*/
- public void append(char c, AttributedCharacterIterator.Attribute attr);
+ public void append(char c, Attribute attr);
/**
* This method changes the current default attribute for the next string
@@ -105,14 +108,14 @@ public interface FormatBuffer
*
* @param attr The attribute which will be used by default.
*/
- public void setDefaultAttribute(AttributedCharacterIterator.Attribute attr);
+ public void setDefaultAttribute(Attribute attr);
/**
* This method returns the current default attribute for the buffer.
*
* @return The default attribute for the buffer.
*/
- public AttributedCharacterIterator.Attribute getDefaultAttribute();
+ public Attribute getDefaultAttribute();
/**
* This method cuts the last characters of the buffer. The number of
diff --git a/gnu/java/text/FormatCharacterIterator.java b/gnu/java/text/FormatCharacterIterator.java
index 889394ca4..677d4d3b9 100644
--- a/gnu/java/text/FormatCharacterIterator.java
+++ b/gnu/java/text/FormatCharacterIterator.java
@@ -1,6 +1,6 @@
/* FormatCharacter.java -- Implementation of AttributedCharacterIterator for
formatters.
- Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,12 +38,15 @@ exception statement from your version. */
package gnu.java.text;
import java.text.AttributedCharacterIterator;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Vector;
+
+import static java.text.AttributedCharacterIterator.Attribute;
/**
* This class should not be put public and it is only intended to the
@@ -62,7 +65,7 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
private int charIndex;
private int attributeIndex;
private int[] ranges;
- private HashMap[] attributes;
+ private List<Map<Attribute,Object>> attributes;
private static final boolean DEBUG = false;
/**
@@ -74,7 +77,7 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
{
formattedString = "";
ranges = new int[0];
- attributes = new HashMap[0];
+ attributes = new ArrayList<Map<Attribute,Object>>(0);
}
/**
@@ -87,12 +90,13 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
* <pre>
* s = "hello";
* ranges = new int[] { 2, 6 };
- * attributes = new HashMap[2];
+ * attributes = new ArrayList<Map<Attribute,Object>>(2);
* </pre>
- * <code>"he"</code> will have the attributes <code>attributes[0]</code>,
- * <code>"llo"</code> the <code>attributes[1]</code>.
+ * <code>"he"</code> will have the attributes <code>attributes.get(0)</code>,
+ * <code>"llo"</code> the <code>attributes.get(1)</code>.
*/
- public FormatCharacterIterator (String s, int[] ranges, HashMap[] attributes)
+ public FormatCharacterIterator (String s, int[] ranges,
+ List<Map<Attribute,Object>> attributes)
{
formattedString = s;
this.ranges = ranges;
@@ -104,55 +108,57 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
* and thus are already documented.
*/
- public Set getAllAttributeKeys()
+ public Set<Attribute> getAllAttributeKeys()
{
- if (attributes != null && attributes[attributeIndex] != null)
- return attributes[attributeIndex].keySet();
+ if (attributes != null && attributes.get(attributeIndex) != null)
+ return attributes.get(attributeIndex).keySet();
else
- return new HashSet();
+ return new HashSet<Attribute>();
}
- public Map getAttributes()
+ public Map<Attribute,Object> getAttributes()
{
- if (attributes != null && attributes[attributeIndex] != null)
- return attributes[attributeIndex];
+ if (attributes != null && attributes.get(attributeIndex) != null)
+ return attributes.get(attributeIndex);
else
- return new HashMap();
+ return new HashMap<Attribute,Object>();
}
- public Object getAttribute (AttributedCharacterIterator.Attribute attrib)
+ public Object getAttribute (Attribute attrib)
{
- if (attributes != null && attributes[attributeIndex] != null)
- return attributes[attributeIndex].get (attrib);
+ if (attributes != null && attributes.get(attributeIndex) != null)
+ return attributes.get(attributeIndex).get (attrib);
else
return null;
}
- public int getRunLimit(Set reqAttrs)
+ public int getRunLimit(Set<? extends Attribute> reqAttrs)
{
if (attributes == null)
return formattedString.length();
int currentAttrIndex = attributeIndex;
- Set newKeys;
+ Set<Attribute> newKeys;
do
{
currentAttrIndex++;
- if (currentAttrIndex == attributes.length)
+ if (currentAttrIndex == attributes.size())
return formattedString.length();
- if (attributes[currentAttrIndex] == null)
+ Map<Attribute,Object> currentAttr =
+ attributes.get(currentAttrIndex);
+ if (currentAttr == null)
break;
- newKeys = attributes[currentAttrIndex].keySet();
+ newKeys = currentAttr.keySet();
}
while (newKeys.containsAll (reqAttrs));
return ranges[currentAttrIndex-1];
}
- public int getRunLimit (AttributedCharacterIterator.Attribute attribute)
+ public int getRunLimit (Attribute attribute)
{
- Set s = new HashSet();
+ Set<Attribute> s = new HashSet<Attribute>();
s.add (attribute);
return getRunLimit (s);
@@ -162,24 +168,24 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
{
if (attributes == null)
return formattedString.length();
- if (attributes[attributeIndex] == null)
+ if (attributes.get(attributeIndex) == null)
{
- for (int i=attributeIndex+1;i<attributes.length;i++)
- if (attributes[i] != null)
+ for (int i=attributeIndex+1;i<attributes.size();i++)
+ if (attributes.get(i) != null)
return ranges[i-1];
return formattedString.length();
}
- return getRunLimit (attributes[attributeIndex].keySet());
+ return getRunLimit (attributes.get(attributeIndex).keySet());
}
- public int getRunStart (Set reqAttrs)
+ public int getRunStart (Set<? extends Attribute> reqAttrs)
{
if (attributes == null)
return formattedString.length();
int currentAttrIndex = attributeIndex;
- Set newKeys = null;
+ Set<Attribute> newKeys = null;
do
{
@@ -187,9 +193,11 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
return 0;
currentAttrIndex--;
- if (attributes[currentAttrIndex] == null)
+ Map<Attribute,Object> currentAttr =
+ attributes.get(currentAttrIndex);
+ if (currentAttr == null)
break;
- newKeys = attributes[currentAttrIndex].keySet();
+ newKeys = currentAttr.keySet();
}
while (newKeys.containsAll (reqAttrs));
@@ -201,20 +209,21 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
if (attributes == null)
return 0;
- if (attributes[attributeIndex] == null)
+ Map<Attribute,Object> attrib = attributes.get(attributeIndex);
+ if (attrib == null)
{
for (int i=attributeIndex;i>0;i--)
- if (attributes[i] != null)
+ if (attributes.get(i) != null)
return ranges[attributeIndex-1];
return 0;
}
- return getRunStart (attributes[attributeIndex].keySet());
+ return getRunStart (attrib.keySet());
}
- public int getRunStart (AttributedCharacterIterator.Attribute attribute)
+ public int getRunStart (Attribute attribute)
{
- Set s = new HashSet();
+ Set<Attribute> s = new HashSet<Attribute>();
s.add (attribute);
return getRunStart (s);
@@ -261,7 +270,7 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
{
charIndex = formattedString.length()-1;
if (attributes != null)
- attributeIndex = attributes.length-1;
+ attributeIndex = attributes.size()-1;
return formattedString.charAt (charIndex);
}
@@ -306,7 +315,7 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
charIndex = position;
if (attributes != null)
{
- for (attributeIndex=0;attributeIndex<attributes.length;
+ for (attributeIndex=0;attributeIndex<attributes.size();
attributeIndex++)
if (ranges[attributeIndex] > charIndex)
break;
@@ -327,40 +336,42 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
*
* @param attributes the new array attributes to apply to the string.
*/
- public void mergeAttributes (HashMap[] attributes, int[] ranges)
+ public void mergeAttributes (List<Map<Attribute,Object>> attributes,
+ int[] ranges)
{
- Vector new_ranges = new Vector();
- Vector new_attributes = new Vector();
+ List<Integer> newRanges = new ArrayList<Integer>();
+ List<Map<Attribute,Object>> newAttributes =
+ new ArrayList<Map<Attribute,Object>>();
int i = 0, j = 0;
- debug("merging " + attributes.length + " attrs");
+ debug("merging " + attributes.size() + " attrs");
while (i < this.ranges.length && j < ranges.length)
{
- if (this.attributes[i] != null)
+ if (this.attributes.get(i) != null)
{
- new_attributes.add (this.attributes[i]);
- if (attributes[j] != null)
- this.attributes[i].putAll (attributes[j]);
+ newAttributes.add (this.attributes.get(i));
+ if (attributes.get(j) != null)
+ this.attributes.get(i).putAll (attributes.get(j));
}
else
{
- new_attributes.add (attributes[j]);
+ newAttributes.add (attributes.get(j));
}
if (this.ranges[i] == ranges[j])
{
- new_ranges.add (new Integer (ranges[j]));
+ newRanges.add (Integer.valueOf (ranges[j]));
i++;
j++;
}
else if (this.ranges[i] < ranges[j])
{
- new_ranges.add (new Integer (this.ranges[i]));
+ newRanges.add (Integer.valueOf (this.ranges[i]));
i++;
}
else
{
- new_ranges.add (new Integer (ranges[j]));
+ newRanges.add (Integer.valueOf (ranges[j]));
j++;
}
}
@@ -369,27 +380,25 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
{
for (;i<this.ranges.length;i++)
{
- new_attributes.add (this.attributes[i]);
- new_ranges.add (new Integer (this.ranges[i]));
+ newAttributes.add (this.attributes.get(i));
+ newRanges.add (Integer.valueOf (this.ranges[i]));
}
}
if (j != ranges.length)
{
for (;j<ranges.length;j++)
{
- new_attributes.add (attributes[j]);
- new_ranges.add (new Integer (ranges[j]));
+ newAttributes.add (attributes.get(j));
+ newRanges.add (Integer.valueOf (ranges[j]));
}
}
- this.attributes = new HashMap[new_attributes.size()];
- this.ranges = new int[new_ranges.size()];
- System.arraycopy (new_attributes.toArray(), 0, this.attributes,
- 0, this.attributes.length);
+ this.attributes = newAttributes;
+ this.ranges = new int[newRanges.size()];
- for (i=0;i<new_ranges.size();i++)
+ for (i=0;i<newRanges.size();i++)
{
- this.ranges[i] = ((Integer)new_ranges.elementAt (i)).intValue();
+ this.ranges[i] = newRanges.get (i).intValue();
}
dumpTable();
@@ -405,35 +414,35 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
public void append (AttributedCharacterIterator iterator)
{
char c = iterator.first();
- Vector more_ranges = new Vector();
- Vector more_attributes = new Vector();
+ List<Integer> moreRanges = new ArrayList<Integer>();
+ List<Map<Attribute,Object>> moreAttributes =
+ new ArrayList<Map<Attribute,Object>>();
do
{
formattedString = formattedString + String.valueOf (c);
// TODO: Reduce the size of the output array.
- more_attributes.add (iterator.getAttributes());
- more_ranges.add (new Integer (formattedString.length()));
+ moreAttributes.add (iterator.getAttributes());
+ moreRanges.add (Integer.valueOf (formattedString.length()));
// END TOOD
c = iterator.next();
}
while (c != DONE);
- HashMap[] new_attributes = new HashMap[attributes.length
- + more_attributes.size()];
- int[] new_ranges = new int[ranges.length + more_ranges.size()];
+ List<Map<Attribute,Object>> newAttributes =
+ new ArrayList<Map<Attribute,Object>>(attributes.size() + moreAttributes.size());
+ int[] newRanges = new int[ranges.length + moreRanges.size()];
- System.arraycopy (attributes, 0, new_attributes, 0, attributes.length);
- System.arraycopy (more_attributes.toArray(), 0, new_attributes,
- attributes.length, more_attributes.size());
+ newAttributes.addAll(attributes);
+ newAttributes.addAll(moreAttributes);
- System.arraycopy (ranges, 0, new_ranges, 0, ranges.length);
- Object[] new_ranges_array = more_ranges.toArray();
- for (int i = 0; i < more_ranges.size();i++)
- new_ranges[i+ranges.length] = ((Integer) new_ranges_array[i]).intValue();
+ System.arraycopy (ranges, 0, newRanges, 0, ranges.length);
+ Integer[] newRangesArray = moreRanges.toArray(new Integer[moreRanges.size()]);
+ for (int i = 0; i < moreRanges.size();i++)
+ newRanges[i+ranges.length] = newRangesArray[i].intValue();
- attributes = new_attributes;
- ranges = new_ranges;
+ attributes = newAttributes;
+ ranges = newRanges;
}
/**
@@ -441,28 +450,29 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
* directly in the calling parameters.
*
* @param text The string to append.
- * @param local_attributes The attributes to put on this string in the
+ * @param localAttributes The attributes to put on this string in the
* iterator. If it is <code>null</code> the string will simply have no
* attributes.
*/
- public void append (String text, HashMap local_attributes)
+ public void append (String text, HashMap<? extends Attribute,? extends Object> localAttributes)
{
- int[] new_ranges = new int[ranges.length+1];
- HashMap[] new_attributes = new HashMap[attributes.length+1];
+ int[] newRanges = new int[ranges.length+1];
+ List<Map<Attribute,Object>> newAttributes =
+ new ArrayList<Map<Attribute,Object>>(attributes.size()+1);
formattedString += text;
- System.arraycopy (attributes, 0, new_attributes, 0, attributes.length);
- System.arraycopy (ranges, 0, new_ranges, 0, ranges.length);
- new_ranges[ranges.length] = formattedString.length();
- new_attributes[attributes.length] = local_attributes;
+ newAttributes.addAll(attributes);
+ System.arraycopy (ranges, 0, newRanges, 0, ranges.length);
+ newRanges[ranges.length] = formattedString.length();
+ newAttributes.add(new HashMap<Attribute,Object>(localAttributes));
- ranges = new_ranges;
- attributes = new_attributes;
+ ranges = newRanges;
+ attributes = newAttributes;
}
/**
* This method appends a string without attributes. It is completely
- * equivalent to call {@link #append(String,HashMap)} with local_attributes
+ * equivalent to call {@link #append(String,HashMap)} with localAttributes
* equal to <code>null</code>.
*
* @param text The string to append to the iterator.
@@ -475,22 +485,31 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
/**
* This method adds a set of attributes to a range of character. The
* bounds are always inclusive. In the case many attributes have to
- * be added it is advised to directly use {@link #mergeAttributes([Ljava.util.HashMap;[I}
+ * be added it is advised to directly use {@link #mergeAttributes(java.util.List;[I}
*
* @param attributes Attributes to merge into the iterator.
- * @param range_start Lower bound of the range of characters which will receive the
+ * @param rangeStart Lower bound of the range of characters which will receive the
* attribute.
- * @param range_end Upper bound of the range of characters which will receive the
+ * @param rangeEnd Upper bound of the range of characters which will receive the
* attribute.
*
* @throws IllegalArgumentException if ranges are out of bounds.
*/
- public void addAttributes(HashMap attributes, int range_start, int range_end)
+ public void addAttributes(Map<? extends Attribute,? extends Object> attributes,
+ int rangeStart, int rangeEnd)
{
- if (range_start == 0)
- mergeAttributes(new HashMap[] { attributes }, new int[] { range_end });
+ List<Map<Attribute,Object>> mergeAttribs = new ArrayList<Map<Attribute,Object>>();
+ int[] mergeRanges;
+
+ if (rangeStart == 0)
+ mergeRanges = new int[] { rangeEnd };
else
- mergeAttributes(new HashMap[] { null, attributes }, new int[] { range_start, range_end });
+ {
+ mergeRanges = new int[] { rangeStart, rangeEnd };
+ mergeAttribs.add(null);
+ }
+ mergeAttribs.add(new HashMap<Attribute,Object>(attributes));
+ mergeAttributes(mergeAttribs, mergeRanges);
}
private void debug(String s)
@@ -501,7 +520,7 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
private void dumpTable()
{
- int start_range = 0;
+ int startRange = 0;
if (!DEBUG)
return;
@@ -509,15 +528,15 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
System.out.println("Dumping internal table:");
for (int i = 0; i < ranges.length; i++)
{
- System.out.print("\t" + start_range + " => " + ranges[i] + ":");
- if (attributes[i] == null)
+ System.out.print("\t" + startRange + " => " + ranges[i] + ":");
+ if (attributes.get(i) == null)
System.out.println("null");
else
{
- Set keyset = attributes[i].keySet();
+ Set<Attribute> keyset = attributes.get(i).keySet();
if (keyset != null)
{
- Iterator keys = keyset.iterator();
+ Iterator<Attribute> keys = keyset.iterator();
while (keys.hasNext())
System.out.print(" " + keys.next());
diff --git a/gnu/java/text/StringFormatBuffer.java b/gnu/java/text/StringFormatBuffer.java
index 2367fccb3..8374500ea 100644
--- a/gnu/java/text/StringFormatBuffer.java
+++ b/gnu/java/text/StringFormatBuffer.java
@@ -1,5 +1,5 @@
/* StringFormatBuffer.java -- Implements FormatBuffer using StringBuffer.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,10 @@ exception statement from your version. */
package gnu.java.text;
import java.text.AttributedCharacterIterator;
-import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.text.AttributedCharacterIterator.Attribute;
/**
* This class is an implementation of a FormatBuffer without attributes.
@@ -48,7 +51,7 @@ import java.util.HashMap;
public class StringFormatBuffer implements FormatBuffer
{
private final StringBuffer buffer;
- private AttributedCharacterIterator.Attribute defaultAttr;
+ private Attribute defaultAttr;
public StringFormatBuffer(int prebuffer)
{
@@ -65,12 +68,12 @@ public class StringFormatBuffer implements FormatBuffer
buffer.append(s);
}
- public void append(String s, AttributedCharacterIterator.Attribute attr)
+ public void append(String s, Attribute attr)
{
buffer.append(s);
}
- public void append(String s, int[] ranges, HashMap[] attrs)
+ public void append(String s, int[] ranges, List<Map<Attribute,Object>> attrs)
{
buffer.append(s);
}
@@ -80,17 +83,17 @@ public class StringFormatBuffer implements FormatBuffer
buffer.append(c);
}
- public void append(char c, AttributedCharacterIterator.Attribute attr)
+ public void append(char c, Attribute attr)
{
buffer.append(c);
}
- public void setDefaultAttribute(AttributedCharacterIterator.Attribute attr)
+ public void setDefaultAttribute(Attribute attr)
{
defaultAttr = attr;
}
- public AttributedCharacterIterator.Attribute getDefaultAttribute()
+ public Attribute getDefaultAttribute()
{
return defaultAttr;
}
diff --git a/java/text/AttributedString.java b/java/text/AttributedString.java
index 7ffb3d4c0..4293d7dd2 100644
--- a/java/text/AttributedString.java
+++ b/java/text/AttributedString.java
@@ -1,5 +1,5 @@
/* AttributedString.java -- Models text with attributes
- Copyright (C) 1998, 1999, 2004, 2005, 2006, Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004, 2005, 2006, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,6 +48,8 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import static java.text.AttributedCharacterIterator.Attribute;
+
/**
* This class models a <code>String</code> with attributes over various
* subranges of the string. It allows applications to access this
@@ -68,7 +70,7 @@ public class AttributedString
{
/** A Map of the attributes */
- Map attribs;
+ Map<? extends Attribute, ?> attribs;
/** The beginning index of the attributes */
int beginIndex;
@@ -83,7 +85,8 @@ public class AttributedString
* @param beginIndex the start index.
* @param endIndex the end index.
*/
- AttributeRange(Map attribs, int beginIndex, int endIndex)
+ AttributeRange(Map<? extends Attribute, ?> attribs,
+ int beginIndex, int endIndex)
{
this.attribs = attribs;
this.beginIndex = beginIndex;
@@ -122,7 +125,7 @@ public class AttributedString
* @param attributes The attribute list.
*/
public AttributedString(String str,
- Map<? extends AttributedCharacterIterator.Attribute, ?> attributes)
+ Map<? extends Attribute, ?> attributes)
{
this(str);
@@ -178,7 +181,7 @@ public class AttributedString
* <code>null</code> to include all attributes.
*/
public AttributedString(AttributedCharacterIterator aci, int begin, int end,
- AttributedCharacterIterator.Attribute[] attributes)
+ Attribute[] attributes)
{
// Validate some arguments
if ((begin < 0) || (end < begin) || end > aci.getEndIndex())
@@ -187,29 +190,28 @@ public class AttributedString
CPStringBuilder sb = new CPStringBuilder("");
// Get the valid attribute list
- Set allAttribs = aci.getAllAttributeKeys();
+ Set<Attribute> allAttribs = aci.getAllAttributeKeys();
if (attributes != null)
allAttribs.retainAll(Arrays.asList(attributes));
// Loop through and extract the attributes
char c = aci.setIndex(begin);
- ArrayList accum = new ArrayList();
+ ArrayList<AttributeRange> accum = new ArrayList<AttributeRange>();
do
{
sb.append(c);
- Iterator iter = allAttribs.iterator();
+ Iterator<Attribute> iter = allAttribs.iterator();
while(iter.hasNext())
{
Object obj = iter.next();
// What should we do if this is not true?
- if (!(obj instanceof AttributedCharacterIterator.Attribute))
+ if (!(obj instanceof Attribute))
continue;
- AttributedCharacterIterator.Attribute attrib =
- (AttributedCharacterIterator.Attribute)obj;
+ Attribute attrib = (Attribute)obj;
// Make sure the attribute is defined.
Object attribObj = aci.getAttribute(attrib);
@@ -237,7 +239,7 @@ public class AttributedString
}
// Create a map object. Yes this will only contain one attribute
- Map newMap = new Hashtable();
+ Map<Attribute,Object> newMap = new Hashtable<Attribute,Object>();
newMap.put(attrib, attribObj);
// Add it to the attribute list.
@@ -249,7 +251,7 @@ public class AttributedString
while( aci.getIndex() < end );
attribs = new AttributeRange[accum.size()];
- attribs = (AttributeRange[]) accum.toArray(attribs);
+ attribs = accum.toArray(attribs);
sci = new StringCharacterIterator(sb.toString());
}
@@ -260,8 +262,7 @@ public class AttributedString
* @param attrib The attribute to add.
* @param value The value of the attribute.
*/
- public void addAttribute(AttributedCharacterIterator.Attribute attrib,
- Object value)
+ public void addAttribute(Attribute attrib, Object value)
{
addAttribute(attrib, value, 0, sci.getEndIndex());
}
@@ -278,14 +279,13 @@ public class AttributedString
* @exception IllegalArgumentException If attribute is <code>null</code> or
* the subrange is not valid.
*/
- public void addAttribute(AttributedCharacterIterator.Attribute attrib,
- Object value, int begin, int end)
+ public void addAttribute(Attribute attrib, Object value, int begin, int end)
{
if (attrib == null)
throw new IllegalArgumentException("null attribute");
if (end <= begin)
throw new IllegalArgumentException("Requires end > begin");
- HashMap hm = new HashMap();
+ HashMap<Attribute,Object> hm = new HashMap<Attribute,Object>();
hm.put(attrib, value);
addAttributes(hm, begin, end);
@@ -303,7 +303,7 @@ public class AttributedString
* <code>null</code>.
* @throws IllegalArgumentException if the subrange is not valid.
*/
- public void addAttributes(Map<? extends AttributedCharacterIterator.Attribute, ?> attributes,
+ public void addAttributes(Map<? extends Attribute, ?> attributes,
int beginIndex, int endIndex)
{
if (attributes == null)
@@ -343,8 +343,7 @@ public class AttributedString
*
* @return An <code>AttributedCharacterIterator</code> for this string.
*/
- public AttributedCharacterIterator getIterator(
- AttributedCharacterIterator.Attribute[] attributes)
+ public AttributedCharacterIterator getIterator(Attribute[] attributes)
{
return(getIterator(attributes, 0, sci.getEndIndex()));
}
@@ -363,8 +362,7 @@ public class AttributedString
*
* @return An <code>AttributedCharacterIterator</code> for this string.
*/
- public AttributedCharacterIterator getIterator(
- AttributedCharacterIterator.Attribute[] attributes,
+ public AttributedCharacterIterator getIterator(Attribute[] attributes,
int beginIndex, int endIndex)
{
if ((beginIndex < 0) || (endIndex > sci.getEndIndex()) ||
diff --git a/java/text/AttributedStringIterator.java b/java/text/AttributedStringIterator.java
index 429bd7063..6d402cbca 100644
--- a/java/text/AttributedStringIterator.java
+++ b/java/text/AttributedStringIterator.java
@@ -1,5 +1,5 @@
/* AttributedStringIterator.java -- Class to iterate over AttributedString
- Copyright (C) 1998, 1999, 2004, 2005, 2006, Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004, 2005, 2006, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,6 +44,8 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import static java.text.AttributedCharacterIterator.Attribute;
+
/**
* This class implements the AttributedCharacterIterator interface. It
* is used by AttributedString.getIterator().
@@ -67,7 +69,7 @@ class AttributedStringIterator implements AttributedCharacterIterator
* The list of attributes that the user is interested in. We may,
* at our option, not return any other attributes.
*/
- private AttributedCharacterIterator.Attribute[] restricts;
+ private Attribute[] restricts;
/*************************************************************************/
@@ -155,9 +157,9 @@ class AttributedStringIterator implements AttributedCharacterIterator
* Returns a list of all the attribute keys that are defined anywhere
* on this string.
*/
- public Set getAllAttributeKeys()
+ public Set<Attribute> getAllAttributeKeys()
{
- HashSet s = new HashSet();
+ HashSet<Attribute> s = new HashSet<Attribute>();
if (attribs == null)
return(s);
@@ -167,8 +169,7 @@ class AttributedStringIterator implements AttributedCharacterIterator
|| attribs[i].endIndex <= getBeginIndex())
continue;
- Set key_set = attribs[i].attribs.keySet();
- Iterator iter = key_set.iterator();
+ Iterator<? extends Attribute> iter = attribs[i].attribs.keySet().iterator();
while (iter.hasNext())
{
s.add(iter.next());
@@ -190,14 +191,14 @@ class AttributedStringIterator implements AttributedCharacterIterator
return getRunLimit(getAllAttributeKeys());
}
- public int getRunLimit(AttributedCharacterIterator.Attribute attrib)
+ public int getRunLimit(Attribute attrib)
{
- HashSet s = new HashSet();
+ HashSet<Attribute> s = new HashSet<Attribute>();
s.add(attrib);
return(getRunLimit(s));
}
- public synchronized int getRunLimit(Set attributeSet)
+ public synchronized int getRunLimit(Set<? extends Attribute> attributeSet)
{
if (attributeSet == null)
return ci.getEndIndex();
@@ -207,13 +208,13 @@ class AttributedStringIterator implements AttributedCharacterIterator
int limit = current;
if (current == end)
return end;
- Map runValues = getAttributes();
+ Map<Attribute,Object> runValues = getAttributes();
while (limit < end)
{
- Iterator iterator = attributeSet.iterator();
+ Iterator<? extends Attribute> iterator = attributeSet.iterator();
while (iterator.hasNext())
{
- Attribute attributeKey = (Attribute) iterator.next();
+ Attribute attributeKey = iterator.next();
Object v1 = runValues.get(attributeKey);
Object v2 = getAttribute(attributeKey, limit + 1);
boolean changed = false;
@@ -262,11 +263,11 @@ class AttributedStringIterator implements AttributedCharacterIterator
*
* return The index of the first character in the run.
*/
- public int getRunStart(AttributedCharacterIterator.Attribute attrib)
+ public int getRunStart(Attribute attrib)
{
if (attrib == null)
return ci.getBeginIndex();
- HashSet s = new HashSet();
+ HashSet<Attribute> s = new HashSet<Attribute>();
s.add(attrib);
return(getRunStart(s));
}
@@ -279,7 +280,7 @@ class AttributedStringIterator implements AttributedCharacterIterator
*
* return The index of the first character in the run.
*/
- public int getRunStart(Set attributeSet)
+ public int getRunStart(Set<? extends Attribute> attributeSet)
{
if (attributeSet == null)
return ci.getBeginIndex();
@@ -289,14 +290,14 @@ class AttributedStringIterator implements AttributedCharacterIterator
int start = current;
if (start == begin)
return begin;
- Map runValues = getAttributes();
+ Map<Attribute, Object> runValues = getAttributes();
int prev = start - 1;
while (start > begin)
{
- Iterator iterator = attributeSet.iterator();
+ Iterator<? extends Attribute> iterator = attributeSet.iterator();
while (iterator.hasNext())
{
- Attribute attributeKey = (Attribute) iterator.next();
+ Attribute attributeKey = iterator.next();
Object v1 = runValues.get(attributeKey);
Object v2 = getAttribute(attributeKey, prev);
boolean changed = false;
@@ -340,7 +341,7 @@ class AttributedStringIterator implements AttributedCharacterIterator
{
if (pos >= attribs[i].beginIndex && pos < attribs[i].endIndex)
{
- Set keys = attribs[i].attribs.keySet();
+ Set<? extends Attribute> keys = attribs[i].attribs.keySet();
if (keys.contains(key))
{
return attribs[i].attribs.get(key);
@@ -370,9 +371,9 @@ class AttributedStringIterator implements AttributedCharacterIterator
* Return a list of all the attributes and values defined for this
* character
*/
- public Map getAttributes()
+ public Map<Attribute,Object> getAttributes()
{
- HashMap m = new HashMap();
+ HashMap<Attribute,Object> m = new HashMap<Attribute,Object>();
if (attribs == null)
return(m);
diff --git a/java/text/Bidi.java b/java/text/Bidi.java
index 6a7bd0750..532ff4e99 100644
--- a/java/text/Bidi.java
+++ b/java/text/Bidi.java
@@ -1,5 +1,5 @@
/* Bidi.java -- Bidirectional Algorithm implementation
- Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -109,7 +109,7 @@ public final class Bidi
// A list of indices where a formatting code was found. These
// are indicies into the original text -- not into the text after
// the codes have been removed.
- private ArrayList formatterIndices;
+ private ArrayList<Integer> formatterIndices;
// Indices of the starts of runs in the text.
private int[] runs;
@@ -404,7 +404,7 @@ public final class Bidi
{
// Mark this character for removal.
if (formatterIndices == null)
- formatterIndices = new ArrayList();
+ formatterIndices = new ArrayList<Integer>();
formatterIndices.add(Integer.valueOf(i));
}
else if (directionalOverride != -1)
@@ -427,7 +427,7 @@ public final class Bidi
if (i == size)
nextFmt = length;
else
- nextFmt = ((Integer) formatterIndices.get(i)).intValue();
+ nextFmt = formatterIndices.get(i).intValue();
// Non-formatter codes are from 'input' to 'nextFmt'.
int len = nextFmt - input;
System.arraycopy(levels, input, levels, output, len);
@@ -716,7 +716,7 @@ public final class Bidi
// Process from the end as we are copying the array over itself here.
for (int index = formatterIndices.size() - 1; index >= 0; --index)
{
- int nextFmt = ((Integer) formatterIndices.get(index)).intValue();
+ int nextFmt = formatterIndices.get(index).intValue();
// nextFmt points to a location in the original array. So,
// nextFmt+1 is the target of our copying. output is the location
diff --git a/java/text/BreakIterator.java b/java/text/BreakIterator.java
index 628cb7235..6fed88f82 100644
--- a/java/text/BreakIterator.java
+++ b/java/text/BreakIterator.java
@@ -1,5 +1,5 @@
/* BreakIterator.java -- Breaks text into elements
- Copyright (C) 1998, 1999, 2001, 2004, 2005, 2007
+ Copyright (C) 1998, 1999, 2001, 2004, 2005, 2007, 2012
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -160,7 +160,7 @@ public abstract class BreakIterator implements Cloneable
}
try
{
- Class k = Class.forName(className);
+ Class<?> k = Class.forName(className);
return (BreakIterator) k.newInstance();
}
catch (ClassNotFoundException x1)
diff --git a/java/text/ChoiceFormat.java b/java/text/ChoiceFormat.java
index 4842f491d..c6a508cb8 100644
--- a/java/text/ChoiceFormat.java
+++ b/java/text/ChoiceFormat.java
@@ -1,5 +1,5 @@
/* ChoiceFormat.java -- Format over a range of numbers
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2012
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -98,8 +98,8 @@ public class ChoiceFormat extends NumberFormat
// This isn't explicitly documented. But for instance we accept
// '#' as a literal hash in a format string.
int index = 0, max = newPattern.length();
- Vector stringVec = new Vector ();
- Vector limitVec = new Vector ();
+ Vector<String> stringVec = new Vector<String> ();
+ Vector<Double> limitVec = new Vector<Double> ();
final CPStringBuilder buf = new CPStringBuilder ();
while (true)
@@ -159,7 +159,7 @@ public class ChoiceFormat extends NumberFormat
choiceLimits = new double[limitVec.size()];
for (int i = 0; i < choiceLimits.length; ++i)
{
- Double d = (Double) limitVec.elementAt(i);
+ Double d = limitVec.elementAt(i);
choiceLimits[i] = d.doubleValue();
}
}
diff --git a/java/text/CollationElementIterator.java b/java/text/CollationElementIterator.java
index 0ca23d074..42452e9dc 100644
--- a/java/text/CollationElementIterator.java
+++ b/java/text/CollationElementIterator.java
@@ -1,5 +1,5 @@
/* CollationElementIterator.java -- Walks through collation elements
- Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004 Free Software Foundation
+ Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2012 Free Software Foundation
This file is part of GNU Classpath.
@@ -91,12 +91,12 @@ public final class CollationElementIterator
* Array containing the collation decomposition of the
* text given to the constructor.
*/
- private RuleBasedCollator.CollationElement[] text_decomposition;
+ private RuleBasedCollator.CollationElement[] textDecomposition;
/**
* Array containing the index of the specified block.
*/
- private int[] text_indexes;
+ private int[] textIndexes;
/**
* This method initializes a new instance of <code>CollationElementIterator</code>
@@ -130,12 +130,12 @@ public final class CollationElementIterator
RuleBasedCollator.CollationElement nextBlock()
{
- if (index >= text_decomposition.length)
+ if (index >= textDecomposition.length)
return null;
- RuleBasedCollator.CollationElement e = text_decomposition[index];
+ RuleBasedCollator.CollationElement e = textDecomposition[index];
- textIndex = text_indexes[index+1];
+ textIndex = textIndexes[index+1];
index++;
@@ -148,9 +148,9 @@ public final class CollationElementIterator
return null;
index--;
- RuleBasedCollator.CollationElement e = text_decomposition[index];
+ RuleBasedCollator.CollationElement e = textDecomposition[index];
- textIndex = text_indexes[index+1];
+ textIndex = textIndexes[index+1];
return e;
}
@@ -268,23 +268,23 @@ public final class CollationElementIterator
String work_text = text.intern();
- ArrayList a_element = new ArrayList();
- ArrayList a_idx = new ArrayList();
+ ArrayList<RuleBasedCollator.CollationElement> aElement = new ArrayList<RuleBasedCollator.CollationElement>();
+ ArrayList<Integer> aIdx = new ArrayList<Integer>();
// Build element collection ordered as they come in "text".
while (idx < work_text.length())
{
- String key, key_old;
+ String key, keyOld;
Object object = null;
int p = 1;
// IMPROVE: use a TreeMap with a prefix-ordering rule.
- key_old = key = null;
+ keyOld = key = null;
do
{
if (object != null)
- key_old = key;
+ keyOld = key;
key = work_text.substring (idx, idx+p);
object = collator.prefix_tree.get (key);
if (object != null && idx < alreadyExpanded)
@@ -294,7 +294,7 @@ public final class CollationElementIterator
prefix.expansion.startsWith(work_text.substring(0, idx)))
{
object = null;
- key = key_old;
+ key = keyOld;
}
}
p++;
@@ -302,7 +302,7 @@ public final class CollationElementIterator
while (idx+p <= work_text.length());
if (object == null)
- key = key_old;
+ key = keyOld;
RuleBasedCollator.CollationElement prefix =
(RuleBasedCollator.CollationElement) collator.prefix_tree.get (key);
@@ -322,8 +322,8 @@ public final class CollationElementIterator
RuleBasedCollator.CollationElement e =
collator.getDefaultAccentedElement (work_text.charAt (idx));
- a_element.add (e);
- a_idx.add (new Integer(idx_idx));
+ aElement.add (e);
+ aIdx.add (Integer.valueOf(idx_idx));
idx++;
alreadyExpanded--;
if (alreadyExpanded == 0)
@@ -342,15 +342,15 @@ public final class CollationElementIterator
/* This is a normal character. */
RuleBasedCollator.CollationElement e =
collator.getDefaultElement (work_text.charAt (idx));
- Integer i_ref = new Integer(idx_idx);
+ Integer iRef = Integer.valueOf(idx_idx);
/* Don't forget to mark it as a special sequence so the
* string can be ordered.
*/
- a_element.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ);
- a_idx.add (i_ref);
- a_element.add (e);
- a_idx.add (i_ref);
+ aElement.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ);
+ aIdx.add (iRef);
+ aElement.add (e);
+ aIdx.add (iRef);
idx_idx++;
idx++;
}
@@ -367,8 +367,8 @@ public final class CollationElementIterator
work_text = prefix.expansion
+ work_text.substring (idx+prefix.key.length());
idx = 0;
- a_element.add (prefix);
- a_idx.add (new Integer(idx_idx));
+ aElement.add (prefix);
+ aIdx.add (Integer.valueOf(idx_idx));
if (alreadyExpanded == 0)
idxToMove = prefix.key.length();
alreadyExpanded += prefix.expansion.length()-prefix.key.length();
@@ -378,8 +378,8 @@ public final class CollationElementIterator
/* Third case: the simplest. We have got the prefix and it
* has not to be expanded.
*/
- a_element.add (prefix);
- a_idx.add (new Integer(idx_idx));
+ aElement.add (prefix);
+ aIdx.add (Integer.valueOf(idx_idx));
idx += prefix.key.length();
/* If the sequence is in an expansion, we must decrease the
* counter.
@@ -398,14 +398,13 @@ public final class CollationElementIterator
}
}
- text_decomposition = (RuleBasedCollator.CollationElement[])
- a_element.toArray(new RuleBasedCollator.CollationElement[a_element.size()]);
- text_indexes = new int[a_idx.size()+1];
- for (int i = 0; i < a_idx.size(); i++)
+ textDecomposition = aElement.toArray(new RuleBasedCollator.CollationElement[aElement.size()]);
+ textIndexes = new int[aIdx.size()+1];
+ for (int i = 0; i < aIdx.size(); i++)
{
- text_indexes[i] = ((Integer)a_idx.get(i)).intValue();
+ textIndexes[i] = aIdx.get(i).intValue();
}
- text_indexes[a_idx.size()] = text.length();
+ textIndexes[aIdx.size()] = text.length();
}
/**
@@ -460,19 +459,19 @@ public final class CollationElementIterator
if (offset > (text.getEndIndex() - 1))
throw new IllegalArgumentException("Offset too large: " + offset);
- for (index = 0; index < text_decomposition.length; index++)
+ for (index = 0; index < textDecomposition.length; index++)
{
- if (offset <= text_indexes[index])
+ if (offset <= textIndexes[index])
break;
}
/*
- * As text_indexes[0] == 0, we should not have to take care whether index is
+ * As textIndexes[0] == 0, we should not have to take care whether index is
* greater than 0. It is always.
*/
- if (text_indexes[index] == offset)
+ if (textIndexes[index] == offset)
textIndex = offset;
else
- textIndex = text_indexes[index-1];
+ textIndex = textIndexes[index-1];
}
/**
diff --git a/java/text/DecimalFormat.java b/java/text/DecimalFormat.java
index 9f02bb8d4..77af0d396 100644
--- a/java/text/DecimalFormat.java
+++ b/java/text/DecimalFormat.java
@@ -1,5 +1,5 @@
/* DecimalFormat.java -- Formats and parses numbers
- Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -177,7 +177,7 @@ public class DecimalFormat extends NumberFormat
private boolean hasFractionalPattern;
/** Stores a list of attributes for use by formatToCharacterIterator. */
- private ArrayList attributes = new ArrayList();
+ private ArrayList<FieldPosition> attributes = new ArrayList<FieldPosition>();
/**
* Constructs a <code>DecimalFormat</code> which uses the default
@@ -438,7 +438,7 @@ public class DecimalFormat extends NumberFormat
// add NumberFormat field attributes to the AttributedString
for (int i = 0; i < attributes.size(); i++)
{
- FieldPosition pos = (FieldPosition) attributes.get(i);
+ FieldPosition pos = attributes.get(i);
Format.Field attribute = pos.getFieldAttribute();
as.addAttribute(attribute, attribute, pos.getBeginIndex(),
diff --git a/java/text/MessageFormat.java b/java/text/MessageFormat.java
index ba5805aa0..0e04b2b44 100644
--- a/java/text/MessageFormat.java
+++ b/java/text/MessageFormat.java
@@ -1,5 +1,5 @@
/* MessageFormat.java - Localized message formatting.
- Copyright (C) 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2001, 2002, 2004, 2005, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -164,7 +164,6 @@ public class MessageFormat extends Format
public static final MessageFormat.Field ARGUMENT = new MessageFormat.Field("argument");
// For deserialization
- @SuppressWarnings("unused")
private Field()
{
super("");
diff --git a/java/text/NumberFormat.java b/java/text/NumberFormat.java
index fef986bc3..555ee3739 100644
--- a/java/text/NumberFormat.java
+++ b/java/text/NumberFormat.java
@@ -1,5 +1,5 @@
/* NumberFormat.java -- Formats and parses numbers
- Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2007
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2007, 2012
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -177,7 +177,6 @@ public abstract class NumberFormat extends Format implements Cloneable
* This constructor is only used by the deserializer. Without it,
* it would fail to construct a valid object.
*/
- @SuppressWarnings("unused")
private Field()
{
super("");