本文整理汇总了Java中org.springframework.oxm.xstream.XStreamMarshaller.setAliases方法的典型用法代码示例。如果您正苦于以下问题:Java XStreamMarshaller.setAliases方法的具体用法?Java XStreamMarshaller.setAliases怎么用?Java XStreamMarshaller.setAliases使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.oxm.xstream.XStreamMarshaller
的用法示例。
在下文中一共展示了XStreamMarshaller.setAliases方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.springframework.oxm.xstream.XStreamMarshaller; //导入方法依赖的package包/类
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
writer = new StaxEventItemWriter();
writer.setResource(new FileSystemResource("target/test-outputs/StaxWriterTest.xml"));
writer.setRootTagName("urlset");
XStreamMarshaller marshaller = new XStreamMarshaller();
Map<String, Object> aliases = new HashMap<String, Object>();
aliases.put("url", Url.class);
marshaller.setAliases(aliases);
writer.setMarshaller(marshaller);
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("xmlns", "http://www.sitemaps.org/schemas/sitemap");
writer.setRootElementAttributes(attributes);
}
示例2: registerXStreamMarshaller
import org.springframework.oxm.xstream.XStreamMarshaller; //导入方法依赖的package包/类
public void registerXStreamMarshaller(XStreamMarshaller marshaller, ResourceRegister register) throws Exception {
marshaller.setSupportedClasses(register.getTargetClasses());
if (!register.isEmpty()) {
Collection<ClassDescriptor> cls = register.getClassDescriptors();
Map<String, Class<?>> aliases = new HashMap<String, Class<?>>();
Map<Class<?>, String> omittedFields = new HashMap<Class<?>, String>();
for (ClassDescriptor cl : cls) {
Class<?> clazz = cl.getTargetClass();
String name = cl.getName();
if (!StringUtils.hasLength(name))
name = clazz.getSimpleName();
aliases.put(name, clazz);
Collection<String> fields = cl.getExcludesFields();
for (String fieldName : fields) {
omittedFields.put(clazz, fieldName);
}
}
marshaller.setOmittedFields(omittedFields);
marshaller.setAliases(aliases);
}
}
示例3: getMarshallingXmlViewResolver
import org.springframework.oxm.xstream.XStreamMarshaller; //导入方法依赖的package包/类
@Bean
public CustomXMLViewResolver getMarshallingXmlViewResolver() { // Resolver para o formato XML
//Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
//marshaller.setClassesToBeBound(Product.class);
XStreamMarshaller marshaller = new XStreamMarshaller();
HashMap<String, Class<?>> keys = new HashMap<String,Class<?>>();
//keys.put("product", Product.class);
//keys.put("price", Price.class);
marshaller.setAliases(keys);
return new CustomXMLViewResolver(marshaller);
}
示例4: productMarshaller
import org.springframework.oxm.xstream.XStreamMarshaller; //导入方法依赖的package包/类
@Bean
public XStreamMarshaller productMarshaller() {
HashMap<String, Class> aliases = new HashMap<String, Class>();
aliases.put("product", Product.class);
XStreamMarshaller marshaller = new XStreamMarshaller();
try {
marshaller.setAliases(aliases);
} catch (Exception ignored) {}
return marshaller;
}