|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AttributeDecl.java | 100% | 84,8% | 53,8% | 78% |
|
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 elementName; | |
21 | ||
22 | /** Holds value of property attributeName. */ | |
23 | private String attributeName; | |
24 | ||
25 | /** Holds value of property type. */ | |
26 | private String type; | |
27 | ||
28 | /** Holds value of property value. */ | |
29 | private String value; | |
30 | ||
31 | /** Holds value of property valueDefault. */ | |
32 | private String valueDefault; | |
33 | ||
34 | 0 | public AttributeDecl() { |
35 | } | |
36 | ||
37 | 8 | public AttributeDecl(String elementName, String attributeName, String type, |
38 | String valueDefault, String value) { | |
39 | 8 | this.elementName = elementName; |
40 | 8 | this.attributeName = attributeName; |
41 | 8 | this.type = type; |
42 | 8 | this.value = value; |
43 | 8 | this.valueDefault = valueDefault; |
44 | } | |
45 | ||
46 | /** | |
47 | * Getter for property elementName. | |
48 | * | |
49 | * @return Value of property elementName. | |
50 | */ | |
51 | 7 | public String getElementName() { |
52 | 7 | return elementName; |
53 | } | |
54 | ||
55 | /** | |
56 | * Setter for property elementName. | |
57 | * | |
58 | * @param elementName | |
59 | * New value of property elementName. | |
60 | */ | |
61 | 0 | public void setElementName(String elementName) { |
62 | 0 | this.elementName = elementName; |
63 | } | |
64 | ||
65 | /** | |
66 | * Getter for property attributeName. | |
67 | * | |
68 | * @return Value of property attributeName. | |
69 | */ | |
70 | 7 | public String getAttributeName() { |
71 | 7 | return attributeName; |
72 | } | |
73 | ||
74 | /** | |
75 | * Setter for property attributeName. | |
76 | * | |
77 | * @param attributeName | |
78 | * New value of property attributeName. | |
79 | */ | |
80 | 0 | public void setAttributeName(String attributeName) { |
81 | 0 | this.attributeName = attributeName; |
82 | } | |
83 | ||
84 | /** | |
85 | * Getter for property type. | |
86 | * | |
87 | * @return Value of property type. | |
88 | */ | |
89 | 7 | public String getType() { |
90 | 7 | return type; |
91 | } | |
92 | ||
93 | /** | |
94 | * Setter for property type. | |
95 | * | |
96 | * @param type | |
97 | * New value of property type. | |
98 | */ | |
99 | 0 | public void setType(String type) { |
100 | 0 | this.type = type; |
101 | } | |
102 | ||
103 | /** | |
104 | * Getter for property value. | |
105 | * | |
106 | * @return Value of property value. | |
107 | */ | |
108 | 4 | public String getValue() { |
109 | 4 | return value; |
110 | } | |
111 | ||
112 | /** | |
113 | * Setter for property value. | |
114 | * | |
115 | * @param value | |
116 | * New value of property value. | |
117 | */ | |
118 | 0 | public void setValue(String value) { |
119 | 0 | this.value = value; |
120 | } | |
121 | ||
122 | /** | |
123 | * Getter for property valueDefault. | |
124 | * | |
125 | * @return Value of property valueDefault. | |
126 | */ | |
127 | 7 | public String getValueDefault() { |
128 | 7 | return valueDefault; |
129 | } | |
130 | ||
131 | /** | |
132 | * Setter for property valueDefault. | |
133 | * | |
134 | * @param valueDefault | |
135 | * New value of property valueDefault. | |
136 | */ | |
137 | 0 | public void setValueDefault(String valueDefault) { |
138 | 0 | this.valueDefault = valueDefault; |
139 | } | |
140 | ||
141 | 11 | public String toString() { |
142 | 11 | StringBuffer buffer = new StringBuffer("<!ATTLIST "); |
143 | 11 | buffer.append(elementName); |
144 | 11 | buffer.append(" "); |
145 | 11 | buffer.append(attributeName); |
146 | 11 | buffer.append(" "); |
147 | 11 | buffer.append(type); |
148 | 11 | buffer.append(" "); |
149 | ||
150 | 11 | if (valueDefault != null) { |
151 | 10 | buffer.append(valueDefault); |
152 | ||
153 | 10 | if (valueDefault.equals("#FIXED")) { |
154 | 1 | buffer.append(" \""); |
155 | 1 | buffer.append(value); |
156 | 1 | buffer.append("\""); |
157 | } | |
158 | } else { | |
159 | 1 | buffer.append("\""); |
160 | 1 | buffer.append(value); |
161 | 1 | buffer.append("\""); |
162 | } | |
163 | ||
164 | 11 | buffer.append(">"); |
165 | ||
166 | 11 | 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 | */ |
|