home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / xml4j.jar / com / ibm / xml / parser / Child.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-08-30  |  6.2 KB  |  302 lines

  1. package com.ibm.xml.parser;
  2.  
  3. import com.ibm.xml.xpointer.XPointer;
  4. import java.io.IOException;
  5. import java.io.Serializable;
  6. import java.io.Writer;
  7. import org.w3c.dom.DOMException;
  8. import org.w3c.dom.Document;
  9. import org.w3c.dom.NamedNodeMap;
  10. import org.w3c.dom.Node;
  11. import org.w3c.dom.NodeList;
  12.  
  13. public abstract class Child implements Node, Cloneable, Serializable, Visitee {
  14.    static final long serialVersionUID = 6737260867707773565L;
  15.    public static final int ELEMENT_DECL = 20;
  16.    public static final int ATTLIST = 21;
  17.    public static final int ATTDEF = 22;
  18.    public static final int PSEUDONODE = 23;
  19.    public static final String NAME_DOCUMENT = "#document";
  20.    public static final String NAME_COMMENT = "#comment";
  21.    public static final String NAME_TEXT = "#text";
  22.    public static final String NAME_CDATA = "#cdata-section";
  23.    public static final String NAME_DOCFRAGMENT = "#document-fragment";
  24.    public static final String NAME_ATTDEF = "#attribute-definition";
  25.    public static final String NAME_ATTLIST = "#attribute-definition-list";
  26.    public static final String NAME_ELEMENT_DECL = "#element-declaration";
  27.    public static final String NAME_PSEUDONODE = "#pseudo-node";
  28.    Node parent;
  29.    Node prevSibling;
  30.    Node nextSibling;
  31.    transient byte[] digest;
  32.    TXDocument factory;
  33.    private Object userData;
  34.  
  35.    public abstract Object clone();
  36.  
  37.    public Node cloneNode(boolean var1) {
  38.       return (Node)this.clone();
  39.    }
  40.  
  41.    public abstract boolean equals(Node var1, boolean var2);
  42.  
  43.    public String getNodeValue() {
  44.       return null;
  45.    }
  46.  
  47.    public void setNodeValue(String var1) {
  48.       throw new TXDOMException((short)7, "setNodeValue(String) isn't supported in this class.");
  49.    }
  50.  
  51.    public Node getParentNode() {
  52.       return this.parent;
  53.    }
  54.  
  55.    public Node getParentWithoutReference() {
  56.       Node var1;
  57.       for(var1 = this.getParentNode(); var1 != null && var1.getNodeType() == 5; var1 = var1.getParentNode()) {
  58.       }
  59.  
  60.       return var1;
  61.    }
  62.  
  63.    public NodeList getChildNodes() {
  64.       return TXNodeList.emptyNodeList;
  65.    }
  66.  
  67.    public boolean hasChildNodes() {
  68.       return false;
  69.    }
  70.  
  71.    public Node getFirstChild() {
  72.       return null;
  73.    }
  74.  
  75.    public Node getFirstWithoutReference() {
  76.       return null;
  77.    }
  78.  
  79.    public Node getLastChild() {
  80.       return null;
  81.    }
  82.  
  83.    public Node getLastWithoutReference() {
  84.       return null;
  85.    }
  86.  
  87.    public Node getPreviousSibling() {
  88.       return this.prevSibling;
  89.    }
  90.  
  91.    public Node getPreviousWithoutReference() {
  92.       Node var1 = this.getPreviousSibling();
  93.       if (var1 == null) {
  94.          Node var3 = this.getParentNode();
  95.          if (var3 == null) {
  96.             return null;
  97.          }
  98.  
  99.          if (var3.getNodeType() == 5) {
  100.             var1 = ((Child)var3).getPreviousWithoutReference();
  101.          }
  102.       } else {
  103.          while(var1.getNodeType() == 5) {
  104.             Node var2 = var1.getLastChild();
  105.             if (var2 == null) {
  106.                var1 = ((Child)var1).getPreviousWithoutReference();
  107.                break;
  108.             }
  109.  
  110.             var1 = var2;
  111.          }
  112.       }
  113.  
  114.       return var1;
  115.    }
  116.  
  117.    public Node getNextSibling() {
  118.       return this.nextSibling;
  119.    }
  120.  
  121.    public Node getNextWithoutReference() {
  122.       Node var1 = this.getNextSibling();
  123.       if (var1 == null) {
  124.          Node var3 = this.getParentNode();
  125.          if (var3 == null) {
  126.             return null;
  127.          }
  128.  
  129.          if (var3.getNodeType() == 5) {
  130.             var1 = ((Child)var3).getNextWithoutReference();
  131.          }
  132.       } else {
  133.          while(var1.getNodeType() == 5) {
  134.             Node var2 = var1.getFirstChild();
  135.             if (var2 == null) {
  136.                var1 = ((Child)var1).getNextWithoutReference();
  137.                break;
  138.             }
  139.  
  140.             var1 = var2;
  141.          }
  142.       }
  143.  
  144.       return var1;
  145.    }
  146.  
  147.    public NamedNodeMap getAttributes() {
  148.       return null;
  149.    }
  150.  
  151.    public Node insertBefore(Node var1, Node var2) throws DOMException {
  152.       throw new TXDOMException((short)3, "com.ibm.xml.parser.Child#insertBefore(): Can't insert any nodes to this.");
  153.    }
  154.  
  155.    public Node replaceChild(Node var1, Node var2) throws DOMException {
  156.       throw new TXDOMException((short)3, "com.ibm.xml.parser.Child#replaceChild(): Can't insert any nodes to this.");
  157.    }
  158.  
  159.    public Node removeChild(Node var1) throws DOMException {
  160.       throw new TXDOMException((short)8, "com.ibm.xml.parser.Child#removeChild(): Can't insert any nodes to this.");
  161.    }
  162.  
  163.    public Node appendChild(Node var1) throws DOMException {
  164.       throw new TXDOMException((short)3, "com.ibm.xml.parser.Child#appendChild(): Can't insert any nodes to this.");
  165.    }
  166.  
  167.    public String getText() {
  168.       return "";
  169.    }
  170.  
  171.    public TXElement searchAncestors(String var1) {
  172.       return this.searchAncestors(0, (String)null, var1);
  173.    }
  174.  
  175.    public TXElement searchAncestors(int var1, String var2, String var3) {
  176.       Object var4 = this;
  177.  
  178.       while((var4 = ((Node)var4).getParentNode()) != null) {
  179.          if (!(var4 instanceof TXElement)) {
  180.             return null;
  181.          }
  182.  
  183.          if (Match.matchName((Namespace)var4, var1, var2, var3)) {
  184.             return (TXElement)var4;
  185.          }
  186.       }
  187.  
  188.       return null;
  189.    }
  190.  
  191.    public void toXMLString(Writer var1, String var2) throws IOException, LibraryException {
  192.       try {
  193.          ToXMLStringVisitor var3 = new ToXMLStringVisitor(var1, var2);
  194.          (new NonRecursivePreorderTreeTraversal(var3)).traverse(this);
  195.       } catch (IOException var4) {
  196.          throw var4;
  197.       } catch (Exception var5) {
  198.          throw new LibraryException("com.ibm.xml.parser.Child#toXMLString(): Unexpected Exception: " + ((Throwable)var5).toString());
  199.       }
  200.    }
  201.  
  202.    public void toXMLString(Writer var1) throws IOException, LibraryException {
  203.       this.toXMLString(var1, (String)null);
  204.    }
  205.  
  206.    public void print(Writer var1, String var2) throws IOException, LibraryException {
  207.       this.toXMLString(var1, var2);
  208.    }
  209.  
  210.    public void print(Writer var1) throws IOException, LibraryException {
  211.       this.print(var1, (String)null);
  212.    }
  213.  
  214.    public Document getOwnerDocument() {
  215.       return this.factory;
  216.    }
  217.  
  218.    public TXDocument getFactory() {
  219.       return this.factory;
  220.    }
  221.  
  222.    public void setFactory(TXDocument var1) {
  223.       this.factory = var1;
  224.    }
  225.  
  226.    public byte[] getDigest() throws LibraryException {
  227.       if (this.digest == null) {
  228.          this.checkFactory();
  229.  
  230.          try {
  231.             MakeDigestVisitor var1 = new MakeDigestVisitor(this.getFactory().createMessageDigest());
  232.             (new NonRecursivePreorderTreeTraversal(var1)).traverse(this);
  233.          } catch (Exception var2) {
  234.             throw new LibraryException("com.ibm.xml.parser.Child#getDigest(): Unexpected Exception: " + ((Throwable)var2).toString());
  235.          }
  236.       }
  237.  
  238.       return this.digest;
  239.    }
  240.  
  241.    public void clearDigest() {
  242.       if (this.digest != null) {
  243.          this.digest = null;
  244.          if (this.parent != null) {
  245.             ((Child)this.parent).clearDigest();
  246.          }
  247.       }
  248.  
  249.    }
  250.  
  251.    public XPointer makeXPointer() {
  252.       return XPointer.makeXPointer(this);
  253.    }
  254.  
  255.    void checkFactory() {
  256.       if (this.factory == null) {
  257.          if (TXDocument.s_instance == null) {
  258.             TXDocument.s_instance = new TXDocument();
  259.          }
  260.  
  261.          this.factory = TXDocument.s_instance;
  262.       }
  263.  
  264.    }
  265.  
  266.    void setParentNode(Node var1) {
  267.       this.parent = var1;
  268.    }
  269.  
  270.    void setPreviousSibling(Node var1) {
  271.       this.prevSibling = var1;
  272.    }
  273.  
  274.    void setNextSibling(Node var1) {
  275.       this.nextSibling = var1;
  276.    }
  277.  
  278.    byte[] getVisitorDigest() {
  279.       return this.digest;
  280.    }
  281.  
  282.    void setVisitorDigest(byte[] var1) {
  283.       this.digest = var1;
  284.    }
  285.  
  286.    public void setUserData(Object var1) {
  287.       this.userData = var1;
  288.    }
  289.  
  290.    public Object getUserData() {
  291.       return this.userData;
  292.    }
  293.  
  294.    public abstract String getNodeName();
  295.  
  296.    public abstract short getNodeType();
  297.  
  298.    public abstract void acceptPre(Visitor var1) throws Exception;
  299.  
  300.    public abstract void acceptPost(Visitor var1) throws Exception;
  301. }
  302.