From 33b6e5d9fc6fae514f508e580d84626dd202c0bb Mon Sep 17 00:00:00 2001 From: Oliver Burn Date: Sun, 1 Dec 2002 03:56:08 +0000 Subject: [PATCH] Brought the code into the 21st century. Do not have the requirement to run on JDK 1.1. I wish ANT would move on as well. --- .../tools/checkstyle/api/Utils.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java index d8c7855cb..b089a4572 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java @@ -23,12 +23,11 @@ import java.io.FileReader; import java.io.IOException; import java.io.LineNumberReader; import java.util.ArrayList; -import java.util.Enumeration; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.Vector; - import org.apache.commons.beanutils.ConversionException; import org.apache.regexp.RE; import org.apache.regexp.RESyntaxException; @@ -216,17 +215,17 @@ public final class Utils return null; } - final Vector fragments = new Vector(); - final Vector propertyRefs = new Vector(); + final List fragments = new ArrayList(); + final List propertyRefs = new ArrayList(); parsePropertyString(aValue, fragments, propertyRefs); final StringBuffer sb = new StringBuffer(); - final Enumeration i = fragments.elements(); - final Enumeration j = propertyRefs.elements(); - while (i.hasMoreElements()) { - String fragment = (String) i.nextElement(); + final Iterator i = fragments.iterator(); + final Iterator j = propertyRefs.iterator(); + while (i.hasNext()) { + String fragment = (String) i.next(); if (fragment == null) { - final String propertyName = (String) j.nextElement(); + final String propertyName = (String) j.next(); if (!aProps.containsKey(propertyName)) { throw new CheckstyleException( "Property ${" + propertyName + "} has not been set"); @@ -260,8 +259,9 @@ public final class Utils * Code copied from ant - * http://cvs.apache.org/viewcvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java */ - public static void parsePropertyString(String aValue, Vector aFragments, - Vector aPropertyRefs) + public static void parsePropertyString(String aValue, + List aFragments, + List aPropertyRefs) throws CheckstyleException { int prev = 0; @@ -274,12 +274,12 @@ public final class Utils //seems like this current version could stick empty strings //into the list if (pos > 0) { - aFragments.addElement(aValue.substring(prev, pos)); + aFragments.add(aValue.substring(prev, pos)); } //if we are at the end of the string, we tack on a $ //then move past it if (pos == (aValue.length() - 1)) { - aFragments.addElement("$"); + aFragments.add("$"); prev = pos + 1; } else if (aValue.charAt(pos + 1) != '{') { @@ -291,12 +291,12 @@ public final class Utils */ if (aValue.charAt(pos + 1) == '$') { //backwards compatibility two $ map to one mode - aFragments.addElement("$"); + aFragments.add("$"); prev = pos + 2; } else { //new behaviour: $X maps to $X for all values of X!='$' - aFragments.addElement(aValue.substring(pos, pos + 2)); + aFragments.add(aValue.substring(pos, pos + 2)); prev = pos + 2; } @@ -309,15 +309,15 @@ public final class Utils + aValue); } final String propertyName = aValue.substring(pos + 2, endName); - aFragments.addElement(null); - aPropertyRefs.addElement(propertyName); + aFragments.add(null); + aPropertyRefs.add(propertyName); prev = endName + 1; } } //no more $ signs found //if there is any tail to the file, append it if (prev < aValue.length()) { - aFragments.addElement(aValue.substring(prev)); + aFragments.add(aValue.substring(prev)); } } }