1
|
|
/*
|
2
|
|
* JBind
|
3
|
|
*
|
4
|
|
* Copyright (c) by Stefan Wachter. All rights reserved.
|
5
|
|
*
|
6
|
|
* Usage, modification, and redistribution is subject to license terms that are
|
7
|
|
* available at 'http://www.jbind.org'. The JBind license is like the
|
8
|
|
* 'Apache Software License V 1.1'.
|
9
|
|
*/
|
10
|
|
package org.jbind.xml.core.bridge;
|
11
|
|
|
12
|
|
import java.io.IOException;
|
13
|
|
|
14
|
|
import org.jbind.xml.core.data.IImpl;
|
15
|
|
import org.jbind.xml.msg.XmlException;
|
16
|
|
import org.xml.sax.ContentHandler;
|
17
|
|
import org.xml.sax.DTDHandler;
|
18
|
|
import org.xml.sax.EntityResolver;
|
19
|
|
import org.xml.sax.ErrorHandler;
|
20
|
|
import org.xml.sax.InputSource;
|
21
|
|
import org.xml.sax.SAXException;
|
22
|
|
import org.xml.sax.SAXNotRecognizedException;
|
23
|
|
import org.xml.sax.SAXNotSupportedException;
|
24
|
|
import org.xml.sax.XMLReader;
|
25
|
|
|
26
|
|
/**
|
27
|
|
* XML Reader for a data implementation. Used by the
|
28
|
|
* {@link org.jbind.xml.facade.JBindFacade#createSaxSource createSaxSource} method.
|
29
|
|
*/
|
30
|
|
public class ImplReader implements XMLReader {
|
31
|
|
|
32
|
|
private ContentHandler myContentHandler = null;
|
33
|
|
|
34
|
|
private IImpl myImpl;
|
35
|
|
private SaxVisitor myVisitor = new SaxVisitor();
|
36
|
|
|
37
|
0
|
public ImplReader(IImpl anImpl) {
|
38
|
0
|
myImpl = anImpl;
|
39
|
|
}
|
40
|
|
|
41
|
0
|
private void parse() {
|
42
|
0
|
try {
|
43
|
0
|
myVisitor.outputSaxEvents(myImpl, myContentHandler, null, null);
|
44
|
|
} catch (XmlException e) {
|
45
|
0
|
e.printStackTrace();
|
46
|
|
}
|
47
|
|
}
|
48
|
|
|
49
|
0
|
public ContentHandler getContentHandler() {
|
50
|
0
|
return myContentHandler;
|
51
|
|
}
|
52
|
|
|
53
|
0
|
public DTDHandler getDTDHandler() {
|
54
|
0
|
return null;
|
55
|
|
}
|
56
|
|
|
57
|
0
|
public EntityResolver getEntityResolver() {
|
58
|
0
|
return null;
|
59
|
|
}
|
60
|
|
|
61
|
0
|
public ErrorHandler getErrorHandler() {
|
62
|
0
|
return null;
|
63
|
|
}
|
64
|
|
|
65
|
0
|
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
|
66
|
0
|
return false;
|
67
|
|
}
|
68
|
|
|
69
|
0
|
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
|
70
|
0
|
return null;
|
71
|
|
}
|
72
|
|
|
73
|
0
|
public void parse(String systemId) throws IOException, SAXException {
|
74
|
0
|
parse();
|
75
|
|
}
|
76
|
|
|
77
|
|
/**
|
78
|
|
* Outputs SAX events to the content handler.
|
79
|
|
*
|
80
|
|
* @param input <i>(optional)</i>. The supplied input is ignored. The
|
81
|
|
* data implementation that was supplied with the constructor is ouput as
|
82
|
|
* SAX events.
|
83
|
|
*/
|
84
|
0
|
public void parse(InputSource input) throws IOException, SAXException {
|
85
|
0
|
parse();
|
86
|
|
}
|
87
|
|
|
88
|
0
|
public void setContentHandler(ContentHandler aHandler) {
|
89
|
0
|
myContentHandler = aHandler;
|
90
|
|
}
|
91
|
|
|
92
|
0
|
public void setDTDHandler(DTDHandler handler) {}
|
93
|
|
|
94
|
0
|
public void setEntityResolver(EntityResolver resolver) {}
|
95
|
|
|
96
|
0
|
public void setErrorHandler(ErrorHandler handler) {}
|
97
|
|
|
98
|
0
|
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {}
|
99
|
|
|
100
|
0
|
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {}
|
101
|
|
|
102
|
|
}
|
103
|
|
|