/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String) */ @Override public void endElement(String uri, String localName, String qName) throws SAXException { super.endElement(uri, localName, qName); for (DefaultHandler delegate : delegates) { delegate.endElement(uri, localName, qName); } }
/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#endPrefixMapping(java.lang.String) */ @Override public void endPrefixMapping(String prefix) throws SAXException { super.endPrefixMapping(prefix); for (DefaultHandler delegate : delegates) { delegate.endPrefixMapping(prefix); } }
/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String, java.lang.String) */ @Override public void processingInstruction(String target, String data) throws SAXException { super.processingInstruction(target, data); for (DefaultHandler delegate : delegates) { delegate.processingInstruction(target, data); } }
/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#ignorableWhitespace(char[], int, int) */ @Override public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { super.ignorableWhitespace(ch, start, length); for (DefaultHandler delegate : delegates) { delegate.ignorableWhitespace(ch, start, length); } }
/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#startDocument() */ @Override public void startDocument() throws SAXException { super.startDocument(); for (DefaultHandler delegate : delegates) { delegate.startDocument(); } }
/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#skippedEntity(java.lang.String) */ @Override public void skippedEntity(String name) throws SAXException { super.skippedEntity(name); for (DefaultHandler delegate : delegates) { delegate.skippedEntity(name); } }
/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { super.startElement(uri, localName, qName, attributes); for (DefaultHandler delegate : delegates) { delegate.startElement(uri, localName, qName, attributes); } boolean policy = false; if (localName != null && localName.equals(POLICY)) { policy = true; } if (qName != null && qName.endsWith(COLON_POLICY)) { policy = true; } if (!policy) { return; } else { hasPolicy = true; } int count = attributes.getLength(); for (int i = 0; i < count; i++) { String value = attributes.getValue(i); String attrLocalName = attributes.getLocalName(i); String attrQName = attributes.getQName(i); if ((attrLocalName != null && attrLocalName.equals(ID)) || (attrLocalName != null && attrQName.endsWith(COLON_ID))) { policies.add(attributes.getValue(i)); } } }
/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#startPrefixMapping(java.lang.String, java.lang.String) */ @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { super.startPrefixMapping(prefix, uri); for (DefaultHandler delegate : delegates) { delegate.startPrefixMapping(prefix, uri); } }
private void scan(ByteArrayInputStream in, String path, SVNDirEntry dirEntry) { try { Metadata metadata = new Metadata(); metadata.set(Metadata.RESOURCE_NAME_KEY, path); // The following code part is from an proposal of the Authors of // Tika: // https://issues.apache.org/jira/browse/TIKA-232 TikaConfig config = TikaConfig.getDefaultConfig(); // without a // delegate // parser Parser parser = new AutoDetectParser(config); DefaultHandler handler = new BodyContentHandler(); parser.parse(in, handler, metadata); getDocument().addTokenizedField(FieldNames.CONTENTS, handler.toString()); } catch (Exception e) { LOGGER.error("We had an exception " + path + " (r" + dirEntry.getRevision() + ")", e); } finally { try { in.close(); } catch (Exception e) { LOGGER.error("We had an exception " + path + " (r" + dirEntry.getRevision() + ")", e); } } }
/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) */ @Override public void characters(char[] ch, int start, int length) throws SAXException { super.characters(ch, start, length); for (DefaultHandler delegate : delegates) { delegate.characters(ch, start, length); } }
/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String) */ @Override public void notationDecl(String name, String publicId, String systemId) throws SAXException { super.notationDecl(name, publicId, systemId); for (DefaultHandler delegate : delegates) { delegate.notationDecl(name, publicId, systemId); } }
/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @Override public void unparsedEntityDecl( String name, String publicId, String systemId, String notationName) throws SAXException { super.unparsedEntityDecl(name, publicId, systemId, notationName); for (DefaultHandler delegate : delegates) { delegate.unparsedEntityDecl(name, publicId, systemId, notationName); } }
/** * The end of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * @throws SAXException for errors. */ @Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException { DefaultHandler current = getCurrentHandler(); if (current != this) { current.endElement(namespaceURI, localName, qName); } }
protected InputStream sanitizeXmlDocument(DefaultHandler handler, InputStream inputStream) throws S3ServiceException { if (!properties.getBoolProperty("xmlparser.sanitize-listings", true)) { // No sanitizing will be performed, return the original input stream unchanged. return inputStream; } else { if (log.isDebugEnabled()) { log.debug("Sanitizing XML document destined for handler " + handler.getClass()); } InputStream sanitizedInputStream = null; try { /* Read object listing XML document from input stream provided into a * string buffer, so we can replace troublesome characters before * sending the document to the XML parser. */ StringBuffer listingDocBuffer = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, Constants.DEFAULT_ENCODING)); char[] buf = new char[8192]; int read = -1; while ((read = br.read(buf)) != -1) { listingDocBuffer.append(buf, 0, read); } br.close(); // Replace any carriage return (\r) characters with explicit XML // character entities, to prevent the SAX parser from // misinterpreting 0x0D characters as 0x0A. String listingDoc = listingDocBuffer.toString().replaceAll("\r", "
"); sanitizedInputStream = new ByteArrayInputStream(listingDoc.getBytes(Constants.DEFAULT_ENCODING)); } catch (Throwable t) { try { inputStream.close(); } catch (IOException e) { if (log.isErrorEnabled()) { log.error( "Unable to close response InputStream after failure sanitizing XML document", e); } } throw new S3ServiceException( "Failed to sanitize XML document destined for handler " + handler.getClass(), t); } return sanitizedInputStream; } }
/** * Starts an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * @param atts the element attributes. * @throws SAXException for errors. */ @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { DefaultHandler current = getCurrentHandler(); if (current != this) { current.startElement(namespaceURI, localName, qName, atts); } else if (qName.equals(PIEDATASET_TAG)) { this.dataset = new DefaultPieDataset(); } else if (qName.equals(ITEM_TAG)) { ItemHandler subhandler = new ItemHandler(this, this); getSubHandlers().push(subhandler); subhandler.startElement(namespaceURI, localName, qName, atts); } }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { super.endElement(uri, localName, qName); if (localName.equals("item")) { stories.add(story); story = null; largestImgWidth = 0; } if (story != null) { if (localName.equals("title")) { story.setTitle(xmlInnerText.toString().trim()); } else if (localName.equals("description")) { story.setDescription(xmlInnerText.toString().trim()); } else if (localName.equals("link")) { story.setLink(xmlInnerText.toString().trim()); } else if (localName.equals("pubDate")) { SimpleDateFormat dtSourceFormat = story.getSourceDateFormater(); SimpleDateFormat dtTargetFormat = story.getTargetDateFormater(); try { story.setPubDate(dtSourceFormat.parse(xmlInnerText.toString().trim())); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("Exam01", "Parsed date : " + dtTargetFormat.format(story.getPubDate())); } xmlInnerText.setLength(0); } }
/** * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, * java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement( final String uri, final String localName, final String qName, final Attributes atts) throws SAXException { // Found the XMI tag if (localName.equalsIgnoreCase(XMI_TAG_NAME)) { this.processAttributes(atts); this.foundXmiStartElement = true; } // Found the model annotation element else if (localName.equalsIgnoreCase(MODEL_ANNOTATION_TAG_NAME)) { this.processAttributes(atts); this.foundAnnotationStartElement = true; } // Found the virtual database element else if (localName.equalsIgnoreCase(VIRTUAL_DATABASE_TAG_NAME)) { this.processVdbAttributes(atts); this.foundAnnotationStartElement = true; this.foundVdbStartElement = true; } // Found the models element else if (localName.equalsIgnoreCase(MODELS_TAG_NAME) && this.foundVdbStartElement) this.processImportAttributes(atts); else if (localName.equalsIgnoreCase(MODEL_IMPORT_TAG_NAME)) this.processImportAttributes(atts); this.checkForCompletion(); super.startElement(uri, localName, qName, atts); }
/* * (non-Javadoc) * * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, * java.lang.String, java.lang.String, org.xml.sax.Attributes) 元素开始的通知 */ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // TODO Auto-generated method stub super.startElement(uri, localName, qName, attributes); preTag = localName; }
public void characters(char ch[], int start, int length) throws SAXException { /* * Would be called on the following structure: * <element>characters</element> */ String tmp = new String(ch, start, length); if (tagName.equals("status1")) { lccinfo.setDayWeather(tmp); } else if (tagName.equals("status2")) { lccinfo.setNightWeather(tmp); } else if (tagName.equals("temperature1")) { lccinfo.setDayTemp(tmp); } else if (tagName.equals("temperature2")) { lccinfo.setNightTemp(tmp); } else if (tagName.equals("direction1")) { lccinfo.setDayDirection(tmp); } else if (tagName.equals("direction2")) { lccinfo.setNightDirection(tmp); } else if (tagName.equals("chy_shuoming")) { lccinfo.setCY(tmp); } else if (tagName.equals("ssd_s")) { lccinfo.setFEEL(tmp); } else if (tagName.equals("ktk_s")) { lccinfo.setKT(tmp); } else if (tagName.equals("gm_s")) { lccinfo.setGM(tmp); } else if (this.tagName.equals("yd_s")) { lccinfo.setYD(tmp); } super.characters(ch, start, length); }
@Override public void characters(char ch[], int start, int length) throws SAXException { if (description != null) { description.append(String.valueOf(ch, start, length)); } super.characters(ch, start, length); }
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { super.startElement(uri, localName, qName, attributes); if (localName.equals("repo")) { String pk = attributes.getValue("", "pubkey"); if (pk != null) pubkey = pk; } else if (localName.equals("application") && curapp == null) { curapp = new DB.App(); curapp.detail_Populated = true; Bundle progressData = createProgressData(repo.address); progressCounter++; progressListener.onProgress( new ProgressListener.Event( RepoXMLHandler.PROGRESS_TYPE_PROCESS_XML, progressCounter, totalAppCount, progressData)); } else if (localName.equals("package") && curapp != null && curapk == null) { curapk = new DB.Apk(); curapk.id = curapp.id; curapk.repo = repo.id; hashType = null; } else if (localName.equals("hash") && curapk != null) { hashType = attributes.getValue("", "type"); } curchars.setLength(0); }
@Override public void characters(char[] ch, int start, int length) throws SAXException { super.characters(ch, start, length); if (this.noticiaActual != null) sbTexto.append(ch, start, length); }
@Override public void characters(char[] ch, int start, int length) throws SAXException { super.characters(ch, start, length); if (this.dictionary != null) sbItem.append(ch, start, length); }
@Override public void startDocument() throws SAXException { super.startDocument(); catTree = new CategoryTree("root"); partiesList = new ArrayList<>(); builder = new StringBuilder(); }
@Override public void characters(char[] ch, int start, int length) throws SAXException { // TODO Auto-generated method stub val += new String(ch, start, length); super.characters(ch, start, length); }
@Override public void characters(char[] ch, int start, int length) throws SAXException { super.characters(ch, start, length); if (recordCharacters) { builder.append(ch, start, length); } }
@Override public void characters(char[] ch, int start, int length) throws SAXException { super.characters(ch, start, length); if (cuurentElement) { currentValue.append(ch, start, length); } }
@Override public void endElement(final String uri, final String localName, final String name) throws SAXException { if (localName.equals("XLS")) { this.inXLS = false; } else if (localName.equals("ResponseHeader")) { this.inRepsonseHeader = false; } else if (localName.equals("Response")) { this.inRepsonse = false; } else if (localName.equals("DirectoryResponse")) { this.inDirectoryResponse = false; } else if (localName.equals("POIContext")) { this.inPOIContext = false; } else if (localName.equals("POI")) { this.inPOI = false; } else if (localName.equals("Point")) { this.inPoint = false; } else if (localName.equals("pos")) { this.inPos = false; this.mCurPOI.setGeoPoint(GeoPoint.fromInvertedDoubleString(this.sb.toString(), ' ')); } else if (localName.equals("Distance")) { this.inDistance = false; } else { Log.w(DEBUGTAG, "Unexpected end-tag: '" + name + "'"); } // Reset the stringbuffer this.sb.setLength(0); super.endElement(uri, localName, name); }
@Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if (this.start) { if (uri != null) { int numAtts = attributes.getLength(); for (int i = 0; i < numAtts; i++) { String attQName = attributes.getQName(i); if (attQName.equals("xmlns") || attQName.startsWith("xmlns:")) { String attValue = attributes.getValue(i); if (uri.equals(attValue)) { this.nsSpec = attValue; break; } } } } this.start = false; } super.startElement(uri, localName, name, attributes); }
@Override public void endDocument() throws SAXException { if (this.mErrors == null || this.mErrors.size() == 0) { // Maybe do some finalization or similar... } super.endDocument(); }