Project

General

Profile

« Previous | Next » 

Revision 562

Added by berkley about 24 years ago

this class allows the parsing of xml data sent by a replication server to assertain document info about a remote document.

View differences:

src/edu/ucsb/nceas/metacat/DocInfoHandler.java
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$'
10
 *     '$Date$'
11
 * '$Revision$'
12
 */
13

  
14
package edu.ucsb.nceas.metacat;
15

  
16
import java.sql.*;
17
import java.util.Stack;
18
import java.util.Vector;
19
import java.util.Enumeration;
20
import java.util.EmptyStackException;
21
import java.util.Hashtable;
22

  
23
import org.xml.sax.Attributes;
24
import org.xml.sax.SAXException;
25
import org.xml.sax.SAXParseException;
26
import org.xml.sax.ext.DeclHandler;
27
import org.xml.sax.ext.LexicalHandler;
28
import org.xml.sax.helpers.DefaultHandler;
29

  
30
/** 
31
 * A Class implementing callback bethods for the SAX parser to
32
 * call when processing the XML messages from the replication handler
33
 */
34
public class DocInfoHandler extends DefaultHandler 
35
{
36
  private Hashtable docinfo = new Hashtable();
37
  private String currentTag = null;
38
  
39
  public DocInfoHandler()
40
  {
41
  }
42
  
43
  /**
44
   *  capture the name of the tag.
45
   */
46
  public void startElement(String uri, String localName, String qName, 
47
                           Attributes attributes) throws SAXException
48
  {
49
    currentTag = localName;
50
  }
51
  
52
  /**
53
   * put the content and the name of the tag into the hashtable.  the name of
54
   * the tag is the key.
55
   */
56
  public void characters(char[] ch, int start, int length) throws SAXException
57
  {
58
    docinfo.put(currentTag, new String(ch, start, length));
59
  }
60
  
61
  public Hashtable getDocInfo()
62
  {
63
    return docinfo;
64
  }
65
}
0 66

  

Also available in: Unified diff