1:
37:
38: package ;
39:
40: import ;
41: import ;
42: import ;
43: import ;
44: import ;
45:
46:
51: public class EntityDeclarationImpl
52: extends XMLEventImpl
53: implements EntityDeclaration
54: {
55:
56: protected final String publicId;
57: protected final String systemId;
58: protected final String name;
59: protected final String notationName;
60: protected final String replacementText;
61: protected final String baseUri;
62:
63: protected EntityDeclarationImpl(Location location,
64: String publicId, String systemId,
65: String name, String notationName,
66: String replacementText, String baseUri)
67: {
68: super(location);
69: this.publicId = publicId;
70: this.systemId = systemId;
71: this.name = name;
72: this.notationName = notationName;
73: this.replacementText = replacementText;
74: this.baseUri = baseUri;
75: }
76:
77: public int getEventType()
78: {
79: return ENTITY_DECLARATION;
80: }
81:
82: public String getPublicId()
83: {
84: return publicId;
85: }
86:
87: public String getSystemId()
88: {
89: return systemId;
90: }
91:
92: public String getName()
93: {
94: return name;
95: }
96:
97: public String getNotationName()
98: {
99: return notationName;
100: }
101:
102: public String getReplacementText()
103: {
104: return replacementText;
105: }
106:
107: public String getBaseURI()
108: {
109: return baseUri;
110: }
111:
112: public void writeAsEncodedUnicode(Writer writer)
113: throws XMLStreamException
114: {
115: try
116: {
117: writer.write("<!ENTITY ");
118: writer.write(name);
119: writer.write(' ');
120: if (systemId != null)
121: {
122: if (publicId != null)
123: {
124: writer.write(" PUBLIC ");
125: writer.write('"');
126: writer.write(publicId);
127: writer.write('"');
128: writer.write(' ');
129: writer.write('"');
130: writer.write(systemId);
131: writer.write('"');
132: }
133: else
134: {
135: writer.write(" SYSTEM ");
136: writer.write('"');
137: writer.write(systemId);
138: writer.write('"');
139: }
140: if (notationName != null)
141: {
142: writer.write(" NDATA ");
143: writer.write(notationName);
144: }
145: }
146: else
147: {
148: writer.write('"');
149: if (replacementText != null)
150: writer.write(replacementText);
151: writer.write('"');
152: }
153: writer.write(">");
154: }
155: catch (IOException e)
156: {
157: XMLStreamException e2 = new XMLStreamException(e.getMessage());
158: e2.initCause(e);
159: throw e2;
160: }
161: }
162:
163: }