Refine search
public HierarchicalStreamWriter createWriter(OutputStream out) { return new PrettyPrintWriter(new OutputStreamWriter(out)); }
public void startNode(String name, Class clazz) { startNode(name); }
public void startNode(String name) { String escapedName = encodeNode(name); tagIsEmpty = false; finishTag(); writer.write('<'); writer.write(escapedName); elementStack.push(escapedName); tagInProgress = true; depth++ ; readyForNewLine = true; tagIsEmpty = true; }
private String generateResponse(final XStream xStream) { StringWriter writer = new StringWriter(); xStream.marshal(this, new PrettyPrintWriter(writer) { @Override public void addAttribute(final String key, final String value) { if (!key.equals("class")) { super.addAttribute(key, value); } } }); return writer.toString(); }
protected String marshallAdvisory(final DataStructure ds, String transformation) { StringWriter buffer = new StringWriter(); HierarchicalStreamWriter out; if (transformation.toLowerCase(Locale.ENGLISH).endsWith("json")) { out = new JettisonMappedXmlDriver().createWriter(buffer); } else { out = new PrettyPrintWriter(buffer); } XStream xstream = getXStream(); xstream.setMode(XStream.NO_REFERENCES); xstream.aliasPackage("", "org.apache.activemq.command"); xstream.marshal(ds, out); return buffer.toString(); }
@Override public void attributeChanged() { XStream xStream = Circuit.getxStream(); try (Writer out = new OutputStreamWriter(new FileOutputStream(filename), StandardCharsets.UTF_8)) { out.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); xStream.marshal(attributes, new PrettyPrintWriter(out)); } catch (Exception e) { e.printStackTrace(); } }
@Override public <T> String to(T obj) { Writer writer = new StringWriter(); PrettyPrintWriter prettyPrinter = new PrettyPrintWriter(writer); xstream.marshal(obj, prettyPrinter); String xml = writer.toString(); if (LOGGER.isDebugEnabled()) LOGGER.debug("XML Output: " + xml); return xml; }
public static void serializeToXml(List<StandaloneArgument> argumentList, File file) throws IOException { OutputStream os = new FileOutputStream(file); if (file.getName().endsWith(".gz")) { os = new GZIPOutputStream(new FileOutputStream(file)); } PrintWriter pw = new PrintWriter(os); pw.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); getXStream().marshal(argumentList, new PrettyPrintWriter(pw)); IOUtils.closeQuietly(os); }
/** * {@inheritDoc} */ public HierarchicalStreamWriter createWriter(Writer out) { return new PrettyPrintWriter(out, getNameCoder()); }
public static void exportAccountTree(final Engine engine, final Path file) { RootAccount account = engine.getRootAccount(); XStream xstream = getStream(); try (final Writer writer = Files.newBufferedWriter(file, ENCODING); final ObjectOutputStream out = xstream.createObjectOutputStream(new PrettyPrintWriter(writer))) { out.writeObject(account); } catch (IOException e) { Logger.getLogger(AccountTreeXMLFactory.class.getName()).log(Level.SEVERE, e.getLocalizedMessage(), e); } }
private void writeTag(String tag, String value, String attributeName, String attributeValue) { out.startNode(tag); out.addAttribute(attributeName, attributeValue); out.setValue(value); out.endNode(); }
protected void writeAttributeValue(QuickWriter writer, String text) { writeText(text, true); }
private void finishTag() { if (tagInProgress) { writer.write('>'); } tagInProgress = false; if (readyForNewLine) { endOfLine(); } readyForNewLine = false; tagIsEmpty = false; }
protected void endOfLine() { writer.write(getNewLine()); for (int i = 0; i < depth; i++ ) { writer.write(lineIndenter); } }
public void endNode() { depth-- ; if (tagIsEmpty) { writer.write('/'); readyForNewLine = false; finishTag(); elementStack.popSilently(); } else { finishTag(); writer.write(CLOSE); writer.write((String)elementStack.pop()); writer.write('>'); } readyForNewLine = true; if (depth == 0) { writer.flush(); } }
public void startNode(String name) { String escapedName = escapeXmlName(name); tagIsEmpty = false; finishTag(); writer.write('<'); writer.write(escapedName); elementStack.push(escapedName); tagInProgress = true; depth++ ; readyForNewLine = true; tagIsEmpty = true; }
public static String java2xml(Object obj, Class<?> T) { XStream xstream = new XStream(new StaxDriver()); xstream.processAnnotations(T); StringWriter stringWriter = new StringWriter(); xstream.marshal(obj, new PrettyPrintWriter(stringWriter)); return stringWriter.toString(); }