001/*
002 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
003 * 
004 * This software is open source. 
005 * See the bottom of this file for the licence.
006 * 
007 * $Id: AttributeDecl.java,v 1.1 2001/10/10 13:55:06 jstrachan Exp $
008 */
009
010package org.dom4j.dtd;
011
012/** <p><code>AttributeDecl</code> represents an attribute declaration in a DTD.</p>
013  *
014  * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a>
015  * @version $Revision: 1.1 $
016  */
017public class AttributeDecl {
018
019    /** Holds value of property elementName. */
020    private String elementName;
021    
022    /** Holds value of property attributeName. */
023    private String attributeName;
024    
025    /** Holds value of property type. */
026    private String type;
027    
028    /** Holds value of property value. */
029    private String value;
030    
031    /** Holds value of property valueDefault. */
032    private String valueDefault;
033    
034    public AttributeDecl() {
035    }
036
037    public AttributeDecl(String elementName, String attributeName, String type, String valueDefault, String value) {
038        this.elementName = elementName;
039        this.attributeName = attributeName;
040        this.type = type;
041        this.value = value;
042        this.valueDefault = valueDefault;
043    }
044
045    /** Getter for property elementName.
046     * @return Value of property elementName.
047     */
048    public String getElementName() {
049        return elementName;
050    }
051    
052    /** Setter for property elementName.
053     * @param elementName New value of property elementName.
054     */
055    public void setElementName(String elementName) {
056        this.elementName = elementName;
057    }
058    
059    /** Getter for property attributeName.
060     * @return Value of property attributeName.
061     */
062    public String getAttributeName() {
063        return attributeName;
064    }
065    
066    /** Setter for property attributeName.
067     * @param attributeName New value of property attributeName.
068     */
069    public void setAttributeName(String attributeName) {
070        this.attributeName = attributeName;
071    }
072    
073    /** Getter for property type.
074     * @return Value of property type.
075     */
076    public String getType() {
077        return type;
078    }
079    
080    /** Setter for property type.
081     * @param type New value of property type.
082     */
083    public void setType(String type) {
084        this.type = type;
085    }
086    
087    /** Getter for property value.
088     * @return Value of property value.
089     */
090    public String getValue() {
091        return value;
092    }
093    
094    /** Setter for property value.
095     * @param value New value of property value.
096     */
097    public void setValue(String value) {
098        this.value = value;
099    }
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://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 (C) MetaStuff, Ltd. All Rights Reserved.
185 *
186 * $Id: AttributeDecl.java,v 1.1 2001/10/10 13:55:06 jstrachan Exp $
187 */