01: package de.java2html.util;
02:
03: import java.util.Collection;
04: import java.util.Enumeration;
05: import java.util.LinkedHashMap;
06: import java.util.Map;
07: import java.util.Properties;
08: import java.util.Set;
09:
10: /**
11: * A properties implementation that remembers the order of its entries.
12: *
13: * @author Markus Gebhard
14: */
15: public class LinkedProperties extends Properties {
16: private LinkedHashMap map = new LinkedHashMap();
17:
18: public synchronized Object put(Object key, Object value) {
19: return map.put(key, value);
20: }
21:
22: public synchronized Object get(Object key) {
23: return map.get(key);
24: }
25:
26: public synchronized void clear() {
27: map.clear();
28: }
29:
30: public synchronized Object clone() {
31: throw new UnsupportedOperationException();
32: }
33:
34: public boolean containsValue(Object value) {
35: return map.containsValue(value);
36: }
37:
38: public synchronized boolean contains(Object value) {
39: return containsValue(value);
40: }
41:
42: public synchronized boolean containsKey(Object key) {
43: return map.containsKey(key);
44: }
45:
46: public synchronized Enumeration elements() {
47: return new IteratorEnumeration(map.values().iterator());
48: }
49:
50: public Set entrySet() {
51: return map.entrySet();
52: }
53:
54: public synchronized boolean equals(Object o) {
55: throw new UnsupportedOperationException();
56: }
57:
58: public synchronized boolean isEmpty() {
59: return map.isEmpty();
60: }
61:
62: public synchronized Enumeration keys() {
63: return new IteratorEnumeration(map.keySet().iterator());
64: }
65:
66: public Set keySet() {
67: return map.keySet();
68: }
69:
70: public Enumeration propertyNames() {
71: throw new UnsupportedOperationException();
72: }
73:
74: public synchronized void putAll(Map t) {
75: map.putAll(t);
76: }
77:
78: public synchronized Object remove(Object key) {
79: return map.remove(key);
80: }
81:
82: public synchronized int size() {
83: return map.size();
84: }
85:
86: public Collection values() {
87: throw new UnsupportedOperationException();
88: }
89:
90: public String getProperty(String key) {
91: Object oval = get(key);
92: String sval = (oval instanceof String) ? (String) oval : null;
93: return ((sval == null) && (defaults != null)) ? defaults
94: .getProperty(key) : sval;
95: }
96: }
|