KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > vfs > metadata > range > BooleanRange


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * 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 /**
27  * This is the range for boolean type properties.
28  *
29  * @author Matthew Large
30  * @version $Revision: 1.2 $
31  *
32  */

33 public class BooleanRange extends AbstractRange implements Range {
34
35     private String JavaDoc m_sTrueText = "Yes";
36     private String JavaDoc m_sFalseText = "No";
37     
38     /**
39      *
40      */

41     public BooleanRange() {
42         super();
43     }
44     
45     public void setFalseText(String JavaDoc sFalseText) {
46         this.m_sFalseText = sFalseText;
47     }
48     
49     public void setTrueText(String JavaDoc sTrueText) {
50         this.m_sTrueText = sTrueText;
51     }
52     
53     public String JavaDoc getTrueText() {
54         return this.m_sTrueText;
55     }
56     
57     public String JavaDoc getFalseText() {
58         return this.m_sFalseText;
59     }
60
61     /* (non-Javadoc)
62      * @see com.simulacramedia.vfs.metadata.range.AbstractRange#validate(java.lang.String)
63      */

64     public ValidationResult validate(ValueInstance value) {
65         return new ValidationResult(true,"");
66     }
67
68     /* (non-Javadoc)
69      * @see com.simulacramedia.vfs.metadata.Range#instantiate(org.w3c.dom.Element)
70      */

71     public void instantiate(Element elRange) {
72         NodeList nl = elRange.getElementsByTagNameNS(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 JavaDoc sTrueText = elTemp.getAttributeNS(NamespaceType.OHRM.getURI(), "trueLabel");
79                     String JavaDoc sFalseText = elTemp.getAttributeNS(NamespaceType.OHRM.getURI(), "falseLabel");
80                     this.setTrueText(sTrueText);
81                     this.setFalseText(sFalseText);
82                 }
83             }
84         }
85     }
86
87     public String JavaDoc toString() {
88         return "BooleanRange:\n";
89     }
90
91 }
92
Popular Tags