home *** CD-ROM | disk | FTP | other *** search
- package com.ms.xml.parser;
-
- import com.ms.xml.om.ElementImpl;
- import com.ms.xml.util.Atom;
- import com.ms.xml.util.Name;
- import com.ms.xml.util.StringInputStream;
- import com.ms.xml.util.XMLOutputStream;
- import java.io.IOException;
- import java.util.Enumeration;
-
- public class Entity extends ElementImpl {
- static String nameENTITY = "ENTITY";
- static Atom nameXML = Atom.create("XML");
- static Atom nameSpaceID = Atom.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;
- static Name nameNAME = Name.create("NAME", "XML");
- static Name namePUBLICID = Name.create("PUBLICID", "XML");
- static Name nameSYSTEMID = Name.create("SYSTEMID", "XML");
- static Name nameINTENTITYDCL = Name.create("INTENTITYDCL", "XML");
- static Name nameEXTENTITYDCL = Name.create("EXTENTITYDCL", "XML");
- static Name nameNOTATION = Name.create("NOTATION", "XML");
- static Name namePAR = Name.create("PAR", "XML");
-
- char getChar(int var1) {
- return this.text == null ? this.cdata : this.text.charAt(var1);
- }
-
- public Object getAttribute(Name var1) {
- this.getAttributes();
- return super.getAttribute(var1);
- }
-
- Entity(Name var1, boolean var2) {
- super(Name.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;
- super.setText(String.valueOf(this.cdata));
- this.setPosition(0, 0);
- }
-
- void setNDATA(Name var1) {
- this.ndata = var1;
- }
-
- EntityReader getReader(EntityReader var1) {
- return new EntityReader(new StringInputStream(this.text), this.line, this.column, var1, this);
- }
-
- public Enumeration getAttributes() {
- if (super.getAttribute(nameNAME) == null) {
- ((ElementImpl)this).setAttribute(nameNAME, this.name);
- if (this.pubid != null) {
- ((ElementImpl)this).setAttribute(namePUBLICID, this.pubid);
- }
-
- if (this.url != null) {
- ((ElementImpl)this).setAttribute(nameSYSTEMID, this.url);
- }
-
- if (this.ndata != null) {
- ((ElementImpl)this).setAttribute(nameNOTATION, this.ndata);
- }
- }
-
- return super.getAttributes();
- }
-
- public void save(XMLOutputStream var1) throws IOException {
- if (var1.savingDTD) {
- var1.writeIndent();
- this.saveEntity(var1);
- var1.writeNewLine();
- } else {
- super.save(var1);
- }
- }
-
- void setURL(String var1) {
- this.url = var1;
- this.sys = true;
- }
-
- String getURL() {
- return this.url;
- }
-
- 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, (Atom)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, this.name.getNameSpace());
- }
- } 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 Name getTagName() {
- return this.sys ? nameEXTENTITYDCL : nameINTENTITYDCL;
- }
- }
-