1 31 package org.objectweb.proactive.core.xml.io; 32 33 34 42 public class DefaultHandlerAdapter extends org.xml.sax.helpers.DefaultHandler { 43 44 protected XMLHandler targetHandler; 45 46 47 51 public DefaultHandlerAdapter(XMLHandler targetHandler) { 52 this.targetHandler = targetHandler; 53 } 54 55 56 60 64 68 83 84 87 public void startElement(String namespaceURI, String localName,String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException { 88 targetHandler.startElement(qName, new AttributesImpl(atts)); 90 } 91 92 93 96 public void endElement(String namespaceURI, String localName,String qName) throws org.xml.sax.SAXException { 97 targetHandler.endElement(qName); 99 } 100 101 102 113 114 117 public void characters(char ch[], int start, int length) throws org.xml.sax.SAXException { 118 if (length > 0) { 119 char[] c = new char[length]; 120 System.arraycopy(ch,start,c,0,length); 121 targetHandler.readValue(parseCharacterEntities(new String (c))); 122 } 123 } 124 125 126 133 137 155 156 157 161 protected class AttributesImpl implements Attributes { 162 private org.xml.sax.Attributes attributes; 163 AttributesImpl(org.xml.sax.Attributes attributes) { 164 this.attributes = attributes; 165 } 166 public String getValue(int index) { return attributes.getValue(index); } 167 public String getValue(String qName) { return attributes.getValue(qName); } 168 public String getValue(String uri, String localPart) { return attributes.getValue(uri,localPart); } 169 public int getLength() { return attributes.getLength(); } 170 } 171 172 protected class EmptyAttributesImpl implements Attributes { 173 EmptyAttributesImpl() {} 174 public String getValue(int index) { return null; } 175 public String getValue(String qName) { return null; } 176 public String getValue(String uri, String localPart) { return null; } 177 public int getLength() { return 0; } 178 } 179 180 181 182 186 private String parseCharacterEntities(String in) { 187 return in; 188 } 189 190 } | Popular Tags |