QNameMap qmap = new QNameMap(); qmap.setDefaultNamespace("http://libvirt.org/schemas/domain/qemu/1.0"); qmap.setDefaultPrefix("qemu"); StaxDriver staxDriver = new StaxDriver(qmap); XStream xstream = new XStream(staxDriver); xstream.autodetectAnnotations(true); xstream.alias("domain", Domain.class); Domain d = new Domain("kvm","linux"); String xml = xstream.toXML(d);
private XStream xstream() { XStream xstream = new XStream(); // allow annotations on models for maximum flexibility xstream.autodetectAnnotations(true); // prevent xstream from creating complex XML graphs xstream.setMode(XStream.NO_REFERENCES); // setup security (see http://x-stream.github.io/security.html) xstream.allowTypes(WhitelistObjectInputStream.getWhiteClassNames()); xstream.allowTypesByRegExp(WhitelistObjectInputStream.getWhiteRegEx()); return xstream; }
private static XStream getXStream() { if (xstream == null) { xstream = new XStream(); xstream.autodetectAnnotations(true); xstream.alias("pushResponse", NoticeResponse.class); } return xstream; }
private static XStream getXStream() { if (xstream == null) { xstream = new XStream(); xstream.autodetectAnnotations(true); xstream.alias("orderResponse", TaskResponse.class); } return xstream; }
private static XStream getXStream() { if (xstream == null) { xstream = new XStream(); xstream.autodetectAnnotations(true); xstream.alias("pushRequest", NoticeRequest.class); xstream.alias("item", ResultItem.class); } return xstream; }
private void applyDefaultConfig(XStream xstream) { xstream.autodetectAnnotations(true); xstream.setClassLoader(Thread.currentThread().getContextClassLoader()); }
final List<String> headers = Arrays.asList("Quantity", "Price"); final List<String> row1 = Arrays.asList("1", "2"); final List<String> row2 = Arrays.asList("3", "4"); final XStream xStream = new XStream(); xStream.autodetectAnnotations(true); final String xml = xStream.toXML(new Container(new Headers(headers), Arrays.asList( row1, row2)));
public static String entityToXML(Object entity) { XStream xstream = new XStream(new StaxDriver()); xstream.autodetectAnnotations(true); xstream.registerConverter(new GenericResponseAttributeConverter()); String xml = xstream.toXML(entity); xml = xml.replace("<attribute>", ""); xml = xml.replace("</attribute>", ""); return xml; }
private static XStream getXStream() { if (xstream == null) { xstream = new XStream(); xstream.registerConverter(new MapCustomConverter(new DefaultMapper(XStream.class.getClassLoader()))); xstream.autodetectAnnotations(true); xstream.alias("orderRequest", TaskRequest.class); xstream.alias("property", Entry.class); } return xstream; }
/** * Fail string. * * @param msg the msg * @return the string */ public static String fail(String msg) { WxPayNotifyResponse response = new WxPayNotifyResponse(FAIL, msg); XStream xstream = XStreamInitializer.getInstance(); xstream.autodetectAnnotations(true); return xstream.toXML(response); }
/** * Success string. * * @param msg the msg * @return the string */ public static String success(String msg) { WxPayNotifyResponse response = new WxPayNotifyResponse(SUCCESS, msg); XStream xstream = XStreamInitializer.getInstance(); xstream.autodetectAnnotations(true); return xstream.toXML(response); }
/** * Fail string. * * @param msg the msg * @return the string */ public static String fail(String msg) { WxPayNotifyResponse response = new WxPayNotifyResponse(FAIL, msg); XStream xstream = XStreamInitializer.getInstance(); xstream.autodetectAnnotations(true); return xstream.toXML(response); }
/** * Success string. * * @param msg the msg * @return the string */ public static String success(String msg) { WxPayNotifyResponse response = new WxPayNotifyResponse(SUCCESS, msg); XStream xstream = XStreamInitializer.getInstance(); xstream.autodetectAnnotations(true); return xstream.toXML(response); }
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 void main(String[] args) { Players xstramAliasObject = new Players(); XStream xstream = new XStream(new JsonHierarchicalStreamDriver()); xstream.setMode(XStream.NO_REFERENCES); xstream.aliasSystemAttribute(null, "class"); xstream.autodetectAnnotations(true); System.out.println("--- "+xstream.toXML(xstramAliasObject)); }
/** * Just creates a fresh XStream instance. * * @return */ public XStream createForXml() { final XStream xstream = new XStream( new LookAheadXppDriver() ); xstream.setMode( XStream.NO_REFERENCES ); xstream.autodetectAnnotations( false ); return xstream; }
private static XStream newXStream(ClassLoader classLoader) { XStream xstream = new XStream(); if (classLoader != null) { xstream.setClassLoader(classLoader); } xstream.autodetectAnnotations(true); xstream.setMode(XStream.NO_REFERENCES); xstream.processAnnotations(XStreamConfiguration.class); return xstream; } }
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);
/** * 将执行计划序列化成字符串 */ public static String createStringPlan(PhysicalPlan plan) { XStream xstream = new XStream(new DomDriver(XML_CHARSET)); xstream.autodetectAnnotations(true); PhysicalPlanLoader.setAlias(xstream); xstream.registerConverter(new MapConverter(new DefaultMapper(new ClassLoaderReference(PhysicalPlanWriter.class.getClassLoader())))); return xstream.toXML(plan); }