6 |
|
import java.util.ArrayList; |
7 |
|
|
8 |
|
import org.xml.sax.*; |
9 |
+ |
import org.xml.sax.helpers.*; |
10 |
|
import javax.xml.parsers.SAXParserFactory; |
11 |
|
import javax.xml.parsers.ParserConfigurationException; |
12 |
|
import javax.xml.parsers.SAXParser; |
17 |
|
* @author $Author$ |
18 |
|
* @version $Id$ |
19 |
|
*/ |
20 |
< |
public class XMLPacketMaker extends HandlerBase { |
20 |
> |
public class XMLPacketMaker { |
21 |
|
|
22 |
|
//---FINAL ATTRIBUTES--- |
23 |
|
|
26 |
|
*/ |
27 |
|
public final String REVISION = "$Revision$"; |
28 |
|
|
29 |
+ |
/** |
30 |
+ |
* A static reference to the system saxParser |
31 |
+ |
* Use the default (non-validating) parser |
32 |
+ |
*/ |
33 |
+ |
private static SAXParser saxParser = null; |
34 |
+ |
private static SAXParserFactory factory = SAXParserFactory.newInstance(); |
35 |
+ |
|
36 |
|
//---STATIC METHODS--- |
37 |
|
|
38 |
|
//---CONSTRUCTORS--- |
59 |
|
|
60 |
|
// Create the XMLPacket to store values in. |
61 |
|
XMLPacket packet = new XMLPacket(); |
62 |
< |
|
55 |
< |
// Use the default (non-validating) parser |
56 |
< |
SAXParserFactory factory = SAXParserFactory.newInstance(); |
62 |
> |
|
63 |
|
try { |
64 |
|
// Parse the input |
65 |
|
InputSource inputSource = new InputSource(new StringReader(_xml)); |
66 |
< |
SAXParser saxParser = factory.newSAXParser(); |
66 |
> |
|
67 |
> |
if (saxParser == null) { |
68 |
> |
saxParser = factory.newSAXParser(); |
69 |
> |
} |
70 |
> |
|
71 |
|
saxParser.parse(inputSource, new XMLStringParser(packet)); |
72 |
|
} |
73 |
|
catch (Exception e) { |