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 */
9package com.vladium.util;
10
11import java.io.PrintStream;
12import java.io.PrintWriter;
13import java.util.Enumeration;
14import java.util.Iterator;
15import java.util.Properties;
16import java.util.Set;
17import java.util.TreeSet;
18
19// ----------------------------------------------------------------------------
20/**
21 * @author Vlad Roubtsov, (C) 2003
22 */
23public
24class 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// ----------------------------------------------------------------------------