Home | History | Annotate | Download | only in util
      1 /* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
      2  *
      3  * This program and the accompanying materials are made available under
      4  * the terms of the Common Public License v1.0 which accompanies this distribution,
      5  * and is available at http://www.eclipse.org/legal/cpl-v10.html
      6  *
      7  * $Id: XProperties.java,v 1.1.1.1 2004/05/09 16:57:56 vlad_r Exp $
      8  */
      9 package com.vladium.util;
     10 
     11 import java.io.PrintStream;
     12 import java.io.PrintWriter;
     13 import java.util.Enumeration;
     14 import java.util.Iterator;
     15 import java.util.Properties;
     16 import java.util.Set;
     17 import java.util.TreeSet;
     18 
     19 // ----------------------------------------------------------------------------
     20 /**
     21  * @author Vlad Roubtsov, (C) 2003
     22  */
     23 public
     24 class XProperties extends Properties
     25 {
     26     // public: ................................................................
     27 
     28 
     29     public XProperties ()
     30     {
     31     }
     32 
     33     public XProperties (final Properties base)
     34     {
     35         super (base);
     36     }
     37 
     38     public void list (final PrintStream out)
     39     {
     40         final Set /* String */ _propertyNames = new TreeSet ();
     41 
     42         // note: must use propertyNames() because that is the only method that recurses
     43         for (Enumeration propertyNames = propertyNames (); propertyNames.hasMoreElements (); )
     44         {
     45             _propertyNames.add (propertyNames.nextElement ());
     46         }
     47 
     48         for (Iterator i = _propertyNames.iterator (); i.hasNext (); )
     49         {
     50             final String n = (String) i.next ();
     51             final String v = getProperty (n);
     52 
     53             out.println (n + ":\t[" + v + "]");
     54         }
     55     }
     56 
     57     public void list (final PrintWriter out)
     58     {
     59         final Set /* String */ _propertyNames = new TreeSet ();
     60 
     61         // note: must use propertyNames() because that is the only method that recurses
     62         for (Enumeration propertyNames = propertyNames (); propertyNames.hasMoreElements (); )
     63         {
     64             _propertyNames.add (propertyNames.nextElement ());
     65         }
     66 
     67         for (Iterator i = _propertyNames.iterator (); i.hasNext (); )
     68         {
     69             final String n = (String) i.next ();
     70             final String v = getProperty (n);
     71 
     72             out.println (n + ":\t[" + v + "]");
     73         }
     74     }
     75 
     76     // protected: .............................................................
     77 
     78     // package: ...............................................................
     79 
     80     // private: ...............................................................
     81 
     82 } // end of class
     83 // ----------------------------------------------------------------------------