01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.properties;
06:
07: import java.util.Properties;
08:
09: class TCSubProperties implements TCProperties {
10:
11: private final String category;
12: private final TCPropertiesImpl properties;
13:
14: public TCSubProperties(TCPropertiesImpl properties, String category) {
15: this .properties = properties;
16: this .category = category;
17: }
18:
19: public TCProperties getPropertiesFor(String category2) {
20: return properties.getPropertiesFor(getActualKey(category2));
21: }
22:
23: private String getActualKey(String key) {
24: return category + "." + key;
25: }
26:
27: public String getProperty(String key) {
28: return properties.getProperty(getActualKey(key));
29: }
30:
31: public String toString() {
32: return "TCSubProperties(" + category + ")";
33: }
34:
35: public Properties addAllPropertiesTo(Properties dest) {
36: return properties.addAllPropertiesTo(dest, category + ".");
37: }
38:
39: public boolean getBoolean(String key) {
40: return properties.getBoolean(getActualKey(key));
41: }
42:
43: public float getFloat(String key) {
44: return properties.getFloat(getActualKey(key));
45: }
46:
47: public int getInt(String key) {
48: return properties.getInt(getActualKey(key));
49: }
50:
51: public long getLong(String key) {
52: return properties.getLong(getActualKey(key));
53: }
54:
55: public String getProperty(String key, boolean missingOkay) {
56: return properties.getProperty(getActualKey(key), missingOkay);
57: }
58:
59: public int getInt(String key, int defaultValue) {
60: return properties.getInt(getActualKey(key), defaultValue);
61: }
62:
63: public boolean getBoolean(String key, boolean defaultValue) {
64: return properties.getBoolean(getActualKey(key), defaultValue);
65: }
66: }
|