home *** CD-ROM | disk | FTP | other *** search
- package com.ms.xml.parser;
-
- import com.ms.xml.om.ElementImpl;
- import com.ms.xml.util.Name;
- import com.ms.xml.util.QualifiedName;
- import com.ms.xml.util.XMLOutputStream;
- import java.io.IOException;
- import java.io.StringBufferInputStream;
-
- public class Entity extends ElementImpl {
- static Name nameENTITY = Name.create("ENTITY");
- static Name nameXML = Name.create("XML");
- static Name nameSpaceID = Name.create("//XML/NAMESPACE");
- Name name;
- String url;
- String pubid;
- String text;
- char cdata;
- Name ndata;
- int line;
- int column;
- boolean par;
- boolean sys;
- boolean parsed;
-
- char getChar(int var1) {
- return this.text == null ? this.cdata : this.text.charAt(var1);
- }
-
- void setNDATA(Name var1) {
- this.ndata = var1;
- }
-
- EntityReader getReader(EntityReader var1) {
- return new EntityReader(new StringBufferInputStream(this.text), this.line, this.column, var1, this);
- }
-
- public void save(XMLOutputStream var1) throws IOException {
- var1.writeIndent();
- this.saveEntity(var1);
- var1.writeNewLine();
- }
-
- void setURL(String var1) {
- this.url = var1;
- this.sys = true;
- }
-
- String getURL() {
- return this.url;
- }
-
- Entity(Name var1, boolean var2) {
- super(QualifiedName.create(nameENTITY, nameXML), 7);
- this.name = var1;
- this.par = var2;
- this.parsed = false;
- }
-
- Entity(Name var1, boolean var2, String var3) {
- this(var1, var2);
- this.setText(var3);
- this.setPosition(0, 0);
- }
-
- Entity(Name var1, boolean var2, int var3) {
- this(var1, var2);
- this.cdata = (char)var3;
- this.setText((String)null);
- this.setPosition(0, 0);
- }
-
- void setPosition(int var1, int var2) {
- this.line = var1;
- this.column = var2;
- }
-
- public Name getName() {
- return this.name;
- }
-
- public void saveEntity(XMLOutputStream var1) throws IOException {
- var1.writeChars("<!ENTITY ");
- if (this.par) {
- var1.writeChars("% ");
- }
-
- var1.writeQualifiedName(this.name, (Name)null);
- var1.writeChars(" ");
- if (this.url != null) {
- if (this.pubid == null) {
- var1.writeChars("SYSTEM ");
- } else {
- var1.writeChars("PUBLIC ");
- var1.writeQuotedString(this.pubid);
- var1.write(32);
- }
-
- var1.writeQuotedString(this.url.toString());
- if (this.ndata != null) {
- var1.writeChars(" NDATA ");
- var1.writeQualifiedName(this.ndata, QualifiedName.getNameSpace(this.name));
- }
- } else if (this.text != null) {
- var1.writeQuotedString(this.text);
- }
-
- var1.write(62);
- }
-
- int getLength() {
- if (this.cdata > 0) {
- return -1;
- } else {
- return this.text == null ? 0 : this.text.length();
- }
- }
-
- public void setText(String var1) {
- this.text = var1;
- this.sys = false;
- }
-
- public String getText() {
- return this.text;
- }
- }
-