01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.config.schema.dynamic;
05:
06: import org.apache.xmlbeans.XmlObject;
07:
08: import com.tc.config.schema.context.ConfigContext;
09:
10: /**
11: * An {@link XPathBasedConfigItem} that returns a Java <code>boolean</code> value.
12: */
13: public class BooleanXPathBasedConfigItem extends XPathBasedConfigItem
14: implements BooleanConfigItem {
15:
16: public BooleanXPathBasedConfigItem(ConfigContext context,
17: String xpath, boolean defaultValue) {
18: super (context, xpath, new Boolean(defaultValue));
19: }
20:
21: public BooleanXPathBasedConfigItem(ConfigContext context,
22: String xpath) {
23: super (context, xpath);
24: }
25:
26: protected Object fetchDataFromXmlObject(XmlObject xmlObject) {
27: return super .fetchDataFromXmlObjectByReflection(xmlObject,
28: "getBooleanValue");
29: }
30:
31: public boolean getBoolean() {
32: return ((Boolean) getObject()).booleanValue();
33: }
34:
35: }
|