本文整理匯總了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);
}