本文整理了Java中com.thoughtworks.xstream.XStream.autodetectAnnotations()
方法的一些代码示例,展示了XStream.autodetectAnnotations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.autodetectAnnotations()
方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:autodetectAnnotations
[英]Set the auto-detection mode of the AnnotationMapper. Note that auto-detection implies that the XStream is configured while it is processing the XML steams. This is a potential concurrency problem. Also is it technically not possible to detect all class aliases at deserialization. You have been warned!
[中]设置AnnotationMapper的自动检测模式。注意,自动检测意味着XStream是在处理XML流时配置的。这是一个潜在的并发问题。此外,从技术上讲,在反序列化时检测所有类别名也是不可能的。你被警告了!
代码示例来源:origin: spring-projects/spring-framework
xstream.autodetectAnnotations(true);
代码示例来源:origin: stackoverflow.com
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);
代码示例来源:origin: pippo-java/pippo
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;
}
代码示例来源:origin: yjjdick/sdb-mall
private static XStream getXStream() {
if (xstream == null) {
xstream = new XStream();
xstream.autodetectAnnotations(true);
xstream.alias("pushResponse", NoticeResponse.class);
}
return xstream;
}
代码示例来源:origin: yjjdick/sdb-mall
private static XStream getXStream() {
if (xstream == null) {
xstream = new XStream();
xstream.autodetectAnnotations(true);
xstream.alias("orderResponse", TaskResponse.class);
}
return xstream;
}
代码示例来源:origin: yjjdick/sdb-mall
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;
}
代码示例来源:origin: ch.abertschi.sct/service-call-tracker-impl
private void applyDefaultConfig(XStream xstream)
{
xstream.autodetectAnnotations(true);
xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
}
代码示例来源:origin: stackoverflow.com
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)));
代码示例来源:origin: stackoverflow.com
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;
}
代码示例来源:origin: yjjdick/sdb-mall
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;
}
代码示例来源:origin: com.github.binarywang/weixin-java-pay
/**
* 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);
}
代码示例来源:origin: com.github.binarywang/weixin-java-pay
/**
* 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);
}
代码示例来源:origin: binarywang/WxJava
/**
* 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);
}
代码示例来源:origin: binarywang/WxJava
/**
* 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);
}
代码示例来源:origin: stackoverflow.com
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();
}
代码示例来源:origin: stackoverflow.com
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));
}
代码示例来源:origin: org.sonatype.nexus.client/nexus-client-core
/**
* 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;
}
代码示例来源:origin: org.tinygroup/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;
}
}
代码示例来源:origin: stackoverflow.com
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);
代码示例来源:origin: HuaweiBigData/StreamCQL
/**
* 将执行计划序列化成字符串
*/
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);
}
内容来源于网络,如有侵权,请联系作者删除!