1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.util;
16  
17  import java.util.Enumeration;
18  import java.util.Properties;
19  import java.util.Vector;
20  
21  /**
22   * <a href="OrderedProperties.java.html"><b><i>View Source</i></b></a>
23   *
24   * @author Brian Wing Shun Chan
25   */
26  public class OrderedProperties extends Properties {
27  
28      public OrderedProperties() {
29          super();
30  
31          _names = new Vector<String>();
32      }
33  
34      public Enumeration<String> propertyNames() {
35          return _names.elements();
36      }
37  
38      public Object put(Object key, Object value) {
39          if (_names.contains(key)) {
40              _names.remove(key);
41          }
42  
43          _names.add((String)key);
44  
45          return super.put(key, value);
46      }
47  
48      public Object remove(Object key) {
49          _names.remove(key);
50  
51          return super.remove(key);
52      }
53  
54      private Vector<String> _names;
55  
56  }