com.thoughtworks.xstream.converters.ConverterRegistry Java Examples

The following examples show how to use com.thoughtworks.xstream.converters.ConverterRegistry. 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: XStreamMarshaller.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Set a custom XStream {@link ConverterLookup} to use.
 * Also used as {@link ConverterRegistry} if the given reference implements it as well.
 * @since 4.0
 * @see DefaultConverterLookup
 */
public void setConverterLookup(ConverterLookup converterLookup) {
	this.converterLookup = converterLookup;
	if (converterLookup instanceof ConverterRegistry) {
		this.converterRegistry = (ConverterRegistry) converterLookup;
	}
}
 
Example #2
Source File: XStreamMarshaller.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Set a custom XStream {@link ConverterLookup} to use.
 * Also used as {@link ConverterRegistry} if the given reference implements it as well.
 * @since 4.0
 * @see DefaultConverterLookup
 */
public void setConverterLookup(ConverterLookup converterLookup) {
	this.converterLookup = converterLookup;
	if (converterLookup instanceof ConverterRegistry) {
		this.converterRegistry = (ConverterRegistry) converterLookup;
	}
}
 
Example #3
Source File: XStream.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private XStream(
        ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver, ClassLoaderReference classLoader,
        Mapper mapper, final DefaultConverterLookup defaultConverterLookup) {
    this(reflectionProvider, driver, classLoader, mapper, new ConverterLookup() {
        public Converter lookupConverterForType(Class type) {
            return defaultConverterLookup.lookupConverterForType(type);
        }
    }, new ConverterRegistry() {
        public void registerConverter(Converter converter, int priority) {
            defaultConverterLookup.registerConverter(converter, priority);
        }
    });
}
 
Example #4
Source File: XStream.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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 #5
Source File: AnnotationMapper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct an AnnotationMapper.
 * 
 * @param wrapped the next {@link Mapper} in the chain
 * @since 1.4.5
 */
public AnnotationMapper(
    final Mapper wrapped, final ConverterRegistry converterRegistry, final ConverterLookup converterLookup,
    final ClassLoaderReference classLoaderReference, final ReflectionProvider reflectionProvider) {
    super(wrapped);
    this.converterRegistry = converterRegistry;
    annotatedTypes.add(Object.class);
    setupMappers();
    locked = true;
    
    final ClassLoader classLoader = classLoaderReference.getReference();
    arguments = new Object[]{
        this, classLoaderReference, reflectionProvider, converterLookup, new JVM(),
        classLoader != null ? classLoader : new TypedNull(ClassLoader.class)};
}
 
Example #6
Source File: XStreamMarshaller.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Set a custom XStream {@link ConverterLookup} to use.
 * Also used as {@link ConverterRegistry} if the given reference implements it as well.
 * @since 4.0
 * @see DefaultConverterLookup
 */
public void setConverterLookup(ConverterLookup converterLookup) {
	this.converterLookup = converterLookup;
	if (converterLookup instanceof ConverterRegistry) {
		this.converterRegistry = (ConverterRegistry) converterLookup;
	}
}
 
Example #7
Source File: XStream.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver},
 * {@link ReflectionProvider}, a prepared {@link Mapper} chain, the
 * {@link ClassLoaderReference} and an own {@link ConverterLookup} and
 * {@link ConverterRegistry}.
 * <p>
 * The ClassLoaderReference should also be used for the Mapper chain. The ConverterLookup
 * should access the ConverterRegistry if you intent to register {@link Converter} instances
 * with XStream facade or you are using annotations.
 * </p>
 * 
 * @param reflectionProvider the reflection provider to use or <em>null</em> for best
 *            matching Provider
 * @param driver the driver instance
 * @param classLoaderReference the reference to the {@link ClassLoader} to use
 * @param mapper the instance with the {@link Mapper} chain or <em>null</em> for the default
 *            chain
 * @param converterLookup the instance that is used to lookup the converters
 * @param converterRegistry an instance to manage the converter instances or <em>null</em>
 *            to prevent any further registry (including annotations)
 * @throws InitializationException in case of an initialization problem
 * @since 1.4.5
 */
public XStream(
    ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver,
    ClassLoaderReference classLoaderReference, Mapper mapper, ConverterLookup converterLookup,
    ConverterRegistry converterRegistry) {
    if (reflectionProvider == null) {
        reflectionProvider = JVM.newReflectionProvider();
    }
    this.reflectionProvider = reflectionProvider;
    this.hierarchicalStreamDriver = driver;
    this.classLoaderReference = classLoaderReference;
    this.converterLookup = converterLookup;
    this.converterRegistry = converterRegistry;
    this.mapper = mapper == null ? buildMapper() : mapper;

    setupMappers();
    setupSecurity();
    setupAliases();
    setupDefaultImplementations();
    setupConverters();
    setupImmutableTypes();
    setMode(XPATH_RELATIVE_REFERENCES);
}
 
Example #8
Source File: XStream.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver},
 * {@link ReflectionProvider}, a prepared {@link Mapper} chain, the
 * {@link ClassLoaderReference} and an own {@link ConverterLookup} and
 * {@link ConverterRegistry}.
 * 
 * @param reflectionProvider the reflection provider to use or <em>null</em> for best
 *            matching Provider
 * @param driver the driver instance
 * @param classLoader the {@link ClassLoader} to use
 * @param mapper the instance with the {@link Mapper} chain or <em>null</em> for the default
 *            chain
 * @param converterLookup the instance that is used to lookup the converters
 * @param converterRegistry an instance to manage the converter instances
 * @throws InitializationException in case of an initialization problem
 * @since 1.3
 * @deprecated As of 1.4.5 use
 *             {@link #XStream(ReflectionProvider, HierarchicalStreamDriver, ClassLoaderReference, Mapper, ConverterLookup, ConverterRegistry)}
 */
public XStream(
    ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver,
    ClassLoader classLoader, Mapper mapper, ConverterLookup converterLookup,
    ConverterRegistry converterRegistry) {
    this(reflectionProvider, driver, new ClassLoaderReference(classLoader), mapper, converterLookup, converterRegistry);
}
 
Example #9
Source File: AnnotationMapper.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Construct an AnnotationMapper.
 * 
 * @param wrapped the next {@link Mapper} in the chain
 * @since 1.3
 * @deprecated As of 1.4.5 use {@link #AnnotationMapper(Mapper, ConverterRegistry, ConverterLookup, ClassLoaderReference, ReflectionProvider)}
 */
public AnnotationMapper(
    final Mapper wrapped, final ConverterRegistry converterRegistry, final ConverterLookup converterLookup,
    final ClassLoader classLoader, final ReflectionProvider reflectionProvider,
    final JVM jvm) {
    this(wrapped, converterRegistry, converterLookup, new ClassLoaderReference(classLoader), reflectionProvider);
}
 
Example #10
Source File: XStreamMarshaller.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Set a custom XStream {@link ConverterRegistry} to use.
 * @since 4.0
 * @see #setConverterLookup
 * @see DefaultConverterLookup
 */
public void setConverterRegistry(ConverterRegistry converterRegistry) {
	this.converterRegistry = converterRegistry;
}
 
Example #11
Source File: XStreamMarshaller.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Set a custom XStream {@link ConverterRegistry} to use.
 * @since 4.0
 * @see #setConverterLookup
 * @see DefaultConverterLookup
 */
public void setConverterRegistry(ConverterRegistry converterRegistry) {
	this.converterRegistry = converterRegistry;
}
 
Example #12
Source File: XStreamMarshaller.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Set a custom XStream {@link ConverterRegistry} to use.
 * @since 4.0
 * @see #setConverterLookup
 * @see DefaultConverterLookup
 */
public void setConverterRegistry(ConverterRegistry converterRegistry) {
	this.converterRegistry = converterRegistry;
}