com.thoughtworks.xstream.mapper.DefaultMapper Java Examples
The following examples show how to use
com.thoughtworks.xstream.mapper.DefaultMapper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PhysicalPlanWriter.java From PoseidonX with Apache License 2.0 | 5 votes |
/** * 将执行计划序列化成字符串 */ public static String createStringPlan(PhysicalPlan plan) { XStream xstream = new XStream(new DomDriver(XML_CHARSET)); xstream.autodetectAnnotations(true); PhysicalPlanLoader.setAlias(xstream); xstream.registerConverter(new MapConverter(new DefaultMapper(new ClassLoaderReference(PhysicalPlanWriter.class.getClassLoader())))); return xstream.toXML(plan); }
Example #2
Source File: UseAttributeForEnumMapper.java From lams with GNU General Public License v2.0 | 5 votes |
static Mapper createEnumMapper(final Mapper mapper) { try { Class enumMapperClass = Class.forName( "com.thoughtworks.xstream.mapper.EnumMapper", true, Mapper.class.getClassLoader()); return (Mapper)DependencyInjectionFactory.newInstance( enumMapperClass, new Object[]{new UseAttributeForEnumMapper(mapper .lookupMapperOfType(DefaultMapper.class))}); } catch (Exception e) { return null; } }
Example #3
Source File: XStream.java From lams with GNU General Public License v2.0 | 5 votes |
private Mapper buildMapper() { Mapper mapper = new DefaultMapper(classLoaderReference); if (useXStream11XmlFriendlyMapper()) { mapper = new XStream11XmlFriendlyMapper(mapper); } mapper = new DynamicProxyMapper(mapper); mapper = new PackageAliasingMapper(mapper); mapper = new ClassAliasingMapper(mapper); mapper = new ElementIgnoringMapper(mapper); mapper = new FieldAliasingMapper(mapper); mapper = new AttributeAliasingMapper(mapper); mapper = new SystemAttributeAliasingMapper(mapper); mapper = new ImplicitCollectionMapper(mapper, reflectionProvider); mapper = new OuterClassMapper(mapper); mapper = new ArrayMapper(mapper); mapper = new DefaultImplementationsMapper(mapper); mapper = new AttributeMapper(mapper, converterLookup, reflectionProvider); if (JVM.isVersion(5)) { mapper = buildMapperDynamically( "com.thoughtworks.xstream.mapper.EnumMapper", new Class[]{Mapper.class}, new Object[]{mapper}); } mapper = new LocalConversionMapper(mapper); mapper = new ImmutableTypesMapper(mapper); if (JVM.isVersion(8)) { mapper = buildMapperDynamically("com.thoughtworks.xstream.mapper.LambdaMapper", new Class[]{Mapper.class}, new Object[]{mapper}); } mapper = new SecurityMapper(mapper); if (JVM.isVersion(5)) { mapper = buildMapperDynamically(ANNOTATION_MAPPER_TYPE, new Class[]{ Mapper.class, ConverterRegistry.class, ConverterLookup.class, ClassLoaderReference.class, ReflectionProvider.class}, new Object[]{ mapper, converterRegistry, converterLookup, classLoaderReference, reflectionProvider}); } mapper = wrapMapper((MapperWrapper)mapper); mapper = new CachingMapper(mapper); return mapper; }
Example #4
Source File: JavaClassConverter.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Construct a JavaClassConverter. * @param classLoaderReference the reference to the {@link ClassLoader} of the XStream instance * @since 1.4.5 */ public JavaClassConverter(ClassLoaderReference classLoaderReference) { this(new DefaultMapper(classLoaderReference)); }
Example #5
Source File: JavaFieldConverter.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Construct a JavaFieldConverter. * @param classLoaderReference the reference to the {@link ClassLoader} of the XStream instance * @since 1.4.5 */ public JavaFieldConverter(ClassLoaderReference classLoaderReference) { this(new JavaClassConverter(classLoaderReference), new DefaultMapper(classLoaderReference)); }
Example #6
Source File: XmlSerializer.java From brooklyn-server with Apache License 2.0 | 2 votes |
/** * JCC is used when Class instances are serialized/deserialized as a value * (not as tags) and there are no aliases configured for that type. * It is configured in XStream default *without* access to the XStream mapper, * which is meant to apply when serializing the type name for instances of that type. * <p> * However we need a few selected mappers (see {@link #wrapMapperForHandlingClasses(Mapper)} ) * to apply to all class renames, but many of the mappers must NOT be used, * e.g. because some might intercept all Class<? extends Entity> references * (and that interception is only wanted when serializing <i>instances</i>, * as in {@link #wrapMapperForNormalUsage(Mapper)}). * <p> * This can typically be done simply by registering our own instance of this (due to order guarantee of PrioritizedList), * after the instance added by XStream.setupConverters() */ private JavaClassConverter newCustomJavaClassConverter() { return new JavaClassConverter(wrapMapperForHandlingClasses(new DefaultMapper(xstream.getClassLoaderReference()))) {}; }