提交 f8b2536d 编写于 作者: D dbhole

7117230: clean up warnings in java.text

Reviewed-by: jrose, smarks
上级 49997e44
...@@ -97,7 +97,7 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -97,7 +97,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
private String name; private String name;
// table of all instances in this class, used by readResolve // table of all instances in this class, used by readResolve
private static final Map instanceMap = new HashMap(7); private static final Map<String, Attribute> instanceMap = new HashMap<>(7);
/** /**
* Constructs an {@code Attribute} with the given name. * Constructs an {@code Attribute} with the given name.
...@@ -150,7 +150,7 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -150,7 +150,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
throw new InvalidObjectException("subclass didn't correctly implement readResolve"); throw new InvalidObjectException("subclass didn't correctly implement readResolve");
} }
Attribute instance = (Attribute) instanceMap.get(getName()); Attribute instance = instanceMap.get(getName());
if (instance != null) { if (instance != null) {
return instance; return instance;
} else { } else {
......
...@@ -61,8 +61,8 @@ public class AttributedString { ...@@ -61,8 +61,8 @@ public class AttributedString {
int runArraySize; // current size of the arrays int runArraySize; // current size of the arrays
int runCount; // actual number of runs, <= runArraySize int runCount; // actual number of runs, <= runArraySize
int runStarts[]; // start index for each run int runStarts[]; // start index for each run
Vector runAttributes[]; // vector of attribute keys for each run Vector<Attribute> runAttributes[]; // vector of attribute keys for each run
Vector runAttributeValues[]; // parallel vector of attribute values for each run Vector<Object> runAttributeValues[]; // parallel vector of attribute values for each run
/** /**
* Constructs an AttributedString instance with the given * Constructs an AttributedString instance with the given
...@@ -92,7 +92,7 @@ public class AttributedString { ...@@ -92,7 +92,7 @@ public class AttributedString {
// Determine the runs, creating a new run when the attributes // Determine the runs, creating a new run when the attributes
// differ. // differ.
int offset = 0; int offset = 0;
Map last = null; Map<Attribute,Object> last = null;
for (int counter = 0; counter < iterators.length; counter++) { for (int counter = 0; counter < iterators.length; counter++) {
AttributedCharacterIterator iterator = iterators[counter]; AttributedCharacterIterator iterator = iterators[counter];
...@@ -103,7 +103,7 @@ public class AttributedString { ...@@ -103,7 +103,7 @@ public class AttributedString {
while (index < end) { while (index < end) {
iterator.setIndex(index); iterator.setIndex(index);
Map attrs = iterator.getAttributes(); Map<Attribute,Object> attrs = iterator.getAttributes();
if (mapsDiffer(last, attrs)) { if (mapsDiffer(last, attrs)) {
setAttributes(attrs, index - start + offset); setAttributes(attrs, index - start + offset);
...@@ -156,13 +156,14 @@ public class AttributedString { ...@@ -156,13 +156,14 @@ public class AttributedString {
int attributeCount = attributes.size(); int attributeCount = attributes.size();
if (attributeCount > 0) { if (attributeCount > 0) {
createRunAttributeDataVectors(); createRunAttributeDataVectors();
Vector newRunAttributes = new Vector(attributeCount); Vector<Attribute> newRunAttributes = new Vector<>(attributeCount);
Vector newRunAttributeValues = new Vector(attributeCount); Vector<Object> newRunAttributeValues = new Vector<>(attributeCount);
runAttributes[0] = newRunAttributes; runAttributes[0] = newRunAttributes;
runAttributeValues[0] = newRunAttributeValues; runAttributeValues[0] = newRunAttributeValues;
Iterator iterator = attributes.entrySet().iterator();
Iterator<? extends Map.Entry<? extends Attribute, ?>> iterator = attributes.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next(); Map.Entry<? extends Attribute, ?> entry = iterator.next();
newRunAttributes.addElement(entry.getKey()); newRunAttributes.addElement(entry.getKey());
newRunAttributeValues.addElement(entry.getValue()); newRunAttributeValues.addElement(entry.getValue());
} }
...@@ -252,7 +253,7 @@ public class AttributedString { ...@@ -252,7 +253,7 @@ public class AttributedString {
return; return;
// Select attribute keys to be taken care of // Select attribute keys to be taken care of
HashSet keys = new HashSet(); HashSet<Attribute> keys = new HashSet<>();
if (attributes == null) { if (attributes == null) {
keys.addAll(text.getAllAttributeKeys()); keys.addAll(text.getAllAttributeKeys());
} else { } else {
...@@ -266,9 +267,9 @@ public class AttributedString { ...@@ -266,9 +267,9 @@ public class AttributedString {
// Get and set attribute runs for each attribute name. Need to // Get and set attribute runs for each attribute name. Need to
// scan from the top of the text so that we can discard any // scan from the top of the text so that we can discard any
// Annotation that is no longer applied to a subset text segment. // Annotation that is no longer applied to a subset text segment.
Iterator itr = keys.iterator(); Iterator<Attribute> itr = keys.iterator();
while (itr.hasNext()) { while (itr.hasNext()) {
Attribute attributeKey = (Attribute)itr.next(); Attribute attributeKey = itr.next();
text.setIndex(textBeginIndex); text.setIndex(textBeginIndex);
while (text.getIndex() < endIndex) { while (text.getIndex() < endIndex) {
int start = text.getRunStart(attributeKey); int start = text.getRunStart(attributeKey);
...@@ -390,10 +391,11 @@ public class AttributedString { ...@@ -390,10 +391,11 @@ public class AttributedString {
int beginRunIndex = ensureRunBreak(beginIndex); int beginRunIndex = ensureRunBreak(beginIndex);
int endRunIndex = ensureRunBreak(endIndex); int endRunIndex = ensureRunBreak(endIndex);
Iterator iterator = attributes.entrySet().iterator(); Iterator<? extends Map.Entry<? extends Attribute, ?>> iterator =
attributes.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next(); Map.Entry<? extends Attribute, ?> entry = iterator.next();
addAttributeRunData((Attribute) entry.getKey(), entry.getValue(), beginRunIndex, endRunIndex); addAttributeRunData(entry.getKey(), entry.getValue(), beginRunIndex, endRunIndex);
} }
} }
...@@ -415,8 +417,13 @@ public class AttributedString { ...@@ -415,8 +417,13 @@ public class AttributedString {
private final void createRunAttributeDataVectors() { private final void createRunAttributeDataVectors() {
// use temporary variables so things remain consistent in case of an exception // use temporary variables so things remain consistent in case of an exception
int newRunStarts[] = new int[ARRAY_SIZE_INCREMENT]; int newRunStarts[] = new int[ARRAY_SIZE_INCREMENT];
Vector newRunAttributes[] = new Vector[ARRAY_SIZE_INCREMENT];
Vector newRunAttributeValues[] = new Vector[ARRAY_SIZE_INCREMENT]; @SuppressWarnings("unchecked")
Vector<Attribute> newRunAttributes[] = (Vector<Attribute>[]) new Vector<?>[ARRAY_SIZE_INCREMENT];
@SuppressWarnings("unchecked")
Vector<Object> newRunAttributeValues[] = (Vector<Object>[]) new Vector<?>[ARRAY_SIZE_INCREMENT];
runStarts = newRunStarts; runStarts = newRunStarts;
runAttributes = newRunAttributes; runAttributes = newRunAttributes;
runAttributeValues = newRunAttributeValues; runAttributeValues = newRunAttributeValues;
...@@ -461,8 +468,13 @@ public class AttributedString { ...@@ -461,8 +468,13 @@ public class AttributedString {
if (runCount == runArraySize) { if (runCount == runArraySize) {
int newArraySize = runArraySize + ARRAY_SIZE_INCREMENT; int newArraySize = runArraySize + ARRAY_SIZE_INCREMENT;
int newRunStarts[] = new int[newArraySize]; int newRunStarts[] = new int[newArraySize];
Vector newRunAttributes[] = new Vector[newArraySize];
Vector newRunAttributeValues[] = new Vector[newArraySize]; @SuppressWarnings("unchecked")
Vector<Attribute> newRunAttributes[] = (Vector<Attribute>[]) new Vector<?>[newArraySize];
@SuppressWarnings("unchecked")
Vector<Object> newRunAttributeValues[] = (Vector<Object>[]) new Vector<?>[newArraySize];
for (int i = 0; i < runArraySize; i++) { for (int i = 0; i < runArraySize; i++) {
newRunStarts[i] = runStarts[i]; newRunStarts[i] = runStarts[i];
newRunAttributes[i] = runAttributes[i]; newRunAttributes[i] = runAttributes[i];
...@@ -476,17 +488,17 @@ public class AttributedString { ...@@ -476,17 +488,17 @@ public class AttributedString {
// make copies of the attribute information of the old run that the new one used to be part of // make copies of the attribute information of the old run that the new one used to be part of
// use temporary variables so things remain consistent in case of an exception // use temporary variables so things remain consistent in case of an exception
Vector newRunAttributes = null; Vector<Attribute> newRunAttributes = null;
Vector newRunAttributeValues = null; Vector<Object> newRunAttributeValues = null;
if (copyAttrs) { if (copyAttrs) {
Vector oldRunAttributes = runAttributes[runIndex - 1]; Vector<Attribute> oldRunAttributes = runAttributes[runIndex - 1];
Vector oldRunAttributeValues = runAttributeValues[runIndex - 1]; Vector<Object> oldRunAttributeValues = runAttributeValues[runIndex - 1];
if (oldRunAttributes != null) { if (oldRunAttributes != null) {
newRunAttributes = (Vector) oldRunAttributes.clone(); newRunAttributes = new Vector<>(oldRunAttributes);
} }
if (oldRunAttributeValues != null) { if (oldRunAttributeValues != null) {
newRunAttributeValues = (Vector) oldRunAttributeValues.clone(); newRunAttributeValues = new Vector<>(oldRunAttributeValues);
} }
} }
...@@ -511,8 +523,8 @@ public class AttributedString { ...@@ -511,8 +523,8 @@ public class AttributedString {
for (int i = beginRunIndex; i < endRunIndex; i++) { for (int i = beginRunIndex; i < endRunIndex; i++) {
int keyValueIndex = -1; // index of key and value in our vectors; assume we don't have an entry yet int keyValueIndex = -1; // index of key and value in our vectors; assume we don't have an entry yet
if (runAttributes[i] == null) { if (runAttributes[i] == null) {
Vector newRunAttributes = new Vector(); Vector<Attribute> newRunAttributes = new Vector<>();
Vector newRunAttributeValues = new Vector(); Vector<Object> newRunAttributeValues = new Vector<>();
runAttributes[i] = newRunAttributes; runAttributes[i] = newRunAttributes;
runAttributeValues[i] = newRunAttributeValues; runAttributeValues[i] = newRunAttributeValues;
} else { } else {
...@@ -597,8 +609,8 @@ public class AttributedString { ...@@ -597,8 +609,8 @@ public class AttributedString {
} }
private synchronized Object getAttribute(Attribute attribute, int runIndex) { private synchronized Object getAttribute(Attribute attribute, int runIndex) {
Vector currentRunAttributes = runAttributes[runIndex]; Vector<Attribute> currentRunAttributes = runAttributes[runIndex];
Vector currentRunAttributeValues = runAttributeValues[runIndex]; Vector<Object> currentRunAttributeValues = runAttributeValues[runIndex];
if (currentRunAttributes == null) { if (currentRunAttributes == null) {
return null; return null;
} }
...@@ -650,10 +662,10 @@ public class AttributedString { ...@@ -650,10 +662,10 @@ public class AttributedString {
} }
// returns whether all specified attributes have equal values in the runs with the given indices // returns whether all specified attributes have equal values in the runs with the given indices
private boolean attributeValuesMatch(Set attributes, int runIndex1, int runIndex2) { private boolean attributeValuesMatch(Set<? extends Attribute> attributes, int runIndex1, int runIndex2) {
Iterator iterator = attributes.iterator(); Iterator<? extends Attribute> iterator = attributes.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Attribute key = (Attribute) iterator.next(); Attribute key = iterator.next();
if (!valuesMatch(getAttribute(key, runIndex1), getAttribute(key, runIndex2))) { if (!valuesMatch(getAttribute(key, runIndex1), getAttribute(key, runIndex2))) {
return false; return false;
} }
...@@ -690,7 +702,7 @@ public class AttributedString { ...@@ -690,7 +702,7 @@ public class AttributedString {
* (typically the end of the text) to the ones specified in attrs. * (typically the end of the text) to the ones specified in attrs.
* This is only meant to be called from the constructor! * This is only meant to be called from the constructor!
*/ */
private void setAttributes(Map attrs, int offset) { private void setAttributes(Map<Attribute, Object> attrs, int offset) {
if (runCount == 0) { if (runCount == 0) {
createRunAttributeDataVectors(); createRunAttributeDataVectors();
} }
...@@ -699,12 +711,12 @@ public class AttributedString { ...@@ -699,12 +711,12 @@ public class AttributedString {
int size; int size;
if (attrs != null && (size = attrs.size()) > 0) { if (attrs != null && (size = attrs.size()) > 0) {
Vector runAttrs = new Vector(size); Vector<Attribute> runAttrs = new Vector<>(size);
Vector runValues = new Vector(size); Vector<Object> runValues = new Vector<>(size);
Iterator iterator = attrs.entrySet().iterator(); Iterator<Map.Entry<Attribute, Object>> iterator = attrs.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry)iterator.next(); Map.Entry<Attribute, Object> entry = iterator.next();
runAttrs.add(entry.getKey()); runAttrs.add(entry.getKey());
runValues.add(entry.getValue()); runValues.add(entry.getValue());
...@@ -717,7 +729,7 @@ public class AttributedString { ...@@ -717,7 +729,7 @@ public class AttributedString {
/** /**
* Returns true if the attributes specified in last and attrs differ. * Returns true if the attributes specified in last and attrs differ.
*/ */
private static boolean mapsDiffer(Map last, Map attrs) { private static <K,V> boolean mapsDiffer(Map<K, V> last, Map<K, V> attrs) {
if (last == null) { if (last == null) {
return (attrs != null && attrs.size() > 0); return (attrs != null && attrs.size() > 0);
} }
...@@ -761,7 +773,7 @@ public class AttributedString { ...@@ -761,7 +773,7 @@ public class AttributedString {
this.currentIndex = beginIndex; this.currentIndex = beginIndex;
updateRunInfo(); updateRunInfo();
if (attributes != null) { if (attributes != null) {
relevantAttributes = (Attribute[]) attributes.clone(); relevantAttributes = attributes.clone();
} }
} }
...@@ -944,7 +956,7 @@ public class AttributedString { ...@@ -944,7 +956,7 @@ public class AttributedString {
if (runAttributes == null || currentRunIndex == -1 || runAttributes[currentRunIndex] == null) { if (runAttributes == null || currentRunIndex == -1 || runAttributes[currentRunIndex] == null) {
// ??? would be nice to return null, but current spec doesn't allow it // ??? would be nice to return null, but current spec doesn't allow it
// returning Hashtable saves AttributeMap from dealing with emptiness // returning Hashtable saves AttributeMap from dealing with emptiness
return new Hashtable(); return new Hashtable<>();
} }
return new AttributeMap(currentRunIndex, beginIndex, endIndex); return new AttributeMap(currentRunIndex, beginIndex, endIndex);
} }
...@@ -954,16 +966,16 @@ public class AttributedString { ...@@ -954,16 +966,16 @@ public class AttributedString {
if (runAttributes == null) { if (runAttributes == null) {
// ??? would be nice to return null, but current spec doesn't allow it // ??? would be nice to return null, but current spec doesn't allow it
// returning HashSet saves us from dealing with emptiness // returning HashSet saves us from dealing with emptiness
return new HashSet(); return new HashSet<>();
} }
synchronized (AttributedString.this) { synchronized (AttributedString.this) {
// ??? should try to create this only once, then update if necessary, // ??? should try to create this only once, then update if necessary,
// and give callers read-only view // and give callers read-only view
Set keys = new HashSet(); Set<Attribute> keys = new HashSet<>();
int i = 0; int i = 0;
while (i < runCount) { while (i < runCount) {
if (runStarts[i] < endIndex && (i == runCount - 1 || runStarts[i + 1] > beginIndex)) { if (runStarts[i] < endIndex && (i == runCount - 1 || runStarts[i + 1] > beginIndex)) {
Vector currentRunAttributes = runAttributes[i]; Vector<Attribute> currentRunAttributes = runAttributes[i];
if (currentRunAttributes != null) { if (currentRunAttributes != null) {
int j = currentRunAttributes.size(); int j = currentRunAttributes.size();
while (j-- > 0) { while (j-- > 0) {
...@@ -1052,12 +1064,12 @@ public class AttributedString { ...@@ -1052,12 +1064,12 @@ public class AttributedString {
this.endIndex = endIndex; this.endIndex = endIndex;
} }
public Set entrySet() { public Set<Map.Entry<Attribute, Object>> entrySet() {
HashSet set = new HashSet(); HashSet<Map.Entry<Attribute, Object>> set = new HashSet<>();
synchronized (AttributedString.this) { synchronized (AttributedString.this) {
int size = runAttributes[runIndex].size(); int size = runAttributes[runIndex].size();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
Attribute key = (Attribute) runAttributes[runIndex].get(i); Attribute key = runAttributes[runIndex].get(i);
Object value = runAttributeValues[runIndex].get(i); Object value = runAttributeValues[runIndex].get(i);
if (value instanceof Annotation) { if (value instanceof Annotation) {
value = AttributedString.this.getAttributeCheckRange(key, value = AttributedString.this.getAttributeCheckRange(key,
...@@ -1066,7 +1078,8 @@ public class AttributedString { ...@@ -1066,7 +1078,8 @@ public class AttributedString {
continue; continue;
} }
} }
Map.Entry entry = new AttributeEntry(key, value);
Map.Entry<Attribute, Object> entry = new AttributeEntry(key, value);
set.add(entry); set.add(entry);
} }
} }
...@@ -1079,7 +1092,7 @@ public class AttributedString { ...@@ -1079,7 +1092,7 @@ public class AttributedString {
} }
} }
class AttributeEntry implements Map.Entry { class AttributeEntry implements Map.Entry<Attribute,Object> {
private Attribute key; private Attribute key;
private Object value; private Object value;
...@@ -1098,7 +1111,7 @@ class AttributeEntry implements Map.Entry { ...@@ -1098,7 +1111,7 @@ class AttributeEntry implements Map.Entry {
(value == null ? other.value == null : other.value.equals(value)); (value == null ? other.value == null : other.value.equals(value));
} }
public Object getKey() { public Attribute getKey() {
return key; return key;
} }
......
...@@ -145,9 +145,9 @@ class BreakDictionary { ...@@ -145,9 +145,9 @@ class BreakDictionary {
BufferedInputStream in; BufferedInputStream in;
try { try {
in = (BufferedInputStream)AccessController.doPrivileged( in = AccessController.doPrivileged(
new PrivilegedExceptionAction() { new PrivilegedExceptionAction<BufferedInputStream>() {
public Object run() throws Exception { public BufferedInputStream run() throws Exception {
return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + dictionaryName)); return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + dictionaryName));
} }
} }
......
...@@ -439,7 +439,9 @@ public abstract class BreakIterator implements Cloneable ...@@ -439,7 +439,9 @@ public abstract class BreakIterator implements Cloneable
private static final int WORD_INDEX = 1; private static final int WORD_INDEX = 1;
private static final int LINE_INDEX = 2; private static final int LINE_INDEX = 2;
private static final int SENTENCE_INDEX = 3; private static final int SENTENCE_INDEX = 3;
private static final SoftReference[] iterCache = new SoftReference[4];
@SuppressWarnings("unchecked")
private static final SoftReference<BreakIteratorCache>[] iterCache = (SoftReference<BreakIteratorCache>[]) new SoftReference<?>[4];
/** /**
* Returns a new <code>BreakIterator</code> instance * Returns a new <code>BreakIterator</code> instance
...@@ -554,7 +556,7 @@ public abstract class BreakIterator implements Cloneable ...@@ -554,7 +556,7 @@ public abstract class BreakIterator implements Cloneable
String dataName, String dataName,
String dictionaryName) { String dictionaryName) {
if (iterCache[type] != null) { if (iterCache[type] != null) {
BreakIteratorCache cache = (BreakIteratorCache) iterCache[type].get(); BreakIteratorCache cache = iterCache[type].get();
if (cache != null) { if (cache != null) {
if (cache.getLocale().equals(locale)) { if (cache.getLocale().equals(locale)) {
return cache.createBreakInstance(); return cache.createBreakInstance();
...@@ -567,13 +569,13 @@ public abstract class BreakIterator implements Cloneable ...@@ -567,13 +569,13 @@ public abstract class BreakIterator implements Cloneable
dataName, dataName,
dictionaryName); dictionaryName);
BreakIteratorCache cache = new BreakIteratorCache(locale, result); BreakIteratorCache cache = new BreakIteratorCache(locale, result);
iterCache[type] = new SoftReference(cache); iterCache[type] = new SoftReference<>(cache);
return result; return result;
} }
private static ResourceBundle getBundle(final String baseName, final Locale locale) { private static ResourceBundle getBundle(final String baseName, final Locale locale) {
return (ResourceBundle) AccessController.doPrivileged(new PrivilegedAction() { return AccessController.doPrivileged(new PrivilegedAction<ResourceBundle>() {
public Object run() { public ResourceBundle run() {
return ResourceBundle.getBundle(baseName, locale); return ResourceBundle.getBundle(baseName, locale);
} }
}); });
......
...@@ -41,7 +41,7 @@ class CharacterIteratorFieldDelegate implements Format.FieldDelegate { ...@@ -41,7 +41,7 @@ class CharacterIteratorFieldDelegate implements Format.FieldDelegate {
* for existing regions result in invoking addAttribute on the existing * for existing regions result in invoking addAttribute on the existing
* AttributedStrings. * AttributedStrings.
*/ */
private ArrayList attributedStrings; private ArrayList<AttributedString> attributedStrings;
/** /**
* Running count of the number of characters that have * Running count of the number of characters that have
* been encountered. * been encountered.
...@@ -50,7 +50,7 @@ class CharacterIteratorFieldDelegate implements Format.FieldDelegate { ...@@ -50,7 +50,7 @@ class CharacterIteratorFieldDelegate implements Format.FieldDelegate {
CharacterIteratorFieldDelegate() { CharacterIteratorFieldDelegate() {
attributedStrings = new ArrayList(); attributedStrings = new ArrayList<>();
} }
public void formatted(Format.Field attr, Object value, int start, int end, public void formatted(Format.Field attr, Object value, int start, int end,
...@@ -62,7 +62,7 @@ class CharacterIteratorFieldDelegate implements Format.FieldDelegate { ...@@ -62,7 +62,7 @@ class CharacterIteratorFieldDelegate implements Format.FieldDelegate {
int asIndex = attributedStrings.size() - 1; int asIndex = attributedStrings.size() - 1;
while (start < index) { while (start < index) {
AttributedString as = (AttributedString)attributedStrings. AttributedString as = attributedStrings.
get(asIndex--); get(asIndex--);
int newIndex = index - as.length(); int newIndex = index - as.length();
int aStart = Math.max(0, start - newIndex); int aStart = Math.max(0, start - newIndex);
...@@ -116,8 +116,8 @@ class CharacterIteratorFieldDelegate implements Format.FieldDelegate { ...@@ -116,8 +116,8 @@ class CharacterIteratorFieldDelegate implements Format.FieldDelegate {
AttributedCharacterIterator[iCount]; AttributedCharacterIterator[iCount];
for (int counter = 0; counter < iCount; counter++) { for (int counter = 0; counter < iCount; counter++) {
iterators[counter] = ((AttributedString)attributedStrings. iterators[counter] = attributedStrings.
get(counter)).getIterator(); get(counter).getIterator();
} }
return new AttributedString(iterators).getIterator(); return new AttributedString(iterators).getIterator();
} }
......
...@@ -457,8 +457,8 @@ public class ChoiceFormat extends NumberFormat { ...@@ -457,8 +457,8 @@ public class ChoiceFormat extends NumberFormat {
{ {
ChoiceFormat other = (ChoiceFormat) super.clone(); ChoiceFormat other = (ChoiceFormat) super.clone();
// for primitives or immutables, shallow clone is enough // for primitives or immutables, shallow clone is enough
other.choiceLimits = (double[]) choiceLimits.clone(); other.choiceLimits = choiceLimits.clone();
other.choiceFormats = (String[]) choiceFormats.clone(); other.choiceFormats = choiceFormats.clone();
return other; return other;
} }
......
...@@ -412,6 +412,7 @@ public final class CollationElementIterator ...@@ -412,6 +412,7 @@ public final class CollationElementIterator
* @param newOffset The new character offset into the original text. * @param newOffset The new character offset into the original text.
* @since 1.2 * @since 1.2
*/ */
@SuppressWarnings("deprecation") // getBeginIndex, getEndIndex and setIndex are deprecated
public void setOffset(int newOffset) public void setOffset(int newOffset)
{ {
if (text != null) { if (text != null) {
...@@ -645,14 +646,14 @@ public final class CollationElementIterator ...@@ -645,14 +646,14 @@ public final class CollationElementIterator
{ {
// First get the ordering of this single character, // First get the ordering of this single character,
// which is always the first element in the list // which is always the first element in the list
Vector list = ordering.getContractValues(ch); Vector<EntryPair> list = ordering.getContractValues(ch);
EntryPair pair = (EntryPair)list.firstElement(); EntryPair pair = list.firstElement();
int order = pair.value; int order = pair.value;
// find out the length of the longest contracting character sequence in the list. // find out the length of the longest contracting character sequence in the list.
// There's logic in the builder code to make sure the longest sequence is always // There's logic in the builder code to make sure the longest sequence is always
// the last. // the last.
pair = (EntryPair)list.lastElement(); pair = list.lastElement();
int maxLength = pair.entryName.length(); int maxLength = pair.entryName.length();
// (the Normalizer is cloned here so that the seeking we do in the next loop // (the Normalizer is cloned here so that the seeking we do in the next loop
...@@ -684,7 +685,7 @@ public final class CollationElementIterator ...@@ -684,7 +685,7 @@ public final class CollationElementIterator
// to this sequence // to this sequence
maxLength = 1; maxLength = 1;
for (int i = list.size() - 1; i > 0; i--) { for (int i = list.size() - 1; i > 0; i--) {
pair = (EntryPair)list.elementAt(i); pair = list.elementAt(i);
if (!pair.fwd) if (!pair.fwd)
continue; continue;
...@@ -721,11 +722,11 @@ public final class CollationElementIterator ...@@ -721,11 +722,11 @@ public final class CollationElementIterator
// rather than off. Notice that we still use append() and startsWith() when // rather than off. Notice that we still use append() and startsWith() when
// working on the fragment. This is because the entry pairs that are used // working on the fragment. This is because the entry pairs that are used
// in reverse iteration have their names reversed already. // in reverse iteration have their names reversed already.
Vector list = ordering.getContractValues(ch); Vector<EntryPair> list = ordering.getContractValues(ch);
EntryPair pair = (EntryPair)list.firstElement(); EntryPair pair = list.firstElement();
int order = pair.value; int order = pair.value;
pair = (EntryPair)list.lastElement(); pair = list.lastElement();
int maxLength = pair.entryName.length(); int maxLength = pair.entryName.length();
NormalizerBase tempText = (NormalizerBase)text.clone(); NormalizerBase tempText = (NormalizerBase)text.clone();
...@@ -747,7 +748,7 @@ public final class CollationElementIterator ...@@ -747,7 +748,7 @@ public final class CollationElementIterator
maxLength = 1; maxLength = 1;
for (int i = list.size() - 1; i > 0; i--) { for (int i = list.size() - 1; i > 0; i--) {
pair = (EntryPair)list.elementAt(i); pair = list.elementAt(i);
if (pair.fwd) if (pair.fwd)
continue; continue;
......
...@@ -798,7 +798,7 @@ public abstract class DateFormat extends Format { ...@@ -798,7 +798,7 @@ public abstract class DateFormat extends Format {
private static final long serialVersionUID = 7441350119349544720L; private static final long serialVersionUID = 7441350119349544720L;
// table of all instances in this class, used by readResolve // table of all instances in this class, used by readResolve
private static final Map instanceMap = new HashMap(18); private static final Map<String, Field> instanceMap = new HashMap<>(18);
// Maps from Calendar constant (such as Calendar.ERA) to Field // Maps from Calendar constant (such as Calendar.ERA) to Field
// constant (such as Field.ERA). // constant (such as Field.ERA).
private static final Field[] calendarToFieldMapping = private static final Field[] calendarToFieldMapping =
......
...@@ -2051,7 +2051,7 @@ public class DecimalFormat extends NumberFormat { ...@@ -2051,7 +2051,7 @@ public class DecimalFormat extends NumberFormat {
* @return FieldPosition array of the resulting fields. * @return FieldPosition array of the resulting fields.
*/ */
private FieldPosition[] expandAffix(String pattern) { private FieldPosition[] expandAffix(String pattern) {
ArrayList positions = null; ArrayList<FieldPosition> positions = null;
int stringIndex = 0; int stringIndex = 0;
for (int i=0; i<pattern.length(); ) { for (int i=0; i<pattern.length(); ) {
char c = pattern.charAt(i++); char c = pattern.charAt(i++);
...@@ -2071,7 +2071,7 @@ public class DecimalFormat extends NumberFormat { ...@@ -2071,7 +2071,7 @@ public class DecimalFormat extends NumberFormat {
} }
if (string.length() > 0) { if (string.length() > 0) {
if (positions == null) { if (positions == null) {
positions = new ArrayList(2); positions = new ArrayList<>(2);
} }
FieldPosition fp = new FieldPosition(Field.CURRENCY); FieldPosition fp = new FieldPosition(Field.CURRENCY);
fp.setBeginIndex(stringIndex); fp.setBeginIndex(stringIndex);
...@@ -2098,7 +2098,7 @@ public class DecimalFormat extends NumberFormat { ...@@ -2098,7 +2098,7 @@ public class DecimalFormat extends NumberFormat {
} }
if (fieldID != null) { if (fieldID != null) {
if (positions == null) { if (positions == null) {
positions = new ArrayList(2); positions = new ArrayList<>(2);
} }
FieldPosition fp = new FieldPosition(fieldID, field); FieldPosition fp = new FieldPosition(fieldID, field);
fp.setBeginIndex(stringIndex); fp.setBeginIndex(stringIndex);
...@@ -2109,7 +2109,7 @@ public class DecimalFormat extends NumberFormat { ...@@ -2109,7 +2109,7 @@ public class DecimalFormat extends NumberFormat {
stringIndex++; stringIndex++;
} }
if (positions != null) { if (positions != null) {
return (FieldPosition[])positions.toArray(EmptyFieldPositionArray); return positions.toArray(EmptyFieldPositionArray);
} }
return EmptyFieldPositionArray; return EmptyFieldPositionArray;
} }
......
...@@ -356,9 +356,9 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator { ...@@ -356,9 +356,9 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
// continues in this way until we either successfully make it all the way // continues in this way until we either successfully make it all the way
// across the range, or exhaust all of our combinations of break // across the range, or exhaust all of our combinations of break
// positions.) // positions.)
Stack currentBreakPositions = new Stack(); Stack<Integer> currentBreakPositions = new Stack<>();
Stack possibleBreakPositions = new Stack(); Stack<Integer> possibleBreakPositions = new Stack<>();
Vector wrongBreakPositions = new Vector(); Vector<Integer> wrongBreakPositions = new Vector<>();
// the dictionary is implemented as a trie, which is treated as a state // the dictionary is implemented as a trie, which is treated as a state
// machine. -1 represents the end of a legal word. Every word in the // machine. -1 represents the end of a legal word. Every word in the
...@@ -374,7 +374,7 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator { ...@@ -374,7 +374,7 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
// farthest as real break positions, and then start over from scratch with // farthest as real break positions, and then start over from scratch with
// the character where the error occurred. // the character where the error occurred.
int farthestEndPoint = text.getIndex(); int farthestEndPoint = text.getIndex();
Stack bestBreakPositions = null; Stack<Integer> bestBreakPositions = null;
// initialize (we always exit the loop with a break statement) // initialize (we always exit the loop with a break statement)
c = getCurrent(); c = getCurrent();
...@@ -409,7 +409,11 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator { ...@@ -409,7 +409,11 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
// case there's an error in the text // case there's an error in the text
if (text.getIndex() > farthestEndPoint) { if (text.getIndex() > farthestEndPoint) {
farthestEndPoint = text.getIndex(); farthestEndPoint = text.getIndex();
bestBreakPositions = (Stack)(currentBreakPositions.clone());
@SuppressWarnings("unchecked")
Stack<Integer> currentBreakPositionsCopy = (Stack<Integer>) currentBreakPositions.clone();
bestBreakPositions = currentBreakPositionsCopy;
} }
// wrongBreakPositions is a list of all break positions // wrongBreakPositions is a list of all break positions
...@@ -448,7 +452,7 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator { ...@@ -448,7 +452,7 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
} }
else { else {
if ((currentBreakPositions.size() == 0 || if ((currentBreakPositions.size() == 0 ||
((Integer)(currentBreakPositions.peek())).intValue() != text.getIndex()) currentBreakPositions.peek().intValue() != text.getIndex())
&& text.getIndex() != startPos) { && text.getIndex() != startPos) {
currentBreakPositions.push(new Integer(text.getIndex())); currentBreakPositions.push(new Integer(text.getIndex()));
} }
...@@ -463,15 +467,15 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator { ...@@ -463,15 +467,15 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
// it. Then back up to that position and start over from there (i.e., // it. Then back up to that position and start over from there (i.e.,
// treat that position as the beginning of a new word) // treat that position as the beginning of a new word)
else { else {
Integer temp = (Integer)possibleBreakPositions.pop(); Integer temp = possibleBreakPositions.pop();
Object temp2 = null; Integer temp2 = null;
while (!currentBreakPositions.isEmpty() && temp.intValue() < while (!currentBreakPositions.isEmpty() && temp.intValue() <
((Integer)currentBreakPositions.peek()).intValue()) { currentBreakPositions.peek().intValue()) {
temp2 = currentBreakPositions.pop(); temp2 = currentBreakPositions.pop();
wrongBreakPositions.addElement(temp2); wrongBreakPositions.addElement(temp2);
} }
currentBreakPositions.push(temp); currentBreakPositions.push(temp);
text.setIndex(((Integer)currentBreakPositions.peek()).intValue()); text.setIndex(currentBreakPositions.peek().intValue());
} }
// re-sync "c" for the next go-round, and drop out of the loop if // re-sync "c" for the next go-round, and drop out of the loop if
...@@ -507,7 +511,7 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator { ...@@ -507,7 +511,7 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
cachedBreakPositions[0] = startPos; cachedBreakPositions[0] = startPos;
for (int i = 0; i < currentBreakPositions.size(); i++) { for (int i = 0; i < currentBreakPositions.size(); i++) {
cachedBreakPositions[i + 1] = ((Integer)currentBreakPositions.elementAt(i)).intValue(); cachedBreakPositions[i + 1] = currentBreakPositions.elementAt(i).intValue();
} }
positionInCache = 0; positionInCache = 0;
} }
......
...@@ -88,19 +88,19 @@ final class MergeCollation { ...@@ -88,19 +88,19 @@ final class MergeCollation {
public String getPattern(boolean withWhiteSpace) { public String getPattern(boolean withWhiteSpace) {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
PatternEntry tmp = null; PatternEntry tmp = null;
ArrayList extList = null; ArrayList<PatternEntry> extList = null;
int i; int i;
for (i = 0; i < patterns.size(); ++i) { for (i = 0; i < patterns.size(); ++i) {
PatternEntry entry = (PatternEntry) patterns.get(i); PatternEntry entry = patterns.get(i);
if (entry.extension.length() != 0) { if (entry.extension.length() != 0) {
if (extList == null) if (extList == null)
extList = new ArrayList(); extList = new ArrayList<>();
extList.add(entry); extList.add(entry);
} else { } else {
if (extList != null) { if (extList != null) {
PatternEntry last = findLastWithNoExtension(i-1); PatternEntry last = findLastWithNoExtension(i-1);
for (int j = extList.size() - 1; j >= 0 ; j--) { for (int j = extList.size() - 1; j >= 0 ; j--) {
tmp = (PatternEntry)(extList.get(j)); tmp = extList.get(j);
tmp.addToBuffer(result, false, withWhiteSpace, last); tmp.addToBuffer(result, false, withWhiteSpace, last);
} }
extList = null; extList = null;
...@@ -111,7 +111,7 @@ final class MergeCollation { ...@@ -111,7 +111,7 @@ final class MergeCollation {
if (extList != null) { if (extList != null) {
PatternEntry last = findLastWithNoExtension(i-1); PatternEntry last = findLastWithNoExtension(i-1);
for (int j = extList.size() - 1; j >= 0 ; j--) { for (int j = extList.size() - 1; j >= 0 ; j--) {
tmp = (PatternEntry)(extList.get(j)); tmp = extList.get(j);
tmp.addToBuffer(result, false, withWhiteSpace, last); tmp.addToBuffer(result, false, withWhiteSpace, last);
} }
extList = null; extList = null;
...@@ -121,7 +121,7 @@ final class MergeCollation { ...@@ -121,7 +121,7 @@ final class MergeCollation {
private final PatternEntry findLastWithNoExtension(int i) { private final PatternEntry findLastWithNoExtension(int i) {
for (--i;i >= 0; --i) { for (--i;i >= 0; --i) {
PatternEntry entry = (PatternEntry) patterns.get(i); PatternEntry entry = patterns.get(i);
if (entry.extension.length() == 0) { if (entry.extension.length() == 0) {
return entry; return entry;
} }
...@@ -149,7 +149,7 @@ final class MergeCollation { ...@@ -149,7 +149,7 @@ final class MergeCollation {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
for (int i = 0; i < patterns.size(); ++i) for (int i = 0; i < patterns.size(); ++i)
{ {
PatternEntry entry = (PatternEntry) patterns.get(i); PatternEntry entry = patterns.get(i);
if (entry != null) { if (entry != null) {
entry.addToBuffer(result, true, withWhiteSpace, null); entry.addToBuffer(result, true, withWhiteSpace, null);
} }
...@@ -198,13 +198,13 @@ final class MergeCollation { ...@@ -198,13 +198,13 @@ final class MergeCollation {
* @return the requested pattern entry * @return the requested pattern entry
*/ */
public PatternEntry getItemAt(int index) { public PatternEntry getItemAt(int index) {
return (PatternEntry) patterns.get(index); return patterns.get(index);
} }
//============================================================ //============================================================
// privates // privates
//============================================================ //============================================================
ArrayList patterns = new ArrayList(); // a list of PatternEntries ArrayList<PatternEntry> patterns = new ArrayList<>(); // a list of PatternEntries
private transient PatternEntry saveEntry = null; private transient PatternEntry saveEntry = null;
private transient PatternEntry lastEntry = null; private transient PatternEntry lastEntry = null;
...@@ -326,7 +326,7 @@ final class MergeCollation { ...@@ -326,7 +326,7 @@ final class MergeCollation {
} else { } else {
int i; int i;
for (i = patterns.size() - 1; i >= 0; --i) { for (i = patterns.size() - 1; i >= 0; --i) {
PatternEntry e = (PatternEntry) patterns.get(i); PatternEntry e = patterns.get(i);
if (e.chars.regionMatches(0,entry.chars,0, if (e.chars.regionMatches(0,entry.chars,0,
e.chars.length())) { e.chars.length())) {
excessChars.append(entry.chars.substring(e.chars.length(), excessChars.append(entry.chars.substring(e.chars.length(),
......
...@@ -422,6 +422,7 @@ public class MessageFormat extends Format { ...@@ -422,6 +422,7 @@ public class MessageFormat extends Format {
* @param pattern the pattern for this message format * @param pattern the pattern for this message format
* @exception IllegalArgumentException if the pattern is invalid * @exception IllegalArgumentException if the pattern is invalid
*/ */
@SuppressWarnings("fallthrough") // fallthrough in switch is expected, suppress it
public void applyPattern(String pattern) { public void applyPattern(String pattern) {
StringBuilder[] segments = new StringBuilder[4]; StringBuilder[] segments = new StringBuilder[4];
// Allocate only segments[SEG_RAW] here. The rest are // Allocate only segments[SEG_RAW] here. The rest are
...@@ -897,7 +898,7 @@ public class MessageFormat extends Format { ...@@ -897,7 +898,7 @@ public class MessageFormat extends Format {
*/ */
public AttributedCharacterIterator formatToCharacterIterator(Object arguments) { public AttributedCharacterIterator formatToCharacterIterator(Object arguments) {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
ArrayList iterators = new ArrayList(); ArrayList<AttributedCharacterIterator> iterators = new ArrayList<>();
if (arguments == null) { if (arguments == null) {
throw new NullPointerException( throw new NullPointerException(
...@@ -908,7 +909,7 @@ public class MessageFormat extends Format { ...@@ -908,7 +909,7 @@ public class MessageFormat extends Format {
return createAttributedCharacterIterator(""); return createAttributedCharacterIterator("");
} }
return createAttributedCharacterIterator( return createAttributedCharacterIterator(
(AttributedCharacterIterator[])iterators.toArray( iterators.toArray(
new AttributedCharacterIterator[iterators.size()])); new AttributedCharacterIterator[iterators.size()]));
} }
...@@ -1074,14 +1075,14 @@ public class MessageFormat extends Format { ...@@ -1074,14 +1075,14 @@ public class MessageFormat extends Format {
MessageFormat other = (MessageFormat) super.clone(); MessageFormat other = (MessageFormat) super.clone();
// clone arrays. Can't do with utility because of bug in Cloneable // clone arrays. Can't do with utility because of bug in Cloneable
other.formats = (Format[]) formats.clone(); // shallow clone other.formats = formats.clone(); // shallow clone
for (int i = 0; i < formats.length; ++i) { for (int i = 0; i < formats.length; ++i) {
if (formats[i] != null) if (formats[i] != null)
other.formats[i] = (Format)formats[i].clone(); other.formats[i] = (Format)formats[i].clone();
} }
// for primitives or immutables, shallow clone is enough // for primitives or immutables, shallow clone is enough
other.offsets = (int[]) offsets.clone(); other.offsets = offsets.clone();
other.argumentNumbers = (int[]) argumentNumbers.clone(); other.argumentNumbers = argumentNumbers.clone();
return other; return other;
} }
...@@ -1224,7 +1225,7 @@ public class MessageFormat extends Format { ...@@ -1224,7 +1225,7 @@ public class MessageFormat extends Format {
* expected by the format element(s) that use it. * expected by the format element(s) that use it.
*/ */
private StringBuffer subformat(Object[] arguments, StringBuffer result, private StringBuffer subformat(Object[] arguments, StringBuffer result,
FieldPosition fp, List characterIterators) { FieldPosition fp, List<AttributedCharacterIterator> characterIterators) {
// note: this implementation assumes a fast substring & index. // note: this implementation assumes a fast substring & index.
// if this is not true, would be better to append chars one by one. // if this is not true, would be better to append chars one by one.
int lastOffset = 0; int lastOffset = 0;
......
...@@ -756,7 +756,7 @@ public abstract class NumberFormat extends Format { ...@@ -756,7 +756,7 @@ public abstract class NumberFormat extends Format {
} }
/* try the cache first */ /* try the cache first */
String[] numberPatterns = (String[])cachedLocaleData.get(desiredLocale); String[] numberPatterns = cachedLocaleData.get(desiredLocale);
if (numberPatterns == null) { /* cache miss */ if (numberPatterns == null) { /* cache miss */
ResourceBundle resource = LocaleData.getNumberFormatData(desiredLocale); ResourceBundle resource = LocaleData.getNumberFormatData(desiredLocale);
numberPatterns = resource.getStringArray("NumberPatterns"); numberPatterns = resource.getStringArray("NumberPatterns");
...@@ -844,7 +844,7 @@ public abstract class NumberFormat extends Format { ...@@ -844,7 +844,7 @@ public abstract class NumberFormat extends Format {
/** /**
* Cache to hold the NumberPatterns of a Locale. * Cache to hold the NumberPatterns of a Locale.
*/ */
private static final Hashtable cachedLocaleData = new Hashtable(3); private static final Hashtable<Locale, String[]> cachedLocaleData = new Hashtable<>(3);
// Constants used by factory methods to specify a style of format. // Constants used by factory methods to specify a style of format.
private static final int NUMBERSTYLE = 0; private static final int NUMBERSTYLE = 0;
...@@ -1035,7 +1035,7 @@ public abstract class NumberFormat extends Format { ...@@ -1035,7 +1035,7 @@ public abstract class NumberFormat extends Format {
private static final long serialVersionUID = 7494728892700160890L; private static final long serialVersionUID = 7494728892700160890L;
// table of all instances in this class, used by readResolve // table of all instances in this class, used by readResolve
private static final Map instanceMap = new HashMap(11); private static final Map<String, Field> instanceMap = new HashMap<>(11);
/** /**
* Creates a Field instance with the specified * Creates a Field instance with the specified
......
...@@ -49,6 +49,8 @@ package java.text; ...@@ -49,6 +49,8 @@ package java.text;
public public
class ParseException extends Exception { class ParseException extends Exception {
private static final long serialVersionUID = 2703218443322787634L;
/** /**
* Constructs a ParseException with the specified detail message and * Constructs a ParseException with the specified detail message and
* offset. * offset.
......
...@@ -112,8 +112,8 @@ final class RBCollationTables { ...@@ -112,8 +112,8 @@ final class RBCollationTables {
void fillInTables(boolean f2ary, void fillInTables(boolean f2ary,
boolean swap, boolean swap,
UCompactIntArray map, UCompactIntArray map,
Vector cTbl, Vector<Vector<EntryPair>> cTbl,
Vector eTbl, Vector<int[]> eTbl,
IntHashtable cFlgs, IntHashtable cFlgs,
short mso, short mso,
short mto) { short mto) {
...@@ -155,18 +155,18 @@ final class RBCollationTables { ...@@ -155,18 +155,18 @@ final class RBCollationTables {
* table. * table.
* @param ch the starting character of the contracting string * @param ch the starting character of the contracting string
*/ */
Vector getContractValues(int ch) Vector<EntryPair> getContractValues(int ch)
{ {
int index = mapping.elementAt(ch); int index = mapping.elementAt(ch);
return getContractValuesImpl(index - CONTRACTCHARINDEX); return getContractValuesImpl(index - CONTRACTCHARINDEX);
} }
//get contract values from contractTable by index //get contract values from contractTable by index
private Vector getContractValuesImpl(int index) private Vector<EntryPair> getContractValuesImpl(int index)
{ {
if (index >= 0) if (index >= 0)
{ {
return (Vector)contractTable.elementAt(index); return contractTable.elementAt(index);
} }
else // not found else // not found
{ {
...@@ -202,7 +202,7 @@ final class RBCollationTables { ...@@ -202,7 +202,7 @@ final class RBCollationTables {
// this could cause a performance problem, but in practise that // this could cause a performance problem, but in practise that
// rarely happens // rarely happens
for (int i = 0; i < expandTable.size(); i++) { for (int i = 0; i < expandTable.size(); i++) {
int[] valueList = (int [])expandTable.elementAt(i); int[] valueList = expandTable.elementAt(i);
int length = valueList.length; int length = valueList.length;
if (length > result && valueList[length-1] == order) { if (length > result && valueList[length-1] == order) {
...@@ -220,7 +220,7 @@ final class RBCollationTables { ...@@ -220,7 +220,7 @@ final class RBCollationTables {
* @param idx the index of the expanding string value list * @param idx the index of the expanding string value list
*/ */
final int[] getExpandValueList(int order) { final int[] getExpandValueList(int order) {
return (int[])expandTable.elementAt(order - EXPANDCHARINDEX); return expandTable.elementAt(order - EXPANDCHARINDEX);
} }
/** /**
...@@ -260,9 +260,9 @@ final class RBCollationTables { ...@@ -260,9 +260,9 @@ final class RBCollationTables {
} }
} }
final static int getEntry(Vector list, String name, boolean fwd) { final static int getEntry(Vector<EntryPair> list, String name, boolean fwd) {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
EntryPair pair = (EntryPair)list.elementAt(i); EntryPair pair = list.elementAt(i);
if (pair.fwd == fwd && pair.entryName.equals(name)) { if (pair.fwd == fwd && pair.entryName.equals(name)) {
return i; return i;
} }
...@@ -294,8 +294,8 @@ final class RBCollationTables { ...@@ -294,8 +294,8 @@ final class RBCollationTables {
private boolean seAsianSwapping = false; private boolean seAsianSwapping = false;
private UCompactIntArray mapping = null; private UCompactIntArray mapping = null;
private Vector contractTable = null; private Vector<Vector<EntryPair>> contractTable = null;
private Vector expandTable = null; private Vector<int[]> expandTable = null;
private IntHashtable contractFlags = null; private IntHashtable contractFlags = null;
private short maxSecOrder = 0; private short maxSecOrder = 0;
......
...@@ -85,7 +85,7 @@ final class RBTableBuilder { ...@@ -85,7 +85,7 @@ final class RBTableBuilder {
throw new ParseException("Build rules empty.", 0); throw new ParseException("Build rules empty.", 0);
// This array maps Unicode characters to their collation ordering // This array maps Unicode characters to their collation ordering
mapping = new UCompactIntArray((int)RBCollationTables.UNMAPPED); mapping = new UCompactIntArray(RBCollationTables.UNMAPPED);
// Normalize the build rules. Find occurances of all decomposed characters // Normalize the build rules. Find occurances of all decomposed characters
// and normalize the rules before feeding into the builder. By "normalize", // and normalize the rules before feeding into the builder. By "normalize",
// we mean that all precomposed Unicode characters must be converted into // we mean that all precomposed Unicode characters must be converted into
...@@ -263,7 +263,7 @@ final class RBTableBuilder { ...@@ -263,7 +263,7 @@ final class RBTableBuilder {
{ {
if (expandTable != null) { if (expandTable != null) {
for (int i = 0; i < expandTable.size(); i++) { for (int i = 0; i < expandTable.size(); i++) {
int[] valueList = (int [])expandTable.elementAt(i); int[] valueList = expandTable.elementAt(i);
for (int j = 0; j < valueList.length; j++) { for (int j = 0; j < valueList.length; j++) {
int order = valueList[j]; int order = valueList[j];
if (order < RBCollationTables.EXPANDCHARINDEX && order > CHARINDEX) { if (order < RBCollationTables.EXPANDCHARINDEX && order > CHARINDEX) {
...@@ -354,7 +354,7 @@ final class RBTableBuilder { ...@@ -354,7 +354,7 @@ final class RBTableBuilder {
boolean fwd) boolean fwd)
{ {
if (contractTable == null) { if (contractTable == null) {
contractTable = new Vector(INITIALTABLESIZE); contractTable = new Vector<>(INITIALTABLESIZE);
} }
//initial character //initial character
...@@ -366,12 +366,12 @@ final class RBTableBuilder { ...@@ -366,12 +366,12 @@ final class RBTableBuilder {
*/ */
// See if the initial character of the string already has a contract table. // See if the initial character of the string already has a contract table.
int entry = mapping.elementAt(ch); int entry = mapping.elementAt(ch);
Vector entryTable = getContractValuesImpl(entry - RBCollationTables.CONTRACTCHARINDEX); Vector<EntryPair> entryTable = getContractValuesImpl(entry - RBCollationTables.CONTRACTCHARINDEX);
if (entryTable == null) { if (entryTable == null) {
// We need to create a new table of contract entries for this base char // We need to create a new table of contract entries for this base char
int tableIndex = RBCollationTables.CONTRACTCHARINDEX + contractTable.size(); int tableIndex = RBCollationTables.CONTRACTCHARINDEX + contractTable.size();
entryTable = new Vector(INITIALTABLESIZE); entryTable = new Vector<>(INITIALTABLESIZE);
contractTable.addElement(entryTable); contractTable.addElement(entryTable);
// Add the initial character's current ordering first. then // Add the initial character's current ordering first. then
...@@ -383,10 +383,10 @@ final class RBTableBuilder { ...@@ -383,10 +383,10 @@ final class RBTableBuilder {
// Now add (or replace) this string in the table // Now add (or replace) this string in the table
int index = RBCollationTables.getEntry(entryTable, groupChars, fwd); int index = RBCollationTables.getEntry(entryTable, groupChars, fwd);
if (index != RBCollationTables.UNMAPPED) { if (index != RBCollationTables.UNMAPPED) {
EntryPair pair = (EntryPair) entryTable.elementAt(index); EntryPair pair = entryTable.elementAt(index);
pair.value = anOrder; pair.value = anOrder;
} else { } else {
EntryPair pair = (EntryPair)entryTable.lastElement(); EntryPair pair = entryTable.lastElement();
// NOTE: This little bit of logic is here to speed CollationElementIterator // NOTE: This little bit of logic is here to speed CollationElementIterator
// .nextContractChar(). This code ensures that the longest sequence in // .nextContractChar(). This code ensures that the longest sequence in
...@@ -426,11 +426,11 @@ final class RBTableBuilder { ...@@ -426,11 +426,11 @@ final class RBTableBuilder {
int ch = Character.isHighSurrogate(ch0)? int ch = Character.isHighSurrogate(ch0)?
Character.toCodePoint(ch0, groupChars.charAt(1)):ch0; Character.toCodePoint(ch0, groupChars.charAt(1)):ch0;
*/ */
Vector entryTable = getContractValues(ch); Vector<EntryPair> entryTable = getContractValues(ch);
if (entryTable != null) { if (entryTable != null) {
int index = RBCollationTables.getEntry(entryTable, groupChars, true); int index = RBCollationTables.getEntry(entryTable, groupChars, true);
if (index != RBCollationTables.UNMAPPED) { if (index != RBCollationTables.UNMAPPED) {
EntryPair pair = (EntryPair) entryTable.elementAt(index); EntryPair pair = entryTable.elementAt(index);
result = pair.value; result = pair.value;
} }
} }
...@@ -442,8 +442,8 @@ final class RBTableBuilder { ...@@ -442,8 +442,8 @@ final class RBTableBuilder {
int order = mapping.elementAt(ch); int order = mapping.elementAt(ch);
if (order >= RBCollationTables.CONTRACTCHARINDEX) { if (order >= RBCollationTables.CONTRACTCHARINDEX) {
Vector groupList = getContractValuesImpl(order - RBCollationTables.CONTRACTCHARINDEX); Vector<EntryPair> groupList = getContractValuesImpl(order - RBCollationTables.CONTRACTCHARINDEX);
EntryPair pair = (EntryPair)groupList.firstElement(); EntryPair pair = groupList.firstElement();
order = pair.value; order = pair.value;
} }
return order; return order;
...@@ -454,17 +454,17 @@ final class RBTableBuilder { ...@@ -454,17 +454,17 @@ final class RBTableBuilder {
* table. * table.
* @param ch the starting character of the contracting string * @param ch the starting character of the contracting string
*/ */
private Vector getContractValues(int ch) private Vector<EntryPair> getContractValues(int ch)
{ {
int index = mapping.elementAt(ch); int index = mapping.elementAt(ch);
return getContractValuesImpl(index - RBCollationTables.CONTRACTCHARINDEX); return getContractValuesImpl(index - RBCollationTables.CONTRACTCHARINDEX);
} }
private Vector getContractValuesImpl(int index) private Vector<EntryPair> getContractValuesImpl(int index)
{ {
if (index >= 0) if (index >= 0)
{ {
return (Vector)contractTable.elementAt(index); return contractTable.elementAt(index);
} }
else // not found else // not found
{ {
...@@ -513,7 +513,7 @@ final class RBTableBuilder { ...@@ -513,7 +513,7 @@ final class RBTableBuilder {
*/ */
private int addExpansion(int anOrder, String expandChars) { private int addExpansion(int anOrder, String expandChars) {
if (expandTable == null) { if (expandTable == null) {
expandTable = new Vector(INITIALTABLESIZE); expandTable = new Vector<>(INITIALTABLESIZE);
} }
// If anOrder is valid, we want to add it at the beginning of the list // If anOrder is valid, we want to add it at the beginning of the list
...@@ -610,8 +610,8 @@ final class RBTableBuilder { ...@@ -610,8 +610,8 @@ final class RBTableBuilder {
private boolean seAsianSwapping = false; private boolean seAsianSwapping = false;
private UCompactIntArray mapping = null; private UCompactIntArray mapping = null;
private Vector contractTable = null; private Vector<Vector<EntryPair>> contractTable = null;
private Vector expandTable = null; private Vector<int[]> expandTable = null;
private short maxSecOrder = 0; private short maxSecOrder = 0;
private short maxTerOrder = 0; private short maxTerOrder = 0;
......
...@@ -444,9 +444,9 @@ class RuleBasedBreakIterator extends BreakIterator { ...@@ -444,9 +444,9 @@ class RuleBasedBreakIterator extends BreakIterator {
BufferedInputStream is; BufferedInputStream is;
try { try {
is = (BufferedInputStream)AccessController.doPrivileged( is = AccessController.doPrivileged(
new PrivilegedExceptionAction() { new PrivilegedExceptionAction<BufferedInputStream>() {
public Object run() throws Exception { public BufferedInputStream run() throws Exception {
return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile)); return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册