Project

General

Profile

1
/**
2
 *        Name: DBElement.java
3
 *     Purpose: A Class that represents an XML element and can
4
 *		write its contents to a database connection
5
 * Institution: National Center for Ecological Analysis and Synthesis
6
 *   Copyright: 1998
7
 *     Authors: Matt Jones
8
 *
9
 *     Version: '$Id: DBElement.java 6 1999-09-13 00:18:59Z jones $'
10
 */
11

    
12
//package project;
13

    
14
import com.sun.xml.tree.ElementNode;
15

    
16
import org.w3c.dom.DOMException;
17
import org.w3c.dom.Element;
18
import org.w3c.dom.Node;
19
import org.w3c.dom.ProcessingInstruction;
20
import org.w3c.dom.Text;
21

    
22

    
23
public class DBElement extends ElementNode
24
{
25
    public DBElement () {
26
      super();
27
    };
28
    
29
    public String getJunk() {
30
	return "This is " + getTagName() + " junk!";
31
    }
32

    
33
    // used by JTree to display this node
34
    public String toString ()
35
    {
36
	StringBuffer	value = new StringBuffer ();
37
	value.append ('<');
38
	value.append (getTagName ());
39
	value.append (getAttributes ().toString ());
40
	value.append ('>');
41
	return value.toString ();
42
    }
43
    
44
    // TreeNode method implementations
45
/*
46
    public TreeNode getChildAt (int n) {
47
    	//System.out.println ("DBElement.getChildAt()");
48
	Node		node = item (n);
49
	
50
	if (node instanceof TreeNode)
51
            return (TreeNode) node;
52
        // Text, ProcessingInstruction ...
53
        return new MaskedNode (node);
54
    }
55
*/
56
    
57
    //
58
    // In this case we really _do_ want to show all the internal
59
    // nodes, so we really ought to use custom TreeNode and
60
    // ProcessingInstruction classes as we build.
61
    //
62
/*
63
    static class MaskedNode implements TreeNode {
64
    	private Node	real;
65
    	MaskedNode (Node e) { real = e; }
66
    	
67
    	public int getChildCount () { return 0; }
68
    	public TreeNode getChildAt (int n) { return null; }
69
    	public TreeNode getParent ()
70
    		{ return (TreeNode) real.getParentNode (); }
71
    	public int getIndex (TreeNode node) { return -1; }
72
    	public boolean getAllowsChildren () { return false; }
73
    	public boolean isLeaf () { return true; }
74
    	public Enumeration children () { return null; }
75
    	
76
    	public String toString () {
77
    	    if (real instanceof Text)
78
    	       return real.toString ();		// XXX constructor
79
    	    if (real instanceof ProcessingInstruction)
80
    	       return real.toString ();		// XXX unreasonable result
81
    	    return "... ? ...";
82
    	}
83
    }
84
 */   	
85
   /* 
86
    public int getChildCount () {
87
    	return getLength ();
88
    }
89
    
90
    public TreeNode getParent () {
91
        return (TreeNode) getParentNode ();
92
    }
93
    
94
    public int getIndex (TreeNode node) {
95
        return -1;                  // XXX implement
96
    }
97
    
98
    public boolean getAllowsChildren () {
99
        return true;
100
    }
101
    
102
    public boolean isLeaf () {
103
        return !hasChildNodes ();
104
    }
105
    
106
    public Enumeration children () {
107
    	//System.out.println ("DBElement.children()");
108

    
109
	throw new RuntimeException ("NYI");
110
    }
111
   */ 
112
}
(1-1/5)