KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > xml > QEntity


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.xml;
30
31 import org.w3c.dom.Entity JavaDoc;
32 import org.w3c.dom.Node JavaDoc;
33
34 import java.io.IOException JavaDoc;
35
36 class QEntity extends QNode implements Entity JavaDoc {
37   String JavaDoc _name;
38   String JavaDoc _value;
39   String JavaDoc _publicId;
40   String JavaDoc _systemId;
41   String JavaDoc _ndata;
42   boolean _isPe;
43   boolean _isSpecial;
44
45   QEntity(String JavaDoc name, String JavaDoc value)
46   {
47     _name = name;
48     _value = value;
49     _isSpecial = true;
50     if (value != null)
51       _firstChild = new QText(value);
52   }
53
54   QEntity(String JavaDoc name, String JavaDoc value, String JavaDoc publicId, String JavaDoc systemId)
55   {
56     _name = name;
57     _value = value;
58     _systemId = systemId;
59     _publicId = publicId;
60     if (value != null)
61       _firstChild = new QText(value);
62   }
63
64   public String JavaDoc getNodeName() { return _name; }
65   public String JavaDoc getTagName() { return _name; }
66   public short getNodeType() { return Node.ENTITY_NODE; }
67
68   public String JavaDoc getPublicId() { return _publicId; }
69   public void setPublicId(String JavaDoc arg) { _publicId = arg; }
70
71   public String JavaDoc getSystemId() { return _systemId; }
72   public void setSystemId(String JavaDoc arg) { _systemId = arg; }
73
74   public String JavaDoc getValue() { return _value; }
75   public void setValue(String JavaDoc arg) { _value = arg; }
76
77   public String JavaDoc getNotationName() { return _ndata; }
78   public void setNotationName(String JavaDoc arg) { _ndata = arg; }
79
80   Node JavaDoc importNode(QDocument owner, boolean deep)
81   {
82     QEntity entity = new QEntity(_name, _value, _publicId, _systemId);
83
84     return entity;
85   }
86
87   // DOM LEVEL 3
88

89   public String JavaDoc getActualEncoding()
90   {
91     throw new UnsupportedOperationException JavaDoc();
92   }
93   
94   public void setActualEncoding(String JavaDoc actualEncoding)
95   {
96     throw new UnsupportedOperationException JavaDoc();
97   }
98
99   public String JavaDoc getEncoding()
100   {
101     throw new UnsupportedOperationException JavaDoc();
102   }
103   
104   public void setEncoding(String JavaDoc encoding)
105   {
106     throw new UnsupportedOperationException JavaDoc();
107   }
108
109   public String JavaDoc getVersion()
110   {
111     throw new UnsupportedOperationException JavaDoc();
112   }
113
114   public String JavaDoc getXmlVersion()
115   {
116     throw new UnsupportedOperationException JavaDoc();
117   }
118
119   public String JavaDoc getXmlEncoding()
120   {
121     throw new UnsupportedOperationException JavaDoc();
122   }
123
124   public String JavaDoc getInputEncoding()
125   {
126     throw new UnsupportedOperationException JavaDoc();
127   }
128   
129   public void setVersion(String JavaDoc version)
130   {
131     throw new UnsupportedOperationException JavaDoc();
132   }
133
134   void print(XmlPrinter out) throws IOException JavaDoc
135   {
136     out.print("<!ENTITY ");
137     if (_isPe)
138       out.print("% ");
139     out.print(_name);
140     if (_publicId != null) {
141       out.print(" PUBLIC \"");
142       out.printDecl(_publicId);
143       out.print("\"");
144       if (_systemId != null) {
145     out.print(" \"");
146     out.printDecl(_systemId);
147     out.print("\"");
148       }
149
150       if (_ndata != null) {
151     out.print(" NDATA ");
152     out.printDecl(_ndata);
153       }
154     } else if (_systemId != null) {
155       out.print(" SYSTEM \"");
156       out.printDecl(_systemId);
157       out.print("\"");
158
159       if (_ndata != null) {
160     out.print(" NDATA ");
161     out.printDecl(_ndata);
162       }
163     }
164     else if (_value != null) {
165       out.print(" \"");
166       out.printDecl(_value);
167       out.print("\"");
168     }
169     out.println(">");
170   }
171
172   public String JavaDoc toString()
173   {
174     if (_systemId != null)
175       return "QEntity[" + _name + " SYSTEM \"" + _systemId + "\"]";
176     else
177       return "QEntity[" + _name + " \"" + _value + "\"]";
178   }
179 }
180
Popular Tags