KickJava   Java API By Example, From Geeks To Geeks.

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


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.w3c.dom.Element JavaDoc;
22 import org.w3c.dom.Node JavaDoc;
23 import org.w3c.dom.NodeList JavaDoc;
24 import org.w3c.dom.Text JavaDoc;
25
26 /**
27  * Represents a value in a vocabulary.
28  *
29  * @author Matthew Large
30  * @version $Revision: 1.1 $
31  *
32  */

33 public class Value {
34
35     /**
36      * Name.
37      */

38     private String JavaDoc m_sName = null;
39     
40     /**
41      * Full path to the virtual file for the value.
42      */

43     private String JavaDoc m_sHREF = null;
44     
45     /**
46      * Display name.
47      */

48     private String JavaDoc m_sDisplayName = null;
49
50     public Value() {
51         super();
52     }
53
54     /**
55      * Construcs a new value
56      *
57      * @param sName Name
58      * @param sPath Full path
59      */

60     public Value(String JavaDoc sName, String JavaDoc sPath) {
61         super();
62         this.m_sName = sName;
63         this.m_sHREF = sPath;
64         this.m_sDisplayName = sName;
65     }
66     
67     /**
68      * Sets the name of this value.
69      *
70      * @param sName Name
71      */

72     public void setName(String JavaDoc sName) {
73         this.m_sName = sName;
74     }
75     
76     /**
77      * Sets the display name for this value
78      *
79      * @param sDisplayName Display name
80      */

81     public void setDisplayName(String JavaDoc sDisplayName) {
82         this.m_sDisplayName = sDisplayName;
83     }
84     
85     /**
86      * Returns the display name for this value.
87      *
88      * @return Display name
89      */

90     public String JavaDoc getDisplayName() {
91         return this.m_sDisplayName;
92     }
93     
94     /**
95      * Returns the name for this value.
96      *
97      * @return Name
98      */

99     public String JavaDoc getName() {
100         return this.m_sName;
101     }
102     
103     /**
104      * Returns the full path to the virtual file for this value.
105      *
106      * @return Full path
107      */

108     public String JavaDoc getHREF() {
109         return this.m_sHREF;
110     }
111
112     public void instantiate(Element JavaDoc elValue) {
113         this.m_sName = elValue.getAttributeNS("http://www.simulacramedia.com/harmoniseclient/propdefs", "name");
114         NodeList JavaDoc nl = elValue.getChildNodes();
115         for(int i=0; i<nl.getLength(); i++) {
116             Node JavaDoc node = nl.item(i);
117             if(node.getNodeType()==Node.ELEMENT_NODE) {
118                 Element JavaDoc element = (Element JavaDoc)node;
119                 if(element.getLocalName().equalsIgnoreCase("displayname")) {
120                     Node JavaDoc node2 = element.getFirstChild();
121                     if(node2.getNodeType()==Node.TEXT_NODE) {
122                         this.m_sDisplayName = ((Text JavaDoc)node2).getNodeValue();
123                     }
124                 } else if(element.getLocalName().equalsIgnoreCase("href")) {
125                     Node JavaDoc node2 = element.getFirstChild();
126                     if(node2.getNodeType()==Node.TEXT_NODE) {
127                         this.m_sHREF = ((Text JavaDoc)node2).getNodeValue();
128                     }
129                 }
130             }
131         }
132     }
133     
134     public String JavaDoc toString() {
135         StringBuffer JavaDoc sBuff = new StringBuffer JavaDoc();
136         
137         sBuff.append("Value: [").append(this.m_sName).append("]\n")
138              .append("DisplayName: ").append(this.m_sDisplayName).append("\n")
139              .append("Path: ").append(this.m_sHREF).append("\n");
140         
141         return sBuff.toString();
142     }
143     
144 }
145
Popular Tags