1 19 20 package gui.updatecenterwizard.settings; 21 22 import java.io.File ; 23 import java.io.FileInputStream ; 24 import java.io.IOException ; 25 import java.lang.Integer ; 26 import java.lang.StringBuffer ; 27 import java.util.*; 28 import java.text.SimpleDateFormat ; 29 import java.text.ParseException ; 30 import java.util.Vector ; 31 import javax.xml.parsers.SAXParser ; 32 import javax.xml.parsers.SAXParserFactory ; 33 import javax.xml.transform.TransformerException ; 34 import org.xml.sax.Attributes ; 35 import org.xml.sax.SAXException ; 36 import org.xml.sax.XMLReader ; 37 import org.xml.sax.helpers.*; 38 39 43 44 public class CatalogXMLFileParser extends DefaultHandler{ 45 public static final String CATALOG = "catalog"; 46 public static final String NAME = "name"; 47 public static final String FILE = "file"; 48 public static final String PROXY_HOST = "proxy_host"; 49 public static final String PROXY_PORT = "proxy_port"; 50 public static final String MODULES = "modules"; 51 52 CatalogDataValues data; 53 StringBuffer buffer; 54 55 56 public CatalogXMLFileParser() throws SAXException { 57 data = null; 58 } 59 60 63 64 public void startDocument() throws SAXException { 65 } 66 67 68 71 public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) throws SAXException { 72 buffer = new StringBuffer (); 73 74 if (qName.equals(CATALOG)) { 75 data = new CatalogDataValues(); 76 } 77 } 78 79 82 public void characters(char buf[], int offset, int len) throws SAXException { 83 buffer.append(buf, offset, len); 84 } 85 86 89 public void endElement(String namespaceURI, String sName, String qName) throws SAXException { 90 91 if (qName.equals(CATALOG)) { 92 } 93 if (qName.equals(NAME)) { 94 if (buffer.length() > 0){ 95 data.setUcName(buffer.toString()); 96 } 97 } 98 if (qName.equals(FILE)) { 99 if (buffer.length() > 0){ 100 data.setUcFile(buffer.toString()); 101 } 102 } 103 if (qName.equals(PROXY_HOST)) { 104 if (buffer.length() > 0){ 105 data.setProxyHost(buffer.toString()); 106 } 107 } 108 if (qName.equals(PROXY_PORT)) { 109 if (buffer.length() > 0){ 110 data.setProxyPort(buffer.toString()); 111 } 112 } 113 if (qName.equals(MODULES)) { 114 if (buffer.length() > 0){ 115 data.setModules(buffer.toString()); 116 } 117 } 118 } 119 120 public CatalogDataValues getData(){ 121 return data; 122 } 123 124 } | Popular Tags |