KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > io > xml > XppDriver


1 package com.thoughtworks.xstream.io.xml;
2
3 import com.thoughtworks.xstream.io.HierarchicalStreamDriver;
4 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
5
6 import java.io.Reader JavaDoc;
7
8 public class XppDriver implements HierarchicalStreamDriver {
9
10     private static boolean xppLibraryPresent;
11
12     public HierarchicalStreamReader createReader(Reader xml) {
13         if (!xppLibraryPresent) {
14             try {
15                 Class.forName("org.xmlpull.mxp1.MXParser");
16             } catch (ClassNotFoundException JavaDoc e) {
17                 throw new IllegalArgumentException JavaDoc("XPP3 pull parser library not present. Specify another driver." +
18                         " For example: new XStream(new DomDriver())");
19             }
20             xppLibraryPresent = true;
21         }
22         return new XppReader(xml);
23     }
24 }
25
Popular Tags