本文整理汇总了Java中com.thoughtworks.xstream.XStream.processAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java XStream.processAnnotations方法的具体用法?Java XStream.processAnnotations怎么用?Java XStream.processAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thoughtworks.xstream.XStream
的用法示例。
在下文中一共展示了XStream.processAnnotations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validUnits2FromXml
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
@DataProvider
public Iterator<Object[]> validUnits2FromXml() throws IOException {
String xml = "";
try (BufferedReader reader = new BufferedReader(new FileReader(new File("src/test/resources/units2.xml")))) {
String line = reader.readLine();
while (line != null) {
xml += line;
line = reader.readLine();
}
}
XStream xStream = new XStream();
xStream.processAnnotations(Unit2Data.class);
List<Unit2Data> units2 = (List<Unit2Data>)xStream.fromXML(xml);
return units2.stream().map((g) -> new Object[] {g}).collect(Collectors.toList()).iterator();
}
示例2: getXML
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
/**
* transforms user into XML string
*
* @param user
* @return
*/
private String getXML (Type toWrite) {
XStream xstream = new XStream(new DomDriver());
xstream.ignoreUnknownElements();
xstream.processAnnotations(SocialProfile.class);
return xstream.toXML(toWrite);
}
示例3: validGroupsFromXml
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
@DataProvider
public Iterator<Object[]> validGroupsFromXml() throws IOException {
try (BufferedReader reader = new BufferedReader(new FileReader(new File ("src/test/resources/groups.xml")))) {
String xml = "";
String line = reader.readLine();
while (line != null) {
xml += line;
line = reader.readLine();
}
XStream xstream = new XStream();
xstream.processAnnotations(GroupData.class);
List<GroupData> groups = (List<GroupData>)xstream.fromXML(xml);
return groups.stream().map((g) -> new Object[] {g}).collect(Collectors.toList()).iterator();
}
}
示例4: createXStream
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
static XStream createXStream() {
XStream xStream = new XStream();
xStream.processAnnotations(new Class[]{
ConvenienceSetterConfig.class
});
xStream.alias("convenienceSetterConfig", ConvenienceSetterConfig.class);
xStream.addImplicitCollection(ConvenienceSetterConfig.class, "convenienceSetterConfigs", "javaType", DataTypeConvenienceSetterConfig.class);
xStream.addImplicitCollection(DataTypeConvenienceSetterConfig.class, "convenienceSetters", "convenienceSetter", ConvenienceSetterModel.class);
xStream.addDefaultImplementation(ArrayList.class, List.class);
xStream.aliasAttribute(DataTypeConvenienceSetterConfig.class, "javaDataTypeName", "name");
xStream.useAttributeFor(ConvenienceSetterModel.class, "setterJavaTypeName");
xStream.useAttributeFor(ConvenienceSetterModel.class, "fullyQualifiedConverterMethodName");
return xStream;
}
示例5: toBean
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public static <T> T toBean(String xml, Class<T> cls) {
XStream xstream = new XStream();
xstream.processAnnotations(cls);
T obj = (T) xstream.fromXML(xml);
return obj;
}
示例6: registerClass
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
/**
* 会自动注册该类及其子类
* @param clz 要注册的类
*/
public static void registerClass(Class<?> clz) {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(clz);
xstream.processAnnotations(getInnerClasses(clz));
register(clz, xstream);
}
示例7: toXml
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public static String toXml(DnaTable object){
XStream xStream = new XStream();
xStream.autodetectAnnotations(true);
xStream.processAnnotations(DnaTable.class);
String top = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n";
return top + xStream.toXML(object);
}
示例8: xmlStringToBean
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
/**
* 把XML转成对象
*
* @param input
* InputStream
* @return Object
*/
@SuppressWarnings("unchecked")
public static <T> T xmlStringToBean(InputStream input, Class<T> cls) {
XStream xstream = new XStream(new DomDriver());
xstream.processAnnotations(cls);
xstream.autodetectAnnotations(true);
return (T) xstream.fromXML(input);
}
示例9: saveAsXml
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
private void saveAsXml(List<ContactData> contacts, File file) throws IOException {
XStream xstream = new XStream();
xstream.processAnnotations(ContactData.class);
String xml = xstream.toXML(contacts);
try (Writer writer = new FileWriter(file)) {
writer.write(xml);
}
}
示例10: serialize
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public String serialize(Object object) {
XStream xstream = new XStream();
xstream.processAnnotations(object.getClass());
return xstream.toXML(object);
}
示例11: serialize
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public String serialize(Object object) {
XStream xstream = new XStream(new JettisonMappedXmlDriver());
xstream.processAnnotations(object.getClass());
return xstream.toXML(object);
}
示例12: xml2Flow
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
protected Flow xml2Flow(File xmlfile) throws FileNotFoundException{
XStream xs = new XStream();
xs.processAnnotations(new Class[]{Flow.class,Start.class,End.class,RuleSet.class,Rule.class,Split.class,Constraint.class,Parallel.class,Merge.class});
return (Flow)xs.fromXML(new FileInputStream(xmlfile));
}
示例13: fromXml
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public static <T> T fromXml(Class<T> clazz, InputStream is) {
XStream xstream = XStreamInitializer.getInstance();
xstream.alias("xml", clazz);
xstream.processAnnotations(clazz);
return (T) xstream.fromXML(is);
}
示例14: xml2Rule
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
protected Rule xml2Rule(File file) throws FileNotFoundException{
XStream xs = new XStream();
xs.processAnnotations(new Class[]{Start.class,End.class,RuleSet.class,Rule.class,Split.class,Constraint.class,Parallel.class,Merge.class});
return (Rule)xs.fromXML(new FileInputStream(file));
}
示例15: toXML
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public String toXML() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(this.getClass());
return xstream.toXML(this);
}