1 // $Id: MarcXmlParserThread.java,v 1.3 2008/09/26 21:17:42 haschart Exp $
\r
3 * Copyright (C) 2004 Bas Peters
\r
5 * This file is part of MARC4J
\r
7 * MARC4J is free software; you can redistribute it and/or modify it under the
\r
8 * terms of the GNU Lesser General Public License as published by the Free
\r
9 * Software Foundation; either version 2.1 of the License, or (at your option)
\r
10 * any later version.
\r
12 * MARC4J is distributed in the hope that it will be useful, but WITHOUT ANY
\r
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
\r
14 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
\r
17 * You should have received a copy of the GNU Lesser General Public License
\r
18 * along with MARC4J; if not, write to the Free Software Foundation, Inc., 59
\r
19 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
24 import javax.xml.transform.sax.TransformerHandler;
\r
26 import org.xml.sax.InputSource;
\r
29 * Extends <code>Thread</code> to produce <code>Record</code> objects from
\r
32 * @author Bas Peters
\r
33 * @version $Revision: 1.3 $
\r
35 public class MarcXmlParserThread extends Thread {
\r
37 private RecordStack queue;
\r
39 private InputSource input;
\r
41 private TransformerHandler th = null;
\r
44 * Creates a new instance and registers the <code>RecordQueue</code>.
\r
49 public MarcXmlParserThread(RecordStack queue) {
\r
54 * Creates a new instance and registers the <code>RecordQueue</code> and
\r
55 * the <code>InputStream</code>.
\r
62 public MarcXmlParserThread(RecordStack queue, InputSource input) {
\r
68 * Returns the content handler to transform the source to MARCXML.
\r
70 * @return TransformerHandler - the transformation content handler
\r
72 public TransformerHandler getTransformerHandler() {
\r
77 * Sets the content handler to transform the source to MARCXML.
\r
80 * the transformation content handler
\r
82 public void setTransformerHandler(TransformerHandler th) {
\r
87 * Returns the input stream.
\r
89 * @return InputSource - the input source
\r
91 public InputSource getInputSource() {
\r
96 * Sets the input stream.
\r
101 public void setInputSource(InputSource input) {
\r
102 this.input = input;
\r
106 * Creates a new <code>MarcXmlHandler</code> instance, registers the
\r
107 * <code>RecordQueue</code> and sends the <code>InputStream</code> to
\r
108 * the <code>MarcXmlParser</code> parser.
\r
110 public void run() {
\r
112 MarcXmlHandler handler = new MarcXmlHandler(queue);
\r
113 MarcXmlParser parser = new MarcXmlParser(handler);
\r
115 parser.parse(input);
\r
117 parser.parse(input, th);
\r
119 catch (MarcException me)
\r
121 queue.passException(me);
\r