KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dom4j > dtd > AttributeDecl


1 /*
2  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
3  *
4  * This software is open source.
5  * See the bottom of this file for the licence.
6  */

7
8 package org.dom4j.dtd;
9
10 /**
11  * <p>
12  * <code>AttributeDecl</code> represents an attribute declaration in a DTD.
13  * </p>
14  *
15  * @author <a HREF="mailto:james.strachan@metastuff.com">James Strachan </a>
16  * @version $Revision: 1.7 $
17  */

18 public class AttributeDecl {
19     /** Holds value of property elementName. */
20     private String JavaDoc elementName;
21
22     /** Holds value of property attributeName. */
23     private String JavaDoc attributeName;
24
25     /** Holds value of property type. */
26     private String JavaDoc type;
27
28     /** Holds value of property value. */
29     private String JavaDoc value;
30
31     /** Holds value of property valueDefault. */
32     private String JavaDoc valueDefault;
33
34     public AttributeDecl() {
35     }
36
37     public AttributeDecl(String JavaDoc elementName, String JavaDoc attributeName, String JavaDoc type,
38             String JavaDoc valueDefault, String JavaDoc value) {
39         this.elementName = elementName;
40         this.attributeName = attributeName;
41         this.type = type;
42         this.value = value;
43         this.valueDefault = valueDefault;
44     }
45
46     /**
47      * Getter for property elementName.
48      *
49      * @return Value of property elementName.
50      */

51     public String JavaDoc getElementName() {
52         return elementName;
53     }
54
55     /**
56      * Setter for property elementName.
57      *
58      * @param elementName
59      * New value of property elementName.
60      */

61     public void setElementName(String JavaDoc elementName) {
62         this.elementName = elementName;
63     }
64
65     /**
66      * Getter for property attributeName.
67      *
68      * @return Value of property attributeName.
69      */

70     public String JavaDoc getAttributeName() {
71         return attributeName;
72     }
73
74     /**
75      * Setter for property attributeName.
76      *
77      * @param attributeName
78      * New value of property attributeName.
79      */

80     public void setAttributeName(String JavaDoc attributeName) {
81         this.attributeName = attributeName;
82     }
83
84     /**
85      * Getter for property type.
86      *
87      * @return Value of property type.
88      */

89     public String JavaDoc getType() {
90         return type;
91     }
92
93     /**
94      * Setter for property type.
95      *
96      * @param type
97      * New value of property type.
98      */

99     public void setType(String JavaDoc type) {
100         this.type = type;
101     }
102
103     /**
104      * Getter for property value.
105      *
106      * @return Value of property value.
107      */

108     public String JavaDoc getValue() {
109         return value;
110     }
111
112     /**
113      * Setter for property value.
114      *
115      * @param value
116      * New value of property value.
117      */

118     public void setValue(String JavaDoc value) {
119         this.value = value;
120     }
121
122     /**
123      * Getter for property valueDefault.
124      *
125      * @return Value of property valueDefault.
126      */

127     public String JavaDoc getValueDefault() {
128         return valueDefault;
129     }
130
131     /**
132      * Setter for property valueDefault.
133      *
134      * @param valueDefault
135      * New value of property valueDefault.
136      */

137     public void setValueDefault(String JavaDoc valueDefault) {
138         this.valueDefault = valueDefault;
139     }
140
141     public String JavaDoc toString() {
142         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("<!ATTLIST ");
143         buffer.append(elementName);
144         buffer.append(" ");
145         buffer.append(attributeName);
146         buffer.append(" ");
147         buffer.append(type);
148         buffer.append(" ");
149
150         if (valueDefault != null) {
151             buffer.append(valueDefault);
152
153             if (valueDefault.equals("#FIXED")) {
154                 buffer.append(" \"");
155                 buffer.append(value);
156                 buffer.append("\"");
157             }
158         } else {
159             buffer.append("\"");
160             buffer.append(value);
161             buffer.append("\"");
162         }
163
164         buffer.append(">");
165
166         return buffer.toString();
167     }
168 }
169
170 /*
171  * Redistribution and use of this software and associated documentation
172  * ("Software"), with or without modification, are permitted provided that the
173  * following conditions are met:
174  *
175  * 1. Redistributions of source code must retain copyright statements and
176  * notices. Redistributions must also contain a copy of this document.
177  *
178  * 2. Redistributions in binary form must reproduce the above copyright notice,
179  * this list of conditions and the following disclaimer in the documentation
180  * and/or other materials provided with the distribution.
181  *
182  * 3. The name "DOM4J" must not be used to endorse or promote products derived
183  * from this Software without prior written permission of MetaStuff, Ltd. For
184  * written permission, please contact dom4j-info@metastuff.com.
185  *
186  * 4. Products derived from this Software may not be called "DOM4J" nor may
187  * "DOM4J" appear in their names without prior written permission of MetaStuff,
188  * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
189  *
190  * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
191  *
192  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
193  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
194  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
195  * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
196  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
197  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
198  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
199  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
200  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
201  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
202  * POSSIBILITY OF SUCH DAMAGE.
203  *
204  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
205  */

206
Popular Tags