01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.http.protocol.transaction;
07:
08: import java.io.IOException;
09: import java.io.InputStream;
10: import java.io.Reader;
11: import java.util.Collection;
12:
13: import org.xml.sax.SAXException;
14:
15: import info.aduna.xml.SimpleSAXParser;
16:
17: import org.openrdf.http.protocol.transaction.operations.TransactionOperation;
18:
19: public class TransactionReader {
20:
21: /**
22: * parse the transaction from the serialization
23: *
24: * @param in
25: * @return
26: * @throws SAXException
27: * If the SimpleSAXParser was unable to create an XMLReader or if the
28: * XML is faulty.
29: * @throws IOException
30: * If IO problems during parsing.
31: */
32: public Collection<TransactionOperation> parse(InputStream in)
33: throws SAXException, IOException {
34: SimpleSAXParser saxParser = new SimpleSAXParser();
35: TransactionSAXParser handler = new TransactionSAXParser();
36: saxParser.setListener(handler);
37: saxParser.parse(in);
38: return handler.getTxn();
39: }
40:
41: /**
42: * parse the transaction from the serialization
43: *
44: * @param in
45: * @return
46: * @throws SAXException
47: * If the SimpleSAXParser was unable to create an XMLReader or if the
48: * XML is faulty.
49: * @throws IOException
50: * If IO problems during parsing.
51: */
52: public Collection<TransactionOperation> parse(Reader in)
53: throws SAXException, IOException {
54: SimpleSAXParser saxParser = new SimpleSAXParser();
55: TransactionSAXParser handler = new TransactionSAXParser();
56: saxParser.setListener(handler);
57: saxParser.parse(in);
58: return handler.getTxn();
59: }
60: }
|