| 1 |
package cds.astrores.sax; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
import java.io.IOException; |
| 25 |
import java.io.InputStream; |
| 26 |
import java.net.URL; |
| 27 |
|
| 28 |
|
| 29 |
import org.kxml2.io.KXmlParser; |
| 30 |
import org.xmlpull.v1.XmlPullParser; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
@SuppressWarnings({"deprecation", "UseOfSystemOutOrSystemErr"}) |
| 47 |
public class AstroresSAXParser { |
| 48 |
|
| 49 |
|
| 50 |
private AstroresSAXEngine engine = null; |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public AstroresSAXParser(AstroresSAXConsumer consumer, String file) { |
| 61 |
this(consumer, file, false); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
public AstroresSAXParser(AstroresSAXConsumer consumer, String file, |
| 75 |
boolean debug) { |
| 76 |
|
| 77 |
try { |
| 78 |
|
| 79 |
XmlPullParser parser = new KXmlParser(); |
| 80 |
|
| 81 |
engine = new AstroresSAXEngine(consumer, parser, file, debug); |
| 82 |
|
| 83 |
engine.parse(parser); |
| 84 |
|
| 85 |
} catch (IOException e) { |
| 86 |
System.err.println("AstroresSAXParser : " + e); |
| 87 |
} catch (Exception f) { |
| 88 |
System.err.println("AstroresSAXParser : " + f); |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
public AstroresSAXParser(AstroresSAXConsumer consumer, URL url, String enc) { |
| 103 |
this(consumer, url, enc, false); |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
public AstroresSAXParser(AstroresSAXConsumer consumer, URL url, String enc, |
| 119 |
boolean debug) { |
| 120 |
|
| 121 |
try { |
| 122 |
|
| 123 |
KXmlParser parser = new KXmlParser(); |
| 124 |
|
| 125 |
engine = new AstroresSAXEngine(consumer, parser, url, enc, debug); |
| 126 |
|
| 127 |
engine.parse(parser); |
| 128 |
|
| 129 |
} catch (IOException e) { |
| 130 |
System.err.println("AstroresSAXParser : " + e); |
| 131 |
} catch (Exception f) { |
| 132 |
System.err.println("AstroresSAXParser : " + f); |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
public AstroresSAXParser(AstroresSAXConsumer consumer, |
| 147 |
InputStream instream, String enc) { |
| 148 |
this(consumer, instream, enc, false); |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
public AstroresSAXParser(AstroresSAXConsumer consumer, |
| 164 |
InputStream instream, String enc, boolean debug) { |
| 165 |
try { |
| 166 |
|
| 167 |
KXmlParser parser = new KXmlParser(); |
| 168 |
|
| 169 |
engine = new AstroresSAXEngine(consumer, parser, instream, enc, |
| 170 |
debug); |
| 171 |
|
| 172 |
engine.parse(parser); |
| 173 |
|
| 174 |
} catch (IOException e) { |
| 175 |
System.err.println("AstroresSAXParser : " + e); |
| 176 |
} catch (Exception f) { |
| 177 |
System.err.println("AstroresSAXParser : " + f); |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
public static void main(String[] argv) throws IOException { |
| 188 |
|
| 189 |
if (argv.length == 0) { |
| 190 |
System.err.println("Usage: java AstroresSAXParser <xml document>"); |
| 191 |
} else { |
| 192 |
|
| 193 |
} |
| 194 |
} |
| 195 |
} |