KickJava   Java API By Example, From Geeks To Geeks.

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


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>ExternalEntityDecl</code> represents an external entity declaration
13  * in a DTD.
14  * </p>
15  *
16  * @author <a HREF="mailto:james.strachan@metastuff.com">James Strachan </a>
17  * @version $Revision: 1.9 $
18  */

19 public class ExternalEntityDecl {
20     /** Holds value of property name. */
21     private String JavaDoc name;
22
23     /** Holds value of property publicID. */
24     private String JavaDoc publicID;
25
26     /** Holds value of property systemID. */
27     private String JavaDoc systemID;
28
29     public ExternalEntityDecl() {
30     }
31
32     public ExternalEntityDecl(String JavaDoc name, String JavaDoc publicID, String JavaDoc systemID) {
33         this.name = name;
34         this.publicID = publicID;
35         this.systemID = systemID;
36     }
37
38     /**
39      * Getter for property name.
40      *
41      * @return Value of property name.
42      */

43     public String JavaDoc getName() {
44         return name;
45     }
46
47     /**
48      * Setter for property name.
49      *
50      * @param name
51      * New value of property name.
52      */

53     public void setName(String JavaDoc name) {
54         this.name = name;
55     }
56
57     /**
58      * Getter for property publicID.
59      *
60      * @return Value of property publicID.
61      */

62     public String JavaDoc getPublicID() {
63         return publicID;
64     }
65
66     /**
67      * Setter for property publicID.
68      *
69      * @param publicID
70      * New value of property publicID.
71      */

72     public void setPublicID(String JavaDoc publicID) {
73         this.publicID = publicID;
74     }
75
76     /**
77      * Getter for property systemID.
78      *
79      * @return Value of property systemID.
80      */

81     public String JavaDoc getSystemID() {
82         return systemID;
83     }
84
85     /**
86      * Setter for property systemID.
87      *
88      * @param systemID
89      * New value of property systemID.
90      */

91     public void setSystemID(String JavaDoc systemID) {
92         this.systemID = systemID;
93     }
94
95     public String JavaDoc toString() {
96         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("<!ENTITY ");
97
98         if (name.startsWith("%")) {
99             buffer.append("% ");
100             buffer.append(name.substring(1));
101         } else {
102             buffer.append(name);
103         }
104
105         if (publicID != null) {
106             buffer.append(" PUBLIC \"");
107             buffer.append(publicID);
108             buffer.append("\" ");
109
110             if (systemID != null) {
111                 buffer.append("\"");
112                 buffer.append(systemID);
113                 buffer.append("\" ");
114             }
115         } else if (systemID != null) {
116             buffer.append(" SYSTEM \"");
117             buffer.append(systemID);
118             buffer.append("\" ");
119         }
120
121         buffer.append(">");
122
123         return buffer.toString();
124     }
125 }
126
127 /*
128  * Redistribution and use of this software and associated documentation
129  * ("Software"), with or without modification, are permitted provided that the
130  * following conditions are met:
131  *
132  * 1. Redistributions of source code must retain copyright statements and
133  * notices. Redistributions must also contain a copy of this document.
134  *
135  * 2. Redistributions in binary form must reproduce the above copyright notice,
136  * this list of conditions and the following disclaimer in the documentation
137  * and/or other materials provided with the distribution.
138  *
139  * 3. The name "DOM4J" must not be used to endorse or promote products derived
140  * from this Software without prior written permission of MetaStuff, Ltd. For
141  * written permission, please contact dom4j-info@metastuff.com.
142  *
143  * 4. Products derived from this Software may not be called "DOM4J" nor may
144  * "DOM4J" appear in their names without prior written permission of MetaStuff,
145  * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
146  *
147  * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
148  *
149  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
150  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
151  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
152  * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
153  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
154  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
155  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
156  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
157  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
158  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
159  * POSSIBILITY OF SUCH DAMAGE.
160  *
161  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
162  */

163
Popular Tags