KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > properties > TCSubProperties


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

5 package com.tc.properties;
6
7 import java.util.Properties JavaDoc;
8
9 class TCSubProperties implements TCProperties {
10
11   private final String JavaDoc category;
12   private final TCPropertiesImpl properties;
13
14   public TCSubProperties(TCPropertiesImpl properties, String JavaDoc category) {
15     this.properties = properties;
16     this.category = category;
17   }
18
19   public TCProperties getPropertiesFor(String JavaDoc category2) {
20     return properties.getPropertiesFor(getActualKey(category2));
21   }
22
23   private String JavaDoc getActualKey(String JavaDoc key) {
24     return category + "." + key;
25   }
26
27   // TODO::REmovwe
28
protected boolean containsKey(String JavaDoc key) {
29     return key.startsWith(category + ".");
30   }
31
32   public String JavaDoc getProperty(String JavaDoc key) {
33     return properties.getProperty(getActualKey(key));
34   }
35
36   public String JavaDoc toString() {
37     return "TCSubProperties(" + category + ")";
38   }
39
40   public Properties JavaDoc addAllPropertiesTo(Properties JavaDoc dest) {
41     return properties.addAllPropertiesTo(dest, category + ".");
42   }
43
44   public boolean getBoolean(String JavaDoc key) {
45     return properties.getBoolean(getActualKey(key));
46   }
47
48   public float getFloat(String JavaDoc key) {
49     return properties.getFloat(getActualKey(key));
50   }
51
52   public int getInt(String JavaDoc key) {
53     return properties.getInt(getActualKey(key));
54   }
55
56   public long getLong(String JavaDoc key) {
57     return properties.getLong(getActualKey(key));
58   }
59
60   public String JavaDoc getProperty(String JavaDoc key, boolean missingOkay) {
61     return properties.getProperty(getActualKey(key), missingOkay);
62   }
63 }
64
Popular Tags