public static void serialize(final String name, final Object ast) { if (name == null || name.length() == 0) return; XStream xstream = new XStream(new StaxDriver()); FileWriter astFileWriter = null; try { File astFile = astFile(name); if (astFile == null) { System.out.println("File-name for writing " + name + " AST could not be determined!"); return; } astFileWriter = new FileWriter(astFile, false); xstream.toXML(ast, astFileWriter); System.out.println("Written AST to " + name + ".xml"); } catch (Exception e) { System.out.println("Couldn't write to " + name + ".xml"); e.printStackTrace(); } finally { DefaultGroovyMethods.closeQuietly(astFileWriter); } }
public XStreamStax() { super(new StaxDriver(), "XML with default StAX parser"); } }
public XStreamStax() { super(new StaxDriver(), "XML with default StAX parser"); } }
@SuppressWarnings("unchecked") public static void load(final InputStream in) { if (in == null) { throw new NullPointerException("given InputStream must not be null"); } final XStream xstream = new XStream(new StaxDriver()); logs.addAll((ArrayList<CaptureLog>) xstream.fromXML(in)); }
public static XStream getXStream() { if (xStream == null) { xStream = new XStream(new StaxDriver()); xStream.alias("argument", Argument.class); xStream.alias("debate", Debate.class); xStream.alias("standaloneArgument", StandaloneArgument.class); xStream.alias("xxx.sampling.datamodel.ReasonClaimWarrantContainer", ReasonClaimWarrantContainer.class); } return xStream; } }
public XstreamMetadataSchemeSerializer() { this.xstream = new XStream(new StaxDriver()); this.xstream.alias("metadataScheme", DcsMetadataScheme.class); this.xstream.registerConverter(new MetadataSchemeConverter()); }
public XstreamMetadataSchemeSerializer() { this.xstream = new XStream(new StaxDriver()); this.xstream.alias("metadataScheme", DcsMetadataScheme.class); this.xstream.registerConverter(new MetadataSchemeConverter()); }
private static XStream getxStream() { XStream xStream = new XStream(new StaxDriver()); xStream.alias("resources", Map.class); xStream.registerConverter(new MapEntryConverter()); return xStream; }
private static XStream getxStream() { XStream xStream = new XStream(new StaxDriver()); xStream.alias("languages", Map.class); xStream.registerConverter(new Resources.MapEntryConverter()); return xStream; }
private static XStream getxStream() { XStream xStream = new XStream(new StaxDriver()); xStream.alias("truthTable", TruthTable.class); xStream.alias("variable", Variable.class); xStream.aliasAttribute(Variable.class, "identifier", "name"); xStream.alias("result", Result.class); xStream.alias("BoolTable", BoolTableByteArray.class); xStream.alias("BoolTableEx", BoolTableExpanded.class); return xStream; }
XStream xstreamin = new XStream(new StaxDriver()); //you need to add this line xstreamin.alias("account", Account.class); //then the rest of your code... Reader someReader = new FileReader("Accounts.xml"); ObjectInputStream in = xstreamin.createObjectInputStream(someReader); accountsin = (ArrayList<Account>) in.readObject(); in.close();
private void persistBookmarks() throws KlabIOException { File f = new File(KLAB.CONFIG.getDataPath() + File.separator + "bookmarks.xml"); XStream xstream = new XStream(new StaxDriver()); String xml = xstream.toXML(_permanentBookmarks); try { FileUtils.writeStringToFile(f, xml); } catch (IOException e) { throw new KlabIOException(e); } }
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(); }
public static XStream createXStream() { XStream xstream = new XStream(new StaxDriver()); XStream.setupDefaultSecurity(xstream); //Setup the default hardening of types disallowed. xstream.setClassLoader(FindBugsFilter.class.getClassLoader()); for (Class modelClass : ALL_XSTREAM_TYPES) { xstream.processAnnotations(modelClass); xstream.allowTypeHierarchy(modelClass); //Build a whitelist of the class allowed } return xstream; }
public XmlMediaType(Enhancer enhancer) { QNameMap qnameMap = new QNameMap(); QName qname = new QName("http://www.w3.org/2005/Atom", "atom"); qnameMap.registerMapping(qname, DefaultRelation.class); // we need the replacer because // xstream replaces an _ with __ (two underscore) more information at // http://xstream.codehaus.org/faq.html#XML_double_underscores XmlFriendlyReplacer replacer = new XmlFriendlyReplacer("$", "_"); helper = new XStreamHelper(new StaxDriver(qnameMap, replacer), enhancer); }
StaxDriver drv = new StaxDriver(); XStream xstream = new XStream(drv); StringWriter strWriter = new StringWriter(); StaxWriter sw = new StaxWriter(drv.getQnameMap(), drv.getOutputFactory().createXMLStreamWriter(strWriter), false, // don't do startDocument true); // do repair namespaces xstream.marshal(ktpMessage, sw); sw.close(); String objectXml = strWriter.toString();
public static <T> String getXmlString(T data) { final StringWriter stringWriter = new StringWriter(); XStream xstream = new XStream(new StaxDriver()); xstream.autodetectAnnotations(true); xstream.marshal(data, new PrettyPrintWriter(stringWriter)); return stringWriter.toString(); }
public static <T> String getXmlString(T data, Class<?> dataClass) { String ret = ""; final StringWriter stringWriter = new StringWriter(); XStream xstream = new XStream(new StaxDriver()); xstream.processAnnotations(dataClass); xstream.marshal(data, new PrettyPrintWriter(stringWriter)); ret = stringWriter.toString(); return ret; }
final XStream xstream = new XStream(new StaxDriver()); xstream.alias("MyCustomNote", Note.class); xstream.aliasField("toAddress", Note.class,"to"); xstream.aliasField("fromName", Note.class,"from"); xstream.aliasField("heading", Note.class,"heading"); xstream.aliasField("output", Note.class,"body");
StaxDriver driver = new StaxDriver(new NoNameCoder()) { @Override public StaxWriter createStaxWriter(XMLStreamWriter out) throws XMLStreamException { // the boolean parameter controls the production of XML declaration return createStaxWriter(out, false); } }; XStream xStream = new XStream(driver); xStream.autodetectAnnotations(true);//needed to process aliases //register MyCustomReflectionConverter MyCustomReflectionConverter reflectionConverter = new MyCustomReflectionConverter (xStream.getMapper(), new SunUnsafeReflectionProvider()); xStream.registerConverter(reflectionConverter, XStream.PRIORITY_VERY_LOW);