KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > vladium > util > XProperties


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 JavaDoc;
12 import java.io.PrintWriter JavaDoc;
13 import java.util.Enumeration JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.Properties JavaDoc;
16 import java.util.Set JavaDoc;
17 import java.util.TreeSet JavaDoc;
18
19 // ----------------------------------------------------------------------------
20
/**
21  * @author Vlad Roubtsov, (C) 2003
22  */

23 public
24 class XProperties extends Properties JavaDoc
25 {
26     // public: ................................................................
27

28     
29     public XProperties ()
30     {
31     }
32     
33     public XProperties (final Properties JavaDoc base)
34     {
35         super (base);
36     }
37     
38     public void list (final PrintStream JavaDoc out)
39     {
40         final Set JavaDoc /* String */ _propertyNames = new TreeSet JavaDoc ();
41         
42         // note: must use propertyNames() because that is the only method that recurses
43
for (Enumeration JavaDoc propertyNames = propertyNames (); propertyNames.hasMoreElements (); )
44         {
45             _propertyNames.add (propertyNames.nextElement ());
46         }
47         
48         for (Iterator JavaDoc i = _propertyNames.iterator (); i.hasNext (); )
49         {
50             final String JavaDoc n = (String JavaDoc) i.next ();
51             final String JavaDoc v = getProperty (n);
52             
53             out.println (n + ":\t[" + v + "]");
54         }
55     }
56     
57     public void list (final PrintWriter JavaDoc out)
58     {
59         final Set JavaDoc /* String */ _propertyNames = new TreeSet JavaDoc ();
60         
61         // note: must use propertyNames() because that is the only method that recurses
62
for (Enumeration JavaDoc propertyNames = propertyNames (); propertyNames.hasMoreElements (); )
63         {
64             _propertyNames.add (propertyNames.nextElement ());
65         }
66         
67         for (Iterator JavaDoc i = _propertyNames.iterator (); i.hasNext (); )
68         {
69             final String JavaDoc n = (String JavaDoc) i.next ();
70             final String JavaDoc 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
// ----------------------------------------------------------------------------
Popular Tags