< prev index next >

test/java/text/Format/common/PParser.java

Print this page

        

@@ -56,11 +56,11 @@
     protected int             column;
 
     public PParser() {
     }
 
-    public Hashtable parse(Reader r) throws IOException {
+    public Map<String,Object> parse(Reader r) throws IOException {
         this.reader = r;
         bufferedToken = false;
         lineNumber = 0;
         column = 0;
         if (getToken() != OPEN_PAIR) {

@@ -89,26 +89,26 @@
         }
         return null;
     }
 
     protected Object parseArray() throws IOException {
-        Vector       array = new Vector();
+        List<Object> array = new ArrayList<>();
         int          token;
 
         while ((token = getToken()) != CLOSE_ARRAY) {
             if (token == MORE) {
                 token = getToken();
             }
             if (token != CLOSE_ARRAY) {
-                array.addElement(parseValue(token));
+                array.add(parseValue(token));
             }
         }
         return array;
     }
 
-    protected Hashtable parsePair() throws IOException {
-        Hashtable           ht = new Hashtable(11);
+    protected Map<String,Object> parsePair() throws IOException {
+        Map<String,Object> ht = new HashMap<>(11);
         int                 token;
 
         while ((token = getToken()) != CLOSE_PAIR) {
             if (token != STRING) {
                 error("Pair expecting string got");

@@ -136,10 +136,11 @@
         int            token = getToken(false, false);
 
         return token;
     }
 
+    @SuppressWarnings("fallthrough")
     protected int getToken(boolean wantsWS, boolean inString)
         throws IOException {
         if (bufferedToken) {
             bufferedToken = false;
             if (lastToken != WS || wantsWS) {

@@ -223,35 +224,30 @@
 
     protected void error(String errorString) {
         throw new RuntimeException(errorString + " at line " + lineNumber + " column " + column);
     }
 
+    @SuppressWarnings("unchecked")
     public static void dump(Object o) {
         if (o instanceof String) {
             System.out.print(o);
-        } else if(o instanceof Vector) {
-            Enumeration     e = ((Vector)o).elements();
-
+        } else if(o instanceof List) {
             dump(" (");
-            while (e.hasMoreElements()) {
-                dump(e.nextElement());
+            ((List)o).forEach((l) -> {
+                dump(l);
                 dump(" -- ");
-            }
+            });
             dump(" )");
         } else {
-            Hashtable       ht = (Hashtable)o;
-            Enumeration     e = ht.keys();
-
+            Map<String,Object> ht = (Map<String,Object>)o;
             dump(" {");
-            while (e.hasMoreElements()) {
-                Object       key = e.nextElement();
-
-                dump(key);
+            ht.keySet().forEach(l -> {
+                dump(l);
                 dump(" = ");
-                dump(ht.get(key));
+                dump(ht.get(l));
                 dump(";");
-            }
+            });
             dump(" }");
         }
     }
 
     public static void main(String[] args) {

@@ -259,11 +255,11 @@
             System.out.println("need filename");
         } else {
             try {
                 FileReader          fr = new FileReader(args[0]);
                 PParser             parser = new PParser();
-                Hashtable           ht = parser.parse(fr);
+                Map<String,Object> ht = parser.parse(fr);
 
                 dump(ht);
                 System.out.println();
             }
             catch (IOException ioe) {
< prev index next >