1 |
562
|
berkley
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Purpose: a class to handle document info request xml strings
|
4 |
|
|
* Copyright: 2000 Regents of the University of California and the
|
5 |
|
|
* National Center for Ecological Analysis and Synthesis
|
6 |
|
|
* Authors: Chad Berkley
|
7 |
|
|
*
|
8 |
|
|
* '$Author$'
|
9 |
|
|
* '$Date$'
|
10 |
|
|
* '$Revision$'
|
11 |
669
|
jones
|
*
|
12 |
|
|
* This program is free software; you can redistribute it and/or modify
|
13 |
|
|
* it under the terms of the GNU General Public License as published by
|
14 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
15 |
|
|
* (at your option) any later version.
|
16 |
|
|
*
|
17 |
|
|
* This program is distributed in the hope that it will be useful,
|
18 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
|
|
* GNU General Public License for more details.
|
21 |
|
|
*
|
22 |
|
|
* You should have received a copy of the GNU General Public License
|
23 |
|
|
* along with this program; if not, write to the Free Software
|
24 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
25 |
562
|
berkley
|
*/
|
26 |
|
|
|
27 |
|
|
package edu.ucsb.nceas.metacat;
|
28 |
|
|
|
29 |
|
|
import java.sql.*;
|
30 |
|
|
import java.util.Stack;
|
31 |
|
|
import java.util.Vector;
|
32 |
|
|
import java.util.Enumeration;
|
33 |
|
|
import java.util.EmptyStackException;
|
34 |
|
|
import java.util.Hashtable;
|
35 |
|
|
|
36 |
|
|
import org.xml.sax.Attributes;
|
37 |
|
|
import org.xml.sax.SAXException;
|
38 |
|
|
import org.xml.sax.SAXParseException;
|
39 |
|
|
import org.xml.sax.ext.DeclHandler;
|
40 |
|
|
import org.xml.sax.ext.LexicalHandler;
|
41 |
|
|
import org.xml.sax.helpers.DefaultHandler;
|
42 |
|
|
|
43 |
|
|
/**
|
44 |
|
|
* A Class implementing callback bethods for the SAX parser to
|
45 |
|
|
* call when processing the XML messages from the replication handler
|
46 |
|
|
*/
|
47 |
|
|
public class DocInfoHandler extends DefaultHandler
|
48 |
|
|
{
|
49 |
|
|
private Hashtable docinfo = new Hashtable();
|
50 |
|
|
private String currentTag = null;
|
51 |
|
|
|
52 |
|
|
public DocInfoHandler()
|
53 |
|
|
{
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
/**
|
57 |
|
|
* capture the name of the tag.
|
58 |
|
|
*/
|
59 |
|
|
public void startElement(String uri, String localName, String qName,
|
60 |
|
|
Attributes attributes) throws SAXException
|
61 |
|
|
{
|
62 |
|
|
currentTag = localName;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
/**
|
66 |
|
|
* put the content and the name of the tag into the hashtable. the name of
|
67 |
|
|
* the tag is the key.
|
68 |
|
|
*/
|
69 |
|
|
public void characters(char[] ch, int start, int length) throws SAXException
|
70 |
|
|
{
|
71 |
|
|
docinfo.put(currentTag, new String(ch, start, length));
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
public Hashtable getDocInfo()
|
75 |
|
|
{
|
76 |
|
|
return docinfo;
|
77 |
|
|
}
|
78 |
|
|
}
|