< prev index next >

src/com/sun/javatest/util/Properties.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


 519      *
 520      * @return  the value in this property list with the specified key value.
 521      * @see     com.sun.javatest.util.Properties#defaults
 522      * @since   JDK1.0
 523      */
 524     public String getProperty(String key, String defaultValue) {
 525         String val = getProperty(key);
 526         return (val == null) ? defaultValue : val;
 527     }
 528 
 529     /**
 530      * Returns an enumeration of all the keys in this property list, including
 531      * the keys in the default property list.
 532      *
 533      * @return  an enumeration of all the keys in this property list, including
 534      *          the keys in the default property list.
 535      * @see     java.util.Enumeration
 536      * @see     com.sun.javatest.util.Properties#defaults
 537      * @since   JDK1.0
 538      */
 539     public Enumeration propertyNames() {
 540         Hashtable<String, String> h = new Hashtable<>();
 541         enumerate(h);
 542         return h.keys();
 543     }
 544 
 545 //    /**
 546 //     * Prints this property list out to the specified output stream.
 547 //     * This method is useful for debugging.
 548 //     *
 549 //     * @param   out   an output stream.
 550 //     * @since   JDK1.0
 551 //     */
 552 //    public void list(PrintStream out) {
 553 //      list(new PrintWriter(out));
 554 //    }
 555 
 556     /**
 557      * Prints this property list out to the specified output stream.
 558      * This method is useful for debugging.
 559      *


 570         Hashtable<String, String> h = new Hashtable<>();
 571         enumerate(h);
 572         for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
 573             String key = e.nextElement();
 574             String val = h.get(key);
 575             if (val.length() > 40) {
 576                 val = val.substring(0, 37) + "...";
 577             }
 578             out.println(key + "=" + val);
 579         }
 580     }
 581 
 582     /**
 583      * Enumerates all key/value pairs in the specified hastable.
 584      * @param h the hashtable
 585      */
 586     private synchronized void enumerate(Map<String, String> h) {
 587         if (defaults != null) {
 588             defaults.enumerate(h);
 589         }
 590         for (Enumeration e = keys() ; e.hasMoreElements() ;) {
 591             String key = (String)e.nextElement();
 592             h.put(key, get(key));
 593         }
 594     }
 595 
 596     /**
 597      * Convert a nibble to a hex character
 598      * @param   nibble  the nibble to convert.
 599      */
 600     private static char toHex(int nibble) {
 601         return hexDigit[(nibble & 0xF)];
 602     }
 603 
 604     /** A table of hex digits */
 605     private static char[] hexDigit = {
 606         '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
 607     };
 608 }


 519      *
 520      * @return  the value in this property list with the specified key value.
 521      * @see     com.sun.javatest.util.Properties#defaults
 522      * @since   JDK1.0
 523      */
 524     public String getProperty(String key, String defaultValue) {
 525         String val = getProperty(key);
 526         return (val == null) ? defaultValue : val;
 527     }
 528 
 529     /**
 530      * Returns an enumeration of all the keys in this property list, including
 531      * the keys in the default property list.
 532      *
 533      * @return  an enumeration of all the keys in this property list, including
 534      *          the keys in the default property list.
 535      * @see     java.util.Enumeration
 536      * @see     com.sun.javatest.util.Properties#defaults
 537      * @since   JDK1.0
 538      */
 539     public Enumeration<String> propertyNames() {
 540         Hashtable<String, String> h = new Hashtable<>();
 541         enumerate(h);
 542         return h.keys();
 543     }
 544 
 545 //    /**
 546 //     * Prints this property list out to the specified output stream.
 547 //     * This method is useful for debugging.
 548 //     *
 549 //     * @param   out   an output stream.
 550 //     * @since   JDK1.0
 551 //     */
 552 //    public void list(PrintStream out) {
 553 //      list(new PrintWriter(out));
 554 //    }
 555 
 556     /**
 557      * Prints this property list out to the specified output stream.
 558      * This method is useful for debugging.
 559      *


 570         Hashtable<String, String> h = new Hashtable<>();
 571         enumerate(h);
 572         for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
 573             String key = e.nextElement();
 574             String val = h.get(key);
 575             if (val.length() > 40) {
 576                 val = val.substring(0, 37) + "...";
 577             }
 578             out.println(key + "=" + val);
 579         }
 580     }
 581 
 582     /**
 583      * Enumerates all key/value pairs in the specified hastable.
 584      * @param h the hashtable
 585      */
 586     private synchronized void enumerate(Map<String, String> h) {
 587         if (defaults != null) {
 588             defaults.enumerate(h);
 589         }
 590         for (Enumeration<String> e = keys() ; e.hasMoreElements() ;) {
 591             String key = e.nextElement();
 592             h.put(key, get(key));
 593         }
 594     }
 595 
 596     /**
 597      * Convert a nibble to a hex character
 598      * @param   nibble  the nibble to convert.
 599      */
 600     private static char toHex(int nibble) {
 601         return hexDigit[(nibble & 0xF)];
 602     }
 603 
 604     /** A table of hex digits */
 605     private static char[] hexDigit = {
 606         '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
 607     };
 608 }
< prev index next >