OrderedProperties.java |
1 /** 2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or modify it under 5 * the terms of the GNU Lesser General Public License as published by the Free 6 * Software Foundation; either version 2.1 of the License, or (at your option) 7 * any later version. 8 * 9 * This library is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 * details. 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 }