Project

General

Profile

1
/**
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
 *    Release: @release@
8
 *
9
 *   '$Author: jones $'
10
 *     '$Date: 2001-01-18 11:52:00 -0800 (Thu, 18 Jan 2001) $'
11
 * '$Revision: 669 $'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27

    
28
package edu.ucsb.nceas.metacat;
29

    
30
import java.sql.*;
31
import java.util.Stack;
32
import java.util.Vector;
33
import java.util.Enumeration;
34
import java.util.EmptyStackException;
35
import java.util.Hashtable;
36

    
37
import org.xml.sax.Attributes;
38
import org.xml.sax.SAXException;
39
import org.xml.sax.SAXParseException;
40
import org.xml.sax.ext.DeclHandler;
41
import org.xml.sax.ext.LexicalHandler;
42
import org.xml.sax.helpers.DefaultHandler;
43

    
44
/** 
45
 * A Class implementing callback bethods for the SAX parser to
46
 * call when processing the XML messages from the replication handler
47
 */
48
public class DocInfoHandler extends DefaultHandler 
49
{
50
  private Hashtable docinfo = new Hashtable();
51
  private String currentTag = null;
52
  
53
  public DocInfoHandler()
54
  {
55
  }
56
  
57
  /**
58
   *  capture the name of the tag.
59
   */
60
  public void startElement(String uri, String localName, String qName, 
61
                           Attributes attributes) throws SAXException
62
  {
63
    currentTag = localName;
64
  }
65
  
66
  /**
67
   * put the content and the name of the tag into the hashtable.  the name of
68
   * the tag is the key.
69
   */
70
  public void characters(char[] ch, int start, int length) throws SAXException
71
  {
72
    docinfo.put(currentTag, new String(ch, start, length));
73
  }
74
  
75
  public Hashtable getDocInfo()
76
  {
77
    return docinfo;
78
  }
79
}
(29-29/61)