Refine search
/** * Generates XML for a <code>String</code> */ private void generate(String s) throws SAXException { handler.startElement("", STRING, STRING, EMPTY); handler.characters(s.toCharArray(), 0, s.length()); handler.endElement("", STRING, STRING); }
case XmlPullParser.TEXT: final char[] chars = pp.getTextCharacters(holderForStartAndLength); contentHandler.characters(chars, holderForStartAndLength[0], //start holderForStartAndLength[1] //len rawName.append(name); contentHandler.endElement(pp.getNamespace(), name, prefix != null ? name : rawName.toString() contentHandler.endElement(pp.getNamespace(), pp.getName(), pp.getName()
protected final ContentHandler mockContentHandler() throws Exception { ContentHandler contentHandler = mock(ContentHandler.class); willAnswer(new CopyCharsAnswer()).given(contentHandler).characters(any(char[].class), anyInt(), anyInt()); willAnswer(new CopyCharsAnswer()).given(contentHandler).ignorableWhitespace(any(char[].class), anyInt(), anyInt()); willAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { invocation.getArguments()[3] = new AttributesImpl((Attributes) invocation.getArguments()[3]); return null; } }).given(contentHandler).startElement(anyString(), anyString(), anyString(), any(Attributes.class)); return contentHandler; }
private void generateBackupFile(File file) throws SAXException { handler.startElement("", BACKUP, BACKUP, EMPTY); handler.characters(file.getPath().toCharArray(), 0, file.getPath().length()); handler.endElement("", BACKUP, BACKUP); }
private void startParagraph(String styleName) throws SAXException { if (pDepth == 0) { handler.startElement(XHTML, "p", "p", EMPTY_ATTRIBUTES); if (styleName != null) { currTextStyle = paragraphTextStyleMap.get(styleName); } hasWrittenStartStyleTags = false; } else { handler.characters(SPACE, 0, SPACE.length); } pDepth++; }
private void endParagraph() throws SAXException { closeStyleTags(); if (pDepth == 1) { handler.endElement(XHTML, "p", "p"); } else { handler.characters(SPACE, 0, SPACE.length); } pDepth--; }
/** * Generates XML for key constraints * * @param element The kind of element to generate (KEY_CONSTRAINT or VALUE_CONSTRAINT). */ private void generate(Class c, String element) throws SAXException { if (c != null) { handler.startElement("", element, element, EMPTY); String className = c.getName(); handler.characters(className.toCharArray(), 0, className.length()); handler.endElement("", element, element); } }
handler.startElement(XHTMLContentHandler.XHTML, el, el, EMPTY_ATTRIBUTES); } else if (TEXT_NS.equals(namespaceURI) && "list".equals(localName)) { startList(attrs.getValue(TEXT_NS, "style-name")); startParagraph(attrs.getValue(TEXT_NS, "style-name")); } else if (TEXT_NS.equals(namespaceURI) && "s".equals(localName)) { handler.characters(SPACE, 0, 1); } else if ("annotation".equals(localName)) { closeStyleTags(); handler.startElement(XHTML, "span", "p", ANNOTATION_ATTRIBUTES); } else if ("note".equals(localName)) { closeStyleTags(); handler.startElement(XHTML, "span", "p", NOTE_ATTRIBUTES); } else if ("notes".equals(localName)) { closeStyleTags();
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (localName.equals("Spatial_Coverage")) { this.delegate.characters(NEWLINE, 0, NEWLINE.length); this.delegate.characters(TABSPACE, 0, TABSPACE.length); this.delegate.endElement("", "table", "table"); } if (this.isLeaf) { Stack<String> tempStack = (Stack<String>) this.treeStack.clone(); String key = ""; while (!tempStack.isEmpty()) { if (key.length() == 0) { key = tempStack.pop(); } else { key = tempStack.pop() + "-" + key; } } String value = this.dataStack.peek(); this.metadata.add(key, value); this.isLeaf = false; } this.treeStack.pop(); this.dataStack.pop(); }
/** * Generates XML for the remote command */ private void generateRemoteCommand() throws SAXException { String remoteCommand = this.system.getRemoteCommand(); handler.startElement("", REMOTE_COMMAND, REMOTE_COMMAND, EMPTY); handler.characters(remoteCommand.toCharArray(), 0, remoteCommand.length()); handler.endElement("", REMOTE_COMMAND, REMOTE_COMMAND); }
serializer.startElement(uri, local, qName, atts); String data = XMLUtils.removeXMLInvalidChars(((Text) node).getData()); char[] ch = data.toCharArray(); serializer.characters(ch, 0, ch.length);
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (localName.equals("Spatial_Coverage")) { this.delegate.characters(NEWLINE, 0, NEWLINE.length); this.delegate.characters(TABSPACE, 0, TABSPACE.length); this.delegate.endElement("", "table", "table"); } if (this.isLeaf) { Stack<String> tempStack = (Stack<String>) this.treeStack.clone(); String key = ""; while (!tempStack.isEmpty()) { if (key.length() == 0) { key = tempStack.pop(); } else { key = tempStack.pop() + "-" + key; } } String value = this.dataStack.peek(); this.metadata.add(key, value); this.isLeaf = false; } this.treeStack.pop(); this.dataStack.pop(); }
private void generate(String kind, Declarable d, Properties p) throws SAXException { if (d == null) { return; } handler.startElement("", kind, kind, EMPTY); String className = d.getClass().getName(); handler.startElement("", CLASS_NAME, CLASS_NAME, EMPTY); handler.characters(className.toCharArray(), 0, className.length()); handler.endElement("", CLASS_NAME, CLASS_NAME); generate(p, null); handler.endElement("", kind, kind); }
private void startParagraph(String styleName) throws SAXException { if (pDepth == 0) { handler.startElement(XHTML, "p", "p", EMPTY_ATTRIBUTES); if (styleName != null) { currTextStyle = paragraphTextStyleMap.get(styleName); } hasWrittenStartStyleTags = false; } else { handler.characters(SPACE, 0, SPACE.length); } pDepth++; }
private void endParagraph() throws SAXException { closeStyleTags(); if (pDepth == 1) { handler.endElement(XHTML, "p", "p"); } else { handler.characters(SPACE, 0, SPACE.length); } pDepth--; }
private void generateGatewayEventFilter(GatewayEventFilter gef) throws SAXException { handler.startElement("", GATEWAY_EVENT_FILTER, GATEWAY_EVENT_FILTER, EMPTY); String className = gef.getClass().getName(); handler.startElement("", CLASS_NAME, CLASS_NAME, EMPTY); handler.characters(className.toCharArray(), 0, className.length()); handler.endElement("", CLASS_NAME, CLASS_NAME); Properties props = null; if (gef instanceof Declarable2) { props = ((Declarable2) gef).getConfig(); generate(props, null); } handler.endElement("", GATEWAY_EVENT_FILTER, GATEWAY_EVENT_FILTER); }
private void generateGatewayTransportFilter(GatewayTransportFilter gef) throws SAXException { handler.startElement("", GATEWAY_TRANSPORT_FILTER, GATEWAY_TRANSPORT_FILTER, EMPTY); String className = gef.getClass().getName(); handler.startElement("", CLASS_NAME, CLASS_NAME, EMPTY); handler.characters(className.toCharArray(), 0, className.length()); handler.endElement("", CLASS_NAME, CLASS_NAME); Properties props = null; if (gef instanceof Declarable2) { props = ((Declarable2) gef).getConfig(); generate(props, null); } handler.endElement("", GATEWAY_TRANSPORT_FILTER, GATEWAY_TRANSPORT_FILTER); }
/** * Generates XML for an arbitrary object. It special cases {@link String}s and * {@link Declarable}s. */ private void generate(Object o) throws SAXException { if (o instanceof String) { handler.startElement("", STRING, STRING, EMPTY); String s = (String) o; handler.characters(s.toCharArray(), 0, s.length()); handler.endElement("", STRING, STRING); } else if (o instanceof Declarable) { generate((Declarable) o); } else if (o == null) { handler.startElement("", STRING, STRING, EMPTY); String s = "null"; handler.characters(s.toCharArray(), 0, s.length()); handler.endElement("", STRING, STRING); } else { // Instead of blowing up, just put a String entry... handler.startElement("", STRING, STRING, EMPTY); String s = o.getClass().getName(); handler.characters(s.toCharArray(), 0, s.length()); handler.endElement("", STRING, STRING); } }
/** * Generates an XML representation of a <code>CacheServerConfig</code>. */ private void generateCacheServer(CacheServerConfig config) throws SAXException { handler.startElement("", CACHE_SERVER, CACHE_SERVER, EMPTY); generateEntityConfig(config); String classpath = config.getClassPath(); if (classpath != null) { handler.startElement("", CLASSPATH, CLASSPATH, EMPTY); handler.characters(classpath.toCharArray(), 0, classpath.length()); handler.endElement("", CLASSPATH, CLASSPATH); } handler.endElement("", CACHE_SERVER, CACHE_SERVER); }
private void generateGatewayEventSubstitutionFilter(GatewayEventSubstitutionFilter filter) throws SAXException { handler.startElement("", GATEWAY_EVENT_SUBSTITUTION_FILTER, GATEWAY_EVENT_SUBSTITUTION_FILTER, EMPTY); String className = filter.getClass().getName(); handler.startElement("", CLASS_NAME, CLASS_NAME, EMPTY); handler.characters(className.toCharArray(), 0, className.length()); handler.endElement("", CLASS_NAME, CLASS_NAME); Properties props = null; if (filter instanceof Declarable2) { props = ((Declarable2) filter).getConfig(); generate(props, null); } handler.endElement("", GATEWAY_EVENT_SUBSTITUTION_FILTER, GATEWAY_EVENT_SUBSTITUTION_FILTER); }