1
|
/**
|
2
|
* '$RCSfile$'
|
3
|
* Purpose: A class that handles xml messages passed by the replication handler
|
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: berkley $'
|
10
|
* '$Date: 2000-12-12 10:55:33 -0800 (Tue, 12 Dec 2000) $'
|
11
|
* '$Revision: 595 $'
|
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
|
|
22
|
import org.xml.sax.Attributes;
|
23
|
import org.xml.sax.SAXException;
|
24
|
import org.xml.sax.SAXParseException;
|
25
|
import org.xml.sax.ext.DeclHandler;
|
26
|
import org.xml.sax.ext.LexicalHandler;
|
27
|
import org.xml.sax.helpers.DefaultHandler;
|
28
|
|
29
|
/**
|
30
|
* A Class implementing callback bethods for the SAX parser to
|
31
|
* call when processing the XML messages from the replication handler
|
32
|
*/
|
33
|
public class CatalogMessageHandler extends DefaultHandler
|
34
|
{
|
35
|
private Vector updates = new Vector();
|
36
|
private Vector indivUpdate = new Vector();
|
37
|
String currentTag = new String();
|
38
|
|
39
|
/**
|
40
|
* This method starts a new vector for each updatedDocument tag.
|
41
|
*/
|
42
|
public void startElement(String uri, String localName, String qName,
|
43
|
Attributes attributes) throws SAXException
|
44
|
{
|
45
|
currentTag = localName;
|
46
|
if(localName.equals("row"))
|
47
|
{
|
48
|
indivUpdate = new Vector();
|
49
|
}
|
50
|
}
|
51
|
|
52
|
/**
|
53
|
* This method write the indivUpdate to updates when it finds the end of
|
54
|
*/
|
55
|
public void endElement(String uri, String localName, String qName)
|
56
|
throws SAXException
|
57
|
{
|
58
|
if(localName.equals("row"))
|
59
|
{
|
60
|
updates.add(new Vector(indivUpdate));
|
61
|
}
|
62
|
}
|
63
|
|
64
|
/**
|
65
|
* Take the data out of the docid and date_updated fields
|
66
|
*/
|
67
|
public void characters(char[] ch, int start, int length) throws SAXException
|
68
|
{
|
69
|
if(currentTag.equals("entry_type") || currentTag.equals("source_doctype")
|
70
|
|| currentTag.equals("target_doctype") || currentTag.equals("public_id")
|
71
|
|| currentTag.equals("system_id"))
|
72
|
{
|
73
|
//System.out.println("parser adding: " + (new String(ch, start, length)).trim());
|
74
|
indivUpdate.add((new String(ch, start, length)).trim());
|
75
|
}
|
76
|
}
|
77
|
|
78
|
public Vector getCatalogVect()
|
79
|
{
|
80
|
return updates;
|
81
|
}
|
82
|
|
83
|
}
|