KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xmlpull > mxp1 > MXParserFactory


1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/
2 /*
3  * Copyright (c) 2002 Extreme! Lab, Indiana University. All rights reserved.
4  *
5  * This software is open source. See the bottom of this file for the licence.
6  *
7  * $Id: MXParserFactory.java,v 1.2 2002/08/13 02:23:44 aslom Exp $
8  */

9
10 package org.xmlpull.mxp1;
11
12 import java.util.Enumeration JavaDoc;
13
14 import org.xmlpull.v1.XmlPullParser;
15 import org.xmlpull.v1.XmlPullParserException;
16 import org.xmlpull.v1.XmlPullParserFactory;
17 import org.xmlpull.v1.XmlSerializer;
18
19 import org.xmlpull.mxp1_serializer.MXSerializer;
20
21 /**
22  * Simple facotry to speed up creation process.
23  *
24  * @author <a HREF="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
25  */

26
27 public class MXParserFactory
28     extends XmlPullParserFactory
29 {
30     protected static boolean stringCachedParserAvailable = true;
31
32     public XmlPullParser newPullParser() throws XmlPullParserException {
33         XmlPullParser pp = null;
34         if(stringCachedParserAvailable) {
35             try {
36                 pp = new MXParserCachingStrings();
37             } catch(Exception JavaDoc ex) {
38                 stringCachedParserAvailable = false;
39             }
40         }
41         if(pp == null) {
42             pp = new MXParser();
43         }
44         for (Enumeration JavaDoc e = features.keys (); e.hasMoreElements ();) {
45             String JavaDoc key = (String JavaDoc) e.nextElement();
46             Boolean JavaDoc value = (Boolean JavaDoc) features.get(key);
47             if(value != null && value.booleanValue()) {
48                 pp.setFeature(key, true);
49             }
50         }
51         return pp;
52
53     }
54
55     public XmlSerializer newSerializer() throws XmlPullParserException {
56         return new MXSerializer();
57     }
58 }
59
60
61 /*
62  * Indiana University Extreme! Lab Software License, Version 1.1.1
63  *
64  *
65  * Copyright (c) 2002 Extreme! Lab, Indiana University. All rights
66  * reserved.
67  *
68  * Redistribution and use in source and binary forms, with or without
69  * modification, are permitted provided that the following conditions
70  * are met:
71  *
72  * 1. Redistributions of source code must retain the above copyright
73  * notice, this list of conditions and the following disclaimer.
74  *
75  * 2. Redistributions in binary form must reproduce the above copyright
76  * notice, this list of conditions and the following disclaimer in
77  * the documentation and/or other materials provided with the
78  * distribution.
79  *
80  * 3. The end-user documentation included with the redistribution,
81  * if any, must include the following acknowledgment:
82  * "This product includes software developed by the Indiana
83  * University Extreme! Lab (http://www.extreme.indiana.edu/)."
84  * Alternately, this acknowledgment may appear in the software itself,
85  * if and wherever such third-party acknowledgments normally appear.
86  *
87  * 4. The names "Indiana University" and "Indiana University
88  * Extreme! Lab" must not be used to endorse or promote products
89  * derived from this software without prior written permission. For
90  * written permission, please contact http://www.extreme.indiana.edu/.
91  *
92  * 5. Products derived from this software may not use "Indiana
93  * University" name nor may "Indiana University" appear in their name,
94  * without prior written permission of the Indiana University.
95  *
96  *
97  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
98  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
99  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
100  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
101  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
102  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
103  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
104  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
105  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
106  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
107  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
108  * SUCH DAMAGE.
109  */

110
111
Popular Tags