01: package com.jeta.forms.store.xml.parser;
02:
03: import java.util.LinkedList;
04:
05: import org.xml.sax.Attributes;
06: import org.xml.sax.SAXException;
07:
08: public class XMLNodeContext {
09: private LinkedList m_stack = new LinkedList();
10:
11: private String m_uri;
12: private String m_qName;
13: private Attributes m_attribs;
14:
15: public Attributes getAttributes() {
16: return m_attribs;
17: }
18:
19: public XMLHandler getCurrentHandler() {
20: if (m_stack.size() > 0)
21: return (XMLHandler) m_stack.getFirst();
22: else
23: return null;
24: }
25:
26: public void push(XMLHandler handler) throws SAXException {
27: if (m_stack.contains(handler)) {
28: throw new SAXException(
29: "XMLNodeContext invalid state. Handler already on call stack: "
30: + handler);
31: }
32: m_stack.addFirst(handler);
33: }
34:
35: public void pop(XMLHandler handler) throws SAXException {
36: if (m_stack.size() == 0) {
37: throw new SAXException(
38: "XMLNodeContext invalid state. Tried to pop from empty stack.");
39: }
40: Object obj = m_stack.removeFirst();
41: if (handler != null && obj != handler) {
42: throw new SAXException(
43: "XMLNodeContext invalid state. Expected to find the specified handler on the call stack: "
44: + handler + "\n.But found instead: " + obj);
45: }
46: }
47:
48: public String getQualifiedName() {
49: return m_qName;
50: }
51:
52: public void set(String uri, String qName, Attributes attribs) {
53: m_uri = uri;
54: m_qName = qName;
55: m_attribs = attribs;
56: }
57:
58: }
|