01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.vfs.metadata.range;
20:
21: import org.openharmonise.commons.xml.namespace.*;
22: import org.openharmonise.vfs.metadata.*;
23: import org.w3c.dom.*;
24:
25: /**
26: * This is the range for boolean type properties.
27: *
28: * @author Matthew Large
29: * @version $Revision: 1.2 $
30: *
31: */
32: public class BooleanRange extends AbstractRange implements Range {
33:
34: private String m_sTrueText = "Yes";
35: private String m_sFalseText = "No";
36:
37: /**
38: *
39: */
40: public BooleanRange() {
41: super ();
42: }
43:
44: public void setFalseText(String sFalseText) {
45: this .m_sFalseText = sFalseText;
46: }
47:
48: public void setTrueText(String sTrueText) {
49: this .m_sTrueText = sTrueText;
50: }
51:
52: public String getTrueText() {
53: return this .m_sTrueText;
54: }
55:
56: public String getFalseText() {
57: return this .m_sFalseText;
58: }
59:
60: /* (non-Javadoc)
61: * @see com.simulacramedia.vfs.metadata.range.AbstractRange#validate(java.lang.String)
62: */
63: public ValidationResult validate(ValueInstance value) {
64: return new ValidationResult(true, "");
65: }
66:
67: /* (non-Javadoc)
68: * @see com.simulacramedia.vfs.metadata.Range#instantiate(org.w3c.dom.Element)
69: */
70: public void instantiate(Element elRange) {
71: NodeList nl = elRange.getElementsByTagNameNS(
72: NamespaceType.XML_SCHEMA.getURI(), "restriction");
73: for (int i = 0; i < nl.getLength(); i++) {
74: Node node = nl.item(i);
75: if (node.getNodeType() == Node.ELEMENT_NODE) {
76: Element elTemp = (Element) node;
77: if (elTemp.getLocalName().equals("labels")) {
78: String sTrueText = elTemp.getAttributeNS(
79: NamespaceType.OHRM.getURI(), "trueLabel");
80: String sFalseText = elTemp.getAttributeNS(
81: NamespaceType.OHRM.getURI(), "falseLabel");
82: this .setTrueText(sTrueText);
83: this .setFalseText(sFalseText);
84: }
85: }
86: }
87: }
88:
89: public String toString() {
90: return "BooleanRange:\n";
91: }
92:
93: }
|