View Javadoc

1   /*
2    * Copyright 2001-2004 (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    * $Id: AttributeDecl.java,v 1.5 2004/06/25 08:03:36 maartenc Exp $
8    */
9   
10  package org.dom4j.dtd;
11  
12  /*** <p><code>AttributeDecl</code> represents an attribute declaration in a DTD.</p>
13    *
14    * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a>
15    * @version $Revision: 1.5 $
16    */
17  public class AttributeDecl {
18  
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      public AttributeDecl() {
35      }
36  
37      public AttributeDecl(String elementName, String attributeName, String type, String valueDefault, String value) {
38          this.elementName = elementName;
39          this.attributeName = attributeName;
40          this.type = type;
41          this.value = value;
42          this.valueDefault = valueDefault;
43      }
44  
45      /*** Getter for property elementName.
46       * @return Value of property elementName.
47       */
48      public String getElementName() {
49          return elementName;
50      }
51      
52      /*** Setter for property elementName.
53       * @param elementName New value of property elementName.
54       */
55      public void setElementName(String elementName) {
56          this.elementName = elementName;
57      }
58      
59      /*** Getter for property attributeName.
60       * @return Value of property attributeName.
61       */
62      public String getAttributeName() {
63          return attributeName;
64      }
65      
66      /*** Setter for property attributeName.
67       * @param attributeName New value of property attributeName.
68       */
69      public void setAttributeName(String attributeName) {
70          this.attributeName = attributeName;
71      }
72      
73      /*** Getter for property type.
74       * @return Value of property type.
75       */
76      public String getType() {
77          return type;
78      }
79      
80      /*** Setter for property type.
81       * @param type New value of property type.
82       */
83      public void setType(String type) {
84          this.type = type;
85      }
86      
87      /*** Getter for property value.
88       * @return Value of property value.
89       */
90      public String getValue() {
91          return value;
92      }
93      
94      /*** Setter for property value.
95       * @param value New value of property value.
96       */
97      public void setValue(String value) {
98          this.value = value;
99      }
100     
101     /*** Getter for property valueDefault.
102      * @return Value of property valueDefault.
103      */
104     public String getValueDefault() {
105         return valueDefault;
106     }
107     
108     /*** Setter for property valueDefault.
109      * @param valueDefault New value of property valueDefault.
110      */
111     public void setValueDefault(String valueDefault) {
112         this.valueDefault = valueDefault;
113     }
114 
115     public String toString() {
116         StringBuffer buffer = new StringBuffer( "<!ATTLIST ");
117         buffer.append( elementName );
118         buffer.append( " " );
119         buffer.append( attributeName );
120         buffer.append( " " );
121         buffer.append( type );
122         buffer.append( " " );
123         if (valueDefault != null) {
124             buffer.append(valueDefault);
125             if (valueDefault.equals("#FIXED")) {
126                 buffer.append(" \"");
127                 buffer.append(value);
128                 buffer.append("\"");
129             }
130         } 
131         else {
132             buffer.append("\"");
133             buffer.append(value);
134             buffer.append("\"");
135         }
136         buffer.append(">");
137         return buffer.toString();
138     }
139 }
140 
141 
142 
143 
144 /*
145  * Redistribution and use of this software and associated documentation
146  * ("Software"), with or without modification, are permitted provided
147  * that the following conditions are met:
148  *
149  * 1. Redistributions of source code must retain copyright
150  *    statements and notices.  Redistributions must also contain a
151  *    copy of this document.
152  *
153  * 2. Redistributions in binary form must reproduce the
154  *    above copyright notice, this list of conditions and the
155  *    following disclaimer in the documentation and/or other
156  *    materials provided with the distribution.
157  *
158  * 3. The name "DOM4J" must not be used to endorse or promote
159  *    products derived from this Software without prior written
160  *    permission of MetaStuff, Ltd.  For written permission,
161  *    please contact dom4j-info@metastuff.com.
162  *
163  * 4. Products derived from this Software may not be called "DOM4J"
164  *    nor may "DOM4J" appear in their names without prior written
165  *    permission of MetaStuff, Ltd. DOM4J is a registered
166  *    trademark of MetaStuff, Ltd.
167  *
168  * 5. Due credit should be given to the DOM4J Project - 
169  *    http://www.dom4j.org
170  *
171  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
172  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
173  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
174  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
175  * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
176  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
177  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
178  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
179  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
180  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
181  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
182  * OF THE POSSIBILITY OF SUCH DAMAGE.
183  *
184  * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
185  *
186  * $Id: AttributeDecl.java,v 1.5 2004/06/25 08:03:36 maartenc Exp $
187  */