b67c489501f95c264c36f9197328886b3a87607c
[mir.git] / source / mir / xml / SaxContext.java
1 package mir.xml;
2
3
4 // XXX this interface is not final, but a prototype.
5
6 /** SAX Context - used to match and perform actions
7  *    provide access to the current stack and XML elements.
8  *
9  *    Inspired by Tomcat's SAX context, although our's is
10  *    implemented and used slightly differently.
11  *
12  * @author 
13  */
14 public class SaxContext  {
15
16     private String tagStack[];
17     private int pos;
18
19     // -------------------- Konstruktor
20     
21     public SaxContext() {
22         pos=0;
23         tagStack = new String[256];
24     }
25     
26     // -------------------- Access to parsing context
27
28     /** Depth of the tag stack.
29      */
30     public int getTagCount() {
31         return pos;
32     }
33
34     /** Access a particular tag
35      */
36     public String getTag( int pos ) {
37         return tagStack[pos];
38     }
39
40     // ------------------- Adjusting the parsing context
41     public void push(String tag) {
42         tagStack[pos] = tag;
43         pos++;
44     }
45         
46     public void pop() {
47         if(pos > 1)
48             tagStack[pos]=null;
49
50         pos--;
51     }
52
53 }
54