Search in sources :

Example 6 with CompactWriter

use of com.thoughtworks.xstream.io.xml.CompactWriter in project ddf by codice.

the class XStreamAttributeCopier method copyXml.

/**
 * Copies the entire XML element {@code reader} is currently at into {@code writer} and returns a
 * new reader ready to read the copied element. After the call, {@code reader} will be at the end
 * of the element that was copied.
 *
 * <p>If {@code attributeMap} is provided, the attributes will be added to the copy.
 *
 * @param reader the reader currently at the XML element you want to copy
 * @param writer the writer that the element will be copied into
 * @param attributeMap the map of attribute names to values that will be added as attributes of
 *     the copy, may be null
 * @return a new reader ready to read the copied element
 * @throws ConversionException if a parser to use for the new reader can't be created
 */
public static HierarchicalStreamReader copyXml(HierarchicalStreamReader reader, StringWriter writer, Map<String, String> attributeMap) {
    copyElementWithAttributes(reader, new CompactWriter(writer, new NoNameCoder()), attributeMap);
    XmlPullParser parser;
    try {
        parser = XmlPullParserFactory.newInstance().newPullParser();
    } catch (XmlPullParserException e) {
        throw new ConversionException("Unable to create XmlPullParser, cannot parse XML.", e);
    }
    return new XppReader(new InputStreamReader(IOUtils.toInputStream(writer.toString(), StandardCharsets.UTF_8)), parser);
}
Also used : ConversionException(com.thoughtworks.xstream.converters.ConversionException) CompactWriter(com.thoughtworks.xstream.io.xml.CompactWriter) InputStreamReader(java.io.InputStreamReader) XppReader(com.thoughtworks.xstream.io.xml.XppReader) XmlPullParser(org.xmlpull.v1.XmlPullParser) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) NoNameCoder(com.thoughtworks.xstream.io.naming.NoNameCoder)

Example 7 with CompactWriter

use of com.thoughtworks.xstream.io.xml.CompactWriter in project OpenOLAT by OpenOLAT.

the class ViteroManager method serializeViteroBooking.

private final String serializeViteroBooking(ViteroBooking booking) {
    StringWriter writer = new StringWriter();
    xStream.marshal(booking, new CompactWriter(writer));
    writer.flush();
    return writer.toString();
}
Also used : CompactWriter(com.thoughtworks.xstream.io.xml.CompactWriter) StringWriter(java.io.StringWriter)

Example 8 with CompactWriter

use of com.thoughtworks.xstream.io.xml.CompactWriter in project OpenOLAT by OpenOLAT.

the class OpenMeetingsDAO method serializeRoom.

public String serializeRoom(OpenMeetingsRoom room) {
    StringWriter writer = new StringWriter();
    xStream.marshal(room, new CompactWriter(writer));
    writer.flush();
    return writer.toString();
}
Also used : CompactWriter(com.thoughtworks.xstream.io.xml.CompactWriter) StringWriter(java.io.StringWriter)

Example 9 with CompactWriter

use of com.thoughtworks.xstream.io.xml.CompactWriter in project jgnash by ccavanaugh.

the class MessageBusClient method sendRemoteMessage.

synchronized void sendRemoteMessage(final Message message) {
    CharArrayWriter writer = new CharArrayWriter();
    xstream.marshal(message, new CompactWriter(writer));
    sendRemoteMessage(writer.toString());
    logger.log(Level.FINE, "sent: {0}", writer);
}
Also used : CompactWriter(com.thoughtworks.xstream.io.xml.CompactWriter) CharArrayWriter(java.io.CharArrayWriter)

Aggregations

CompactWriter (com.thoughtworks.xstream.io.xml.CompactWriter)9 StringWriter (java.io.StringWriter)4 NoNameCoder (com.thoughtworks.xstream.io.naming.NoNameCoder)3 XStream (com.thoughtworks.xstream.XStream)2 HierarchicalStreamWriter (com.thoughtworks.xstream.io.HierarchicalStreamWriter)2 XppDriver (com.thoughtworks.xstream.io.xml.XppDriver)2 Writer (java.io.Writer)2 DateTimeConverter (org.apache.camel.component.salesforce.api.utils.DateTimeConverter)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 ConversionException (com.thoughtworks.xstream.converters.ConversionException)1 FieldDictionary (com.thoughtworks.xstream.converters.reflection.FieldDictionary)1 PureJavaReflectionProvider (com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider)1 TreeMarshallingStrategy (com.thoughtworks.xstream.core.TreeMarshallingStrategy)1 StaxDriver (com.thoughtworks.xstream.io.xml.StaxDriver)1 WstxDriver (com.thoughtworks.xstream.io.xml.WstxDriver)1 XppReader (com.thoughtworks.xstream.io.xml.XppReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 CharArrayWriter (java.io.CharArrayWriter)1 InputStreamReader (java.io.InputStreamReader)1 AnnotationFieldKeySorter (org.apache.camel.component.salesforce.api.dto.AnnotationFieldKeySorter)1