1 28 29 package com.caucho.xml; 30 31 import org.w3c.dom.Entity ; 32 import org.w3c.dom.Node ; 33 34 import java.io.IOException ; 35 36 class QEntity extends QNode implements Entity { 37 String _name; 38 String _value; 39 String _publicId; 40 String _systemId; 41 String _ndata; 42 boolean _isPe; 43 boolean _isSpecial; 44 45 QEntity(String name, String 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 name, String value, String publicId, String 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 getNodeName() { return _name; } 65 public String getTagName() { return _name; } 66 public short getNodeType() { return Node.ENTITY_NODE; } 67 68 public String getPublicId() { return _publicId; } 69 public void setPublicId(String arg) { _publicId = arg; } 70 71 public String getSystemId() { return _systemId; } 72 public void setSystemId(String arg) { _systemId = arg; } 73 74 public String getValue() { return _value; } 75 public void setValue(String arg) { _value = arg; } 76 77 public String getNotationName() { return _ndata; } 78 public void setNotationName(String arg) { _ndata = arg; } 79 80 Node importNode(QDocument owner, boolean deep) 81 { 82 QEntity entity = new QEntity(_name, _value, _publicId, _systemId); 83 84 return entity; 85 } 86 87 89 public String getActualEncoding() 90 { 91 throw new UnsupportedOperationException (); 92 } 93 94 public void setActualEncoding(String actualEncoding) 95 { 96 throw new UnsupportedOperationException (); 97 } 98 99 public String getEncoding() 100 { 101 throw new UnsupportedOperationException (); 102 } 103 104 public void setEncoding(String encoding) 105 { 106 throw new UnsupportedOperationException (); 107 } 108 109 public String getVersion() 110 { 111 throw new UnsupportedOperationException (); 112 } 113 114 public String getXmlVersion() 115 { 116 throw new UnsupportedOperationException (); 117 } 118 119 public String getXmlEncoding() 120 { 121 throw new UnsupportedOperationException (); 122 } 123 124 public String getInputEncoding() 125 { 126 throw new UnsupportedOperationException (); 127 } 128 129 public void setVersion(String version) 130 { 131 throw new UnsupportedOperationException (); 132 } 133 134 void print(XmlPrinter out) throws IOException 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 toString() 173 { 174 if (_systemId != null) 175 return "QEntity[" + _name + " SYSTEM \"" + _systemId + "\"]"; 176 else 177 return "QEntity[" + _name + " \"" + _value + "\"]"; 178 } 179 } 180 | Popular Tags |