本文整理了Java中com.thoughtworks.xstream.XStream.addImplicitArray()
方法的一些代码示例,展示了XStream.addImplicitArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.addImplicitArray()
方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:addImplicitArray
[英]Adds an implicit array.
[中]添加隐式数组。
代码示例来源:origin: stackoverflow.com
XStream xStream = new XStream();
xStream.alias("Strings", ArrayList.class);
xStream.alias("String", String.class);
xStream.addImplicitArray(ArrayList.class, "elementData");
List <String> result = (List <String>)xStream.fromXML(file);
代码示例来源:origin: stackoverflow.com
Class A {
private List<Apple> apples;
public static void setXstreamAlias(XStream xstream)
xstream.alias("apples", List.class, Apple.class);
xstream.addImplicitArray(A.class, "apples");
}
}
代码示例来源:origin: org.eclipse.smarthome.extensionservice/org.eclipse.smarthome.extensionservice.marketplace
@Override
public void registerAliases(XStream xstream) {
xstream.alias("marketplace", Marketplace.class);
xstream.addImplicitArray(Marketplace.class, "categories");
xstream.alias("category", Category.class);
xstream.addImplicitArray(Category.class, "nodes");
xstream.alias("node", Node.class);
xstream.aliasAttribute(Node.class, "id", "id");
xstream.aliasAttribute(Node.class, "name", "name");
// ignore what we do not know
xstream.ignoreUnknownElements();
}
代码示例来源:origin: org.tinygroup/fileresolver
private void processPropertyImplicit(XStream xStream,
XStreamClassAlias classAlias, Class<?> clazz)
throws InstantiationException, IllegalAccessException {
for (XStreamPropertyImplicit propertyImplicit : classAlias
.getPropertyImplicits()) {
String name = propertyImplicit.getAttributeName();
Object newInstance = clazz.newInstance();
if (newInstance instanceof Array) {
xStream.addImplicitArray(clazz, name);
} else if (newInstance instanceof Collection) {
xStream.addImplicitCollection(clazz, name);
}
}
}
代码示例来源:origin: stackoverflow.com
xs.registerConverter(new ItemConverter());
xs.alias("item", Item.class);
xs.addImplicitArray(Item.class, "e");
xs.alias("items", Items.class);
xs.addImplicitArray(Items.class, "e");
代码示例来源:origin: org.tinygroup/org.tinygroup.xstream
private static void processClassProperty(XStream xStream, XStreamClassPropertyAlias propertyAlias, Class<?> clazz) {
String propertyName = propertyAlias.getPropertyName();
Field field = ClassFiledUtil.getDeclaredFieldWithParent(clazz, propertyName);
String aliasName = propertyAlias.getAliasName();
boolean asTttribute = propertyAlias.isAsTttribute();
boolean implicit = propertyAlias.isImplicit();
boolean omit = propertyAlias.isOmit();
if (omit) {
xStream.omitField(clazz, propertyName);
}
if (implicit && field != null) {
if (field.getType().isArray()) {
xStream.addImplicitArray(clazz, propertyName);
} else if (ClassFiledUtil.implmentInterface(field.getType(),
Collection.class)) {
xStream.addImplicitCollection(clazz, propertyName);
}
}
if (!StringUtil.isBlank(aliasName)) {
if (!asTttribute) {
xStream.aliasField(aliasName, clazz, propertyName);
} else {
xStream.aliasAttribute(clazz, propertyName, aliasName);
}
}
}
//
内容来源于网络,如有侵权,请联系作者删除!