1 16 17 package org.apache.jetspeed.webservices.finance.stockmarket; 18 19 import org.xml.sax.helpers.XMLFilterImpl ; 20 import org.xml.sax.ContentHandler ; 21 import org.xml.sax.*; 22 23 30 31 public class StockQuoteArrayHandler extends XMLFilterImpl 32 { 33 StockQuote[] array = new BaseStockQuote[0]; 34 StockQuoteHandler currentVal = null; 35 boolean inElement; 36 37 public void startElement(String uri, String localName, String qName, Attributes attributes) 38 throws SAXException 39 { 40 if (attributes.getValue("href") != null) 41 throw new SAXNotSupportedException("href attributes not supported"); 42 inElement = true; 43 currentVal = new StockQuoteHandler(); 44 currentVal.setParent(this); 45 setContentHandler(currentVal); 46 } 47 48 public void endElement(String uri, String localName, String qName) 49 throws SAXException 50 { 51 if (inElement) 52 { 53 inElement = false; 54 StockQuote theVal = currentVal.getResult(); 55 StockQuote[] newar = new BaseStockQuote[array.length+1]; 56 System.arraycopy(array,0,newar,0,array.length); 57 newar[array.length] = theVal; 58 array = newar; 59 } else 60 { 61 ContentHandler handler = (ContentHandler )getParent(); 62 getParent().setContentHandler(handler); 63 handler.endElement(uri,localName,qName); 64 } 65 } 66 67 public void characters(char[] ch, int start, int length) throws SAXException 68 { 69 } 70 71 public StockQuote[] getResult() 72 { 73 return array; 74 } 75 76 public void setContentHandler(ContentHandler handler) 77 { 78 ((XMLReader)getParent()).setContentHandler(handler); 79 } 80 81 } 82 83 | Popular Tags |