diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2012-07-31 15:19:43 +0100 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2012-07-31 15:19:43 +0100 |
commit | 9c9198d0e7ba1870d9e813010755f193da2b47f1 (patch) | |
tree | 10b09621707b02cdfaf0ad067b36bf18ca990f99 /java/text/AttributedString.java | |
parent | 008bd6c69141806e442de85064be15a19e745169 (diff) | |
download | classpath-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>
Diffstat (limited to 'java/text/AttributedString.java')
-rw-r--r-- | java/text/AttributedString.java | 44 |
1 files changed, 21 insertions, 23 deletions
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()) || |