本文整理汇总了Java中com.thoughtworks.xstream.mapper.MapperWrapper类的典型用法代码示例。如果您正苦于以下问题:Java MapperWrapper类的具体用法?Java MapperWrapper怎么用?Java MapperWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapperWrapper类属于com.thoughtworks.xstream.mapper包,在下文中一共展示了MapperWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCloner
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
@Override
public <T> Function<T, T> createCloner(ClassLoader classLoader)
{
final XStream xstream = new XStream() {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new HibernateMapper(next);
}
};
xstream.setClassLoader(classLoader);
xstream.autodetectAnnotations(true);
xstream.registerConverter(new HibernateProxyConverter());
xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream.getMapper()));
xstream.registerConverter(new HibernatePersistentMapConverter(xstream.getMapper()));
xstream.registerConverter(new HibernatePersistentSortedMapConverter(xstream.getMapper()));
xstream.registerConverter(new HibernatePersistentSortedSetConverter(xstream.getMapper()));
return t -> (T) xstream.fromXML(xstream.toXML(t));
}
示例2: getXStream
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
private synchronized XStream getXStream()
{
if( xstream == null )
{
xstream = new XmlServiceImpl.ExtXStream(getClass().getClassLoader()) {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new HibernateMapper(next);
}
};
xstream.registerConverter(new WorkflowNodeConverter());
xstream.registerConverter(new BaseEntityXmlConverter(registry));
xstream.registerConverter(new HibernateProxyConverter());
xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream.getMapper()));
xstream.registerConverter(new HibernatePersistentMapConverter(xstream.getMapper()));
}
return xstream;
}
示例3: getXStream
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
private synchronized XStream getXStream()
{
if( xstream == null )
{
xstream = new XmlServiceImpl.ExtXStream(getClass().getClassLoader()) {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new HibernateMapper(next);
}
};
xstream.registerConverter(new HibernateProxyConverter());
xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream.getMapper()));
xstream.alias("com.tle.core.oauth.beans.OAuthToken", OAuthToken.class);
xstream.alias("com.tle.core.oauth.beans.OAuthClient", OAuthClient.class);
xstream.registerConverter(new ClientXStreamConverter());
}
return xstream;
}
示例4: XStreamXml
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
public XStreamXml() {
XStream prototype = new XStream();
MapperWrapper mapperWrapper = new MapperWrapper(prototype.getMapper()) {
/**
* Overridden to force a class attribute to be emitted on elements whose tag name is not already the name or
* alias of a class.
*/
@Override
public Class defaultImplementationOf(Class type) {
return null;
}
};
xStream = new XStream(prototype.getReflectionProvider(), new XppDriver(), prototype.getClassLoaderReference(),
mapperWrapper);
xStream.setMode(XStream.ID_REFERENCES);
}
示例5: loadXStream
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
private static XStream loadXStream() {
XStream xstream = new XStream(new DomDriver("UTF-8")) {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new MapperWrapper(next) {
@Override
public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") Class definedIn,
String fieldName) {
if (definedIn == Object.class) {
return false;
}
return super.shouldSerializeMember(definedIn, fieldName);
}
};
}
};
xstream.setMode(XStream.NO_REFERENCES);
return xstream;
}
示例6: generateXStream
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
/**
* {@link XStream} generator
* <p>
*
* @param hierarchicalStreamDriver
* {@link HierarchicalStreamDriver}
* @return {@link XStream}
*/
private XStream generateXStream(HierarchicalStreamDriver hierarchicalStreamDriver) {
XStream xStream = new XStream(hierarchicalStreamDriver) {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new MapperWrapper(next) {
@Override
// avoid {@link XStream} crash when field misses
public boolean shouldSerializeMember(Class definedIn, String fieldName) {
try {
return definedIn != Object.class || realClass(fieldName) != null;
}
catch (CannotResolveClassException cnrce) {
return false;
}
}
};
}
};
xStream.autodetectAnnotations(true);
return xStream;
}
示例7: testUserDefinedMappingCanAlterFieldName
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
public void testUserDefinedMappingCanAlterFieldName() {
xstream = new XStream() {
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new FieldPrefixStrippingMapper(next);
}
};
setupSecurity(xstream);
xstream.alias("thing", ThingWithStupidNamingConventions.class);
ThingWithStupidNamingConventions in = new ThingWithStupidNamingConventions("Joe", "Walnes", 10);
String expectedXml = ""
+ "<thing>\n"
+ " <firstName>Joe</firstName>\n" // look, no underscores!
+ " <lastName>Walnes</lastName>\n"
+ " <age>10</age>\n"
+ "</thing>";
assertBothWays(in, expectedXml);
}
示例8: testStripsPackagesUponDeserialization
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
public void testStripsPackagesUponDeserialization() {
// obviously this isn't deserializable!
xstream = new XStream() {
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new PackageStrippingMapper(next);
}
};
// NOTE: no aliases defined!
String expectedXml = "" +
"<Software>\n" +
" <vendor>ms</vendor>\n" +
" <name>word</name>\n" +
"</Software>";
assertEquals(expectedXml, xstream.toXML(new Software("ms", "word")));
}
示例9: createXStream
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
protected XStream createXStream() {
final XStream xstream = new XStream() {
protected MapperWrapper wrapMapper(final MapperWrapper next) {
return new HibernateMapper(next);
}
};
xstream.registerConverter(new HibernateProxyConverter());
xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream
.getMapper()));
xstream.registerConverter(new HibernatePersistentMapConverter(xstream.getMapper()));
xstream
.registerConverter(new HibernatePersistentSortedMapConverter(xstream.getMapper()));
xstream
.registerConverter(new HibernatePersistentSortedSetConverter(xstream.getMapper()));
return xstream;
}
示例10: createStream
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
/**
* Creates a stream instance for reading and writing.
*
* @return the stream instance
*/
private static final XStream createStream() {
XStream xstream = new XStream() {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new ClassNameAliasingMapper(next);
}
};
xstream.setMode(XStream.ID_REFERENCES);
xstream.alias("model", Model.class);
xstream.addImplicitCollection(Model.class, "models");
xstream.registerConverter(new DelegatingTypeConverter());
xstream.registerConverter(new EnumValueConverter());
xstream.registerConverter(new OperationConverter());
xstream.registerConverter(new TypeRegistryConverter());
xstream.registerConverter(new VTLTypeConverter());
xstream.registerConverter(new AdviceConverter());
xstream.registerConverter(new NullValueTypeConverter());
xstream.registerConverter(new NullValueConverter());
xstream.registerConverter(new ReflectionOperationDescriptorConverter());
xstream.registerConverter(new ReflectionTypeDescriptorConverter());
xstream.registerConverter(new IVMLTypeDescriptorConverter());
xstream.registerConverter(new IvmlComparisonOperationDescriptorConverter());
xstream.registerConverter(new ClassWrapperConverter());
return xstream;
}
示例11: getXStream
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
private XStream getXStream() {
if (supportedClasses.isEmpty()) {
init();
}
NameCoder replacer = new NoNameCoder();
final XStream xStream = new XStream(new XppDriver(replacer)) {
@Override
protected MapperWrapper wrapMapper(final MapperWrapper next) {
return new MapperWrapper(next) {
@Override
public boolean shouldSerializeMember(final Class definedIn, final String fieldName) {
if (definedIn == Object.class) {
return false;
}
return super.shouldSerializeMember(definedIn, fieldName);
}
};
}
};
xStream.registerConverter(new NullDoubleConverter());
xStream.registerConverter(new NullLongConverter());
xStream.processAnnotations(supportedClasses.toArray(new Class[supportedClasses.size()]));
return xStream;
}
示例12: createXStream
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
private XStream createXStream() {
XStream xstream = new XStream() {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new MapperWrapper(next) {
@Override
public boolean shouldSerializeMember(Class definedIn,
String fieldName) {
//System.out.println("definedIn: " + definedIn.getCanonicalName() + ", Object: " + Object.class.getCanonicalName());
if (definedIn == Object.class) {
return false;
}
// System.out.println(fieldName);
return super.shouldSerializeMember(definedIn, fieldName);
}
};
}
};
return xstream;
}
示例13: initXStream
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
/**
* @return
*/
private XStream initXStream(final Session session, final boolean nullifyPk)
{
final XStream xstream = new XStream() {
@Override
protected MapperWrapper wrapMapper(final MapperWrapper next)
{
return new HibernateMapper(new HibernateCollectionsMapper(next));
}
};
// Converter für die Hibernate-Collections
xstream.registerConverter(new HibernateCollectionConverter(xstream.getConverterLookup()));
xstream.registerConverter(
new HibernateProxyConverter(xstream.getMapper(), new PureJavaReflectionProvider(), xstream.getConverterLookup()),
XStream.PRIORITY_VERY_HIGH);
xstream.setMarshallingStrategy(new XStreamMarshallingStrategy(XStreamMarshallingStrategy.RELATIVE));
init(xstream);
return xstream;
}
示例14: McxPriceSource
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
public McxPriceSource(String currency) {
this.currency = currency;
x = new XStream() {
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new MapperWrapper(next) {
@Override
public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") Class definedIn,
String fieldName) {
if (definedIn == Doc.class && !"lprice".equals(fieldName)) {
return false;
}
return super.shouldSerializeMember(definedIn, fieldName);
}
};
}
};
x.processAnnotations(Doc.class);
}
示例15: XmlObjectSerializerIgnoreMissingFieldsServiceImpl
import com.thoughtworks.xstream.mapper.MapperWrapper; //导入依赖的package包/类
public XmlObjectSerializerIgnoreMissingFieldsServiceImpl() {
xstream = new XStream(new ProxyAwareJavaReflectionProvider()) {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new MapperWrapper(next) {
@Override
public boolean shouldSerializeMember(Class definedIn,
String fieldName) {
if (definedIn == Object.class) {
return false;
}
return super.shouldSerializeMember(definedIn, fieldName);
}
};
}
};
xstream.registerConverter(new ProxyConverter(xstream.getMapper(), xstream.getReflectionProvider() ));
xstream.addDefaultImplementation(ArrayList.class, ListProxyDefaultImpl.class);
xstream.registerConverter(new DateTimeConverter());
}