01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.web3.impl;
18:
19: import java.util.Properties;
20: import java.util.ArrayList;
21: import java.util.Iterator;
22: import java.io.InputStream;
23: import java.io.IOException;
24:
25: /**
26: * Properties helper class.
27: *
28: * @author <a href="mailto:michael.gerzabek@at.efp.cc">Michael Gerzabek</a>
29: * @since 2.1
30: * @version CVS $Id: Web3Properties.java 524407 2007-03-31 10:59:28Z joerg $
31: */
32: public class Web3Properties extends Properties {
33:
34: ArrayList orderedKeys = new ArrayList();
35:
36: /** Creates new Properties */
37: public Web3Properties() {
38: super ();
39: }
40:
41: public Web3Properties(Properties defaults) {
42: super (defaults);
43: }
44:
45: public synchronized Iterator getKeysIterator() {
46: return orderedKeys.iterator();
47: }
48:
49: public static Web3Properties load(String name) throws Exception {
50: Web3Properties props = null;
51: InputStream is = Web3Properties.class.getResourceAsStream(name);
52: props = new Web3Properties();
53: if (null != is) {
54: props.load(is);
55: return props;
56: } else {
57: throw new IOException("Properties could not be loaded.");
58: }
59: }
60:
61: public synchronized Object put(Object key, Object value) {
62: Object obj = super .put(key, value);
63: orderedKeys.add(key);
64: return obj;
65: }
66:
67: public synchronized Object remove(Object key) {
68: Object obj = super.remove(key);
69: orderedKeys.remove(key);
70: return obj;
71: }
72: }
|