@Override public void leaveElement(UnmarshallingContext.State state, TagName ea) throws SAXException { State s = (State) state.getTarget(); UnmarshallingContext context = state.getContext(); try { s.handler.endElement(ea.uri, ea.local, ea.getQname()); s.undeclarePrefixes(context.getNewlyDeclaredPrefixes()); } catch( SAXException e ) { context.handleError(e); throw e; } if((--s.depth)==0) { // emulate the end of the document try { s.undeclarePrefixes(context.getAllDeclaredPrefixes()); s.handler.endDocument(); } catch( SAXException e ) { context.handleError(e); throw e; } // we are done state.setTarget(s.getElement()); } }
private static void serializeEntry(TransformerHandler hd, Entry entry) throws SAXException { AttributesImpl entryAttributes = new AttributesImpl(); for (Iterator<String> it = entry.getAttributes().iterator(); it.hasNext();) { String key = it.next(); entryAttributes.addAttribute("", "", key, "", entry.getAttributes().getValue(key)); } hd.startElement("", "", ENTRY_ELEMENT, entryAttributes); StringList tokens = entry.getTokens(); for (String token : tokens) { hd.startElement("", "", TOKEN_ELEMENT, new AttributesImpl()); hd.characters(token.toCharArray(), 0, token.length()); hd.endElement("", "", TOKEN_ELEMENT); } hd.endElement("", "", ENTRY_ELEMENT); } }
hd.endElement("", "", DICTIONARY_ELEMENT);
public void end() throws SAXException { xmlHandler.endElement("", "", name); } }
/** * Receive notification of the end of an element. */ public void endElement(String uri, String loc, String raw) throws SAXException { super.contentHandler.endElement(uri, loc, raw); this.serializer.endElement(uri, loc, raw); }
@Override public void leaveElement(UnmarshallingContext.State state, TagName ea) throws SAXException { State s = (State) state.getTarget(); UnmarshallingContext context = state.getContext(); try { s.handler.endElement(ea.uri, ea.local, ea.getQname()); s.undeclarePrefixes(context.getNewlyDeclaredPrefixes()); } catch( SAXException e ) { context.handleError(e); throw e; } if((--s.depth)==0) { // emulate the end of the document try { s.undeclarePrefixes(context.getAllDeclaredPrefixes()); s.handler.endDocument(); } catch( SAXException e ) { context.handleError(e); throw e; } // we are done state.setTarget(s.getElement()); } }
/** Appends an end tag for the given object. * @throws SAXException in case of any errors. */ protected void writeEndElement(Object lmfObject) throws SAXException { String elementName = lmfObject.getClass().getSimpleName(); th.endElement("", "", elementName); }
@Override public void end() { if (m_handler != null) { try { m_handler.endElement("", "", "systemReportPlugins"); m_handler.endDocument(); } catch (final Exception e) { LOG.warn("Unable to end document.", e); } } } }
@Override protected void endObject(String name) { try { hd.endElement("", "", name); } catch (SAXException e) { throw Exceptions.handle(e); } }
@Override public void end() { if (m_handler != null) { try { m_handler.endElement("", "", "systemReportPlugins"); m_handler.endDocument(); } catch (final Exception e) { LOG.warn("Unable to end document.", e); } } } }
/** * {@link ContentHandler} implementation. */ public void endElement(String namespaceURI, String localName, String qName) throws SAXException { initContentHandler(); contentHandler.endElement(namespaceURI, localName, qName); }
public void executedAtExit(Store store, int solutionsNo) { try { hdTree.endElement("", "", "tree"); hdTree.endDocument(); hdVis.endElement("", "", "visualization"); hdVis.endDocument(); } catch (SAXException e) { e.printStackTrace(); } }
void generateSuccessNode(int searchNodeId) { try { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", "id", "CDATA", "" + searchNodeId); hdTree.startElement("", "", "succ", atts); hdTree.endElement("", "", "succ"); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Override protected void endArray(String name) { try { hd.endElement("", "", name); } catch (SAXException e) { throw Exceptions.handle(e); } }
/** * Makes an childless element appear as {@code<foo />} instead of * {@code<foo></foo>} * @param element the element * @throws SAXException */ private void childless(Element element) throws SAXException { Attributes attributes = getElementAttributes(element); handler.startElement(element.getNamespaceURI(), "", element.getLocalName(), attributes); handler.endElement(element.getNamespaceURI(), "", element.getLocalName()); }
/** * Makes an childless element appear as {@code<foo />} instead of * {@code<foo></foo>} * @param element the element * @throws SAXException */ private void childless(Element element) throws SAXException { Attributes attributes = getElementAttributes(element); handler.startElement(element.getNamespaceURI(), "", element.getLocalName(), attributes); handler.endElement(element.getNamespaceURI(), "", element.getLocalName()); }
protected void writeSimpleTag(final String tagName, final String value, final AttributesImpl attributes) throws SAXException { handler.startElement("", "", tagName, attributes); if (value != null) handler.characters(value.toCharArray(), 0, value .length()); handler.endElement("", "", tagName); }
private void writeElement(TransformerHandler th, String ns, String name, Attributes attrs, String textContent) throws SAXException { th.startElement(ns, name, name, attrs); if (textContent != null) { th.characters(textContent.toCharArray(), 0, textContent.length()); } th.endElement(ns, name, name); }
private void writeCacheLocationIfPresent(RepositoryCacheManager cache, TransformerHandler saxHandler, ArtifactDownloadReport artifact) throws SAXException { File archiveInCache = artifact.getLocalFile(); if (archiveInCache != null) { saxHandler.startElement(null, "cache-location", "cache-location", new AttributesImpl()); char[] archiveInCacheAsChars = archiveInCache.getPath().replace('\\', '/') .toCharArray(); saxHandler.characters(archiveInCacheAsChars, 0, archiveInCacheAsChars.length); saxHandler.endElement(null, "cache-location", "cache-location"); } }
private void writeRetrieveLocation(TransformerHandler saxHandler, String artifactDestPath) throws SAXException { artifactDestPath = removeLeadingPath(getProject().getBaseDir(), new File(artifactDestPath)); saxHandler.startElement(null, "retrieve-location", "retrieve-location", new AttributesImpl()); char[] artifactDestPathAsChars = artifactDestPath.replace('\\', '/').toCharArray(); saxHandler.characters(artifactDestPathAsChars, 0, artifactDestPathAsChars.length); saxHandler.endElement(null, "retrieve-location", "retrieve-location"); }