1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.mirae.j2me.xml;
18
19 import java.util.Hashtable;
20
21 import javax.xml.parsers.ParserConfigurationException;
22 import javax.xml.parsers.SAXParser;
23 import javax.xml.parsers.SAXParserFactory;
24
25 import org.xml.sax.SAXException;
26 import org.xml.sax.SAXNotRecognizedException;
27 import org.xml.sax.SAXNotSupportedException;
28
29 /***
30 * This is an implementation of javax.xml.parsers.SAXParserFactory
31 * @author Ias (iasandcb@tmax.co.kr)
32 *
33 */
34 public class SAXParserFactoryImpl extends SAXParserFactory {
35
36 /*** SAX feature prefix ("http://xml.org/sax/features/" target="alexandria_uri">http://xml.org/sax/features/"). */
37 public static final String SAX_FEATURE_PREFIX = "http://xml.org/sax/features/";
38
39 /*** Namespaces feature ("namespaces"). */
40 public static final String NAMESPACES_FEATURE = "namespaces";
41
42 /*** Namespace prefixes feature ("namespace-prefixes"). */
43 public static final String NAMESPACE_PREFIXES_FEATURE = "namespace-prefixes";
44
45
46 private Hashtable features;
47
48 /***
49 * a default constructor
50 */
51 public SAXParserFactoryImpl() {
52 features = new Hashtable();
53 features.put(SAX_FEATURE_PREFIX + NAMESPACES_FEATURE, new Boolean(true));
54 features.put(SAX_FEATURE_PREFIX + NAMESPACE_PREFIXES_FEATURE, new Boolean(false));
55 }
56 /***
57 * @see javax.xml.parsers.SAXParserFactory#setFeature(java.lang.String, boolean)
58 */
59 public void setFeature(String name, boolean value)
60 throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
61 features.put(name, value ? new Boolean(true) : new Boolean(false));
62 }
63
64 /***
65 * @see javax.xml.parsers.SAXParserFactory#getFeature(java.lang.String)
66 */
67 public boolean getFeature(String name)
68 throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
69 Boolean value = (Boolean) features.get(name);
70 return value.booleanValue();
71 }
72
73 /***
74 * @see javax.xml.parsers.SAXParserFactory#newSAXParser()
75 */
76 public SAXParser newSAXParser() throws ParserConfigurationException, SAXException {
77 return new SAXParserImpl(this);
78 }
79 }