KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > web3 > impl > Web3Properties


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.cocoon.components.web3.impl;
18
19 import java.util.Properties JavaDoc;
20 import java.util.ArrayList JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.io.InputStream JavaDoc;
23 import java.io.IOException JavaDoc;
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 125257 2005-01-15 07:59:07Z antonio $
31  */

32 public class Web3Properties extends Properties JavaDoc {
33
34     ArrayList JavaDoc orderedKeys = new ArrayList JavaDoc();
35     
36     /** Creates new Properties */
37     public Web3Properties() {
38         super();
39     }
40
41     public Web3Properties(Properties JavaDoc defaults) {
42     super(defaults);
43     }
44
45     public synchronized Iterator JavaDoc getKeysIterator() {
46         return orderedKeys.iterator();
47     }
48
49     public static Web3Properties load(String JavaDoc name) throws Exception JavaDoc {
50     Web3Properties props = null;
51     InputStream JavaDoc is = Web3Properties.class.getResourceAsStream(name);
52     props = new Web3Properties();
53     if (null != is) {
54       props.load(is);
55       return props;
56     }
57         else {
58           throw new IOException JavaDoc("Properties could not be loaded.");
59         }
60     }
61
62     public synchronized Object JavaDoc put(Object JavaDoc key, Object JavaDoc value) {
63     Object JavaDoc obj = super.put(key, value);
64     orderedKeys.add(key);
65     return obj;
66     }
67
68     public synchronized Object JavaDoc remove(Object JavaDoc key) {
69     Object JavaDoc obj = super.remove(key);
70     orderedKeys.remove(key);
71     return obj;
72     }
73 }
74
Popular Tags