1
2
3
4
5
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 name;
22
23 /*** Holds value of property publicID. */
24 private String publicID;
25
26 /*** Holds value of property systemID. */
27 private String systemID;
28
29 public ExternalEntityDecl() {
30 }
31
32 public ExternalEntityDecl(String name, String publicID, String 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 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 name) {
54 this.name = name;
55 }
56
57 /***
58 * Getter for property publicID.
59 *
60 * @return Value of property publicID.
61 */
62 public String 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 publicID) {
73 this.publicID = publicID;
74 }
75
76 /***
77 * Getter for property systemID.
78 *
79 * @return Value of property systemID.
80 */
81 public String 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 systemID) {
92 this.systemID = systemID;
93 }
94
95 public String toString() {
96 StringBuffer buffer = new StringBuffer("<!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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162