com.thoughtworks.xstream.converters.ConverterLookup Java Examples
The following examples show how to use
com.thoughtworks.xstream.converters.ConverterLookup.
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: ToAttributedValueConverter.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Creates a new ToAttributedValueConverter instance. * * @param type the type that is handled by this converter instance * @param mapper the mapper in use * @param reflectionProvider the reflection provider in use * @param lookup the converter lookup in use * @param valueFieldName the field defining the tag's value (may be null) * @param valueDefinedIn the type defining the field */ public ToAttributedValueConverter( final Class type, final Mapper mapper, final ReflectionProvider reflectionProvider, final ConverterLookup lookup, final String valueFieldName, Class valueDefinedIn) { this.type = type; this.mapper = mapper; this.reflectionProvider = reflectionProvider; this.lookup = lookup; if (valueFieldName == null) { valueField = null; } else { Field field = null; try { field = (valueDefinedIn != null ? valueDefinedIn : type) .getDeclaredField(valueFieldName); if (!field.isAccessible()) { field.setAccessible(true); } } catch (NoSuchFieldException e) { throw new IllegalArgumentException(e.getMessage() + ": " + valueFieldName); } this.valueField = field; } enumMapper = JVM.isVersion(5) ? UseAttributeForEnumMapper.createEnumMapper(mapper) : null; }
Example #2
Source File: IdentifiableToIdConverter.java From cloudstreetmarket.com with GNU General Public License v3.0 | 6 votes |
/** * Creates a new ToAttributedValueConverter instance. * * @param mapper the mapper in use * @param reflectionProvider the reflection provider in use * @param lookup the converter lookup in use * @param valueFieldName the field defining the tag's value (may be null) * @param valueDefinedIn the type defining the field */ public IdentifiableToIdConverter( final Class<Identifiable<?>> type, final Mapper mapper, final ReflectionProvider reflectionProvider, final ConverterLookup lookup, final String valueFieldName, Class<?> valueDefinedIn) { this.type = type; Field field = null; try { field = (valueDefinedIn != null ? valueDefinedIn : type.getSuperclass()) .getDeclaredField("id"); if (!field.isAccessible()) { field.setAccessible(true); } } catch (NoSuchFieldException e) { throw new IllegalArgumentException(e.getMessage() + ": " + valueFieldName); } }
Example #3
Source File: AnnotationMapper.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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 #4
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 #5
Source File: ReferenceByIdMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
public ReferenceByIdMarshaller(HierarchicalStreamWriter writer, ConverterLookup converterLookup, Mapper mapper, IDGenerator idGenerator) { super(writer, converterLookup, mapper); this.idGenerator = idGenerator; }
Example #6
Source File: XStream.java From lams with GNU General Public License v2.0 | 5 votes |
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 #7
Source File: XStreamMarshaller.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * 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 #8
Source File: TreeUnmarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
public TreeUnmarshaller( Object root, HierarchicalStreamReader reader, ConverterLookup converterLookup, Mapper mapper) { this.root = root; this.reader = reader; this.converterLookup = converterLookup; this.mapper = mapper; }
Example #9
Source File: HibernateCollectionConverter.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public HibernateCollectionConverter(ConverterLookup converterLookup) { listSetConverter = converterLookup.lookupConverterForType(ArrayList.class); mapConverter = converterLookup.lookupConverterForType(HashMap.class); treeMapConverter = converterLookup.lookupConverterForType(TreeMap.class); treeSetConverter = converterLookup.lookupConverterForType(TreeSet.class); defaultConverter = converterLookup.lookupConverterForType(Object.class); }
Example #10
Source File: XStreamMarshaller.java From spring-analysis-note with MIT License | 5 votes |
/** * 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 #11
Source File: XStreamMarshaller.java From java-technology-stack with MIT License | 5 votes |
/** * 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 #12
Source File: AbstractReferenceMarshaller.java From lams with GNU General Public License v2.0 | 4 votes |
public AbstractReferenceMarshaller(HierarchicalStreamWriter writer, ConverterLookup converterLookup, Mapper mapper) { super(writer, converterLookup, mapper); this.writer = new PathTrackingWriter(writer, pathTracker); }
Example #13
Source File: ReferenceByXPathMarshaller.java From lams with GNU General Public License v2.0 | 4 votes |
public ReferenceByXPathMarshaller(HierarchicalStreamWriter writer, ConverterLookup converterLookup, Mapper mapper, int mode) { super(writer, converterLookup, mapper); this.mode = mode; }
Example #14
Source File: XStreamMarshallingStrategy.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
@Override protected TreeMarshaller createMarshallingContext(HierarchicalStreamWriter writer, ConverterLookup converterLookup, Mapper mapper) { return new HibernateProxyXPathMarshaller(writer, converterLookup, mapper, RELATIVE); }
Example #15
Source File: ReferenceByXPathMarshallingStrategy.java From lams with GNU General Public License v2.0 | 4 votes |
protected TreeUnmarshaller createUnmarshallingContext(Object root, HierarchicalStreamReader reader, ConverterLookup converterLookup, Mapper mapper) { return new ReferenceByXPathUnmarshaller(root, reader, converterLookup, mapper); }
Example #16
Source File: ReferenceByXPathMarshallingStrategy.java From lams with GNU General Public License v2.0 | 4 votes |
protected TreeMarshaller createMarshallingContext( HierarchicalStreamWriter writer, ConverterLookup converterLookup, Mapper mapper) { return new ReferenceByXPathMarshaller(writer, converterLookup, mapper, mode); }
Example #17
Source File: TreeMarshallingStrategy.java From lams with GNU General Public License v2.0 | 4 votes |
protected TreeUnmarshaller createUnmarshallingContext(Object root, HierarchicalStreamReader reader, ConverterLookup converterLookup, Mapper mapper) { return new TreeUnmarshaller(root, reader, converterLookup, mapper); }
Example #18
Source File: ReferenceByXPathUnmarshaller.java From lams with GNU General Public License v2.0 | 4 votes |
public ReferenceByXPathUnmarshaller(Object root, HierarchicalStreamReader reader, ConverterLookup converterLookup, Mapper mapper) { super(root, reader, converterLookup, mapper); this.reader = new PathTrackingReader(reader, pathTracker); isNameEncoding = reader.underlyingReader() instanceof AbstractReader; }
Example #19
Source File: TreeMarshallingStrategy.java From lams with GNU General Public License v2.0 | 4 votes |
protected TreeMarshaller createMarshallingContext( HierarchicalStreamWriter writer, ConverterLookup converterLookup, Mapper mapper) { return new TreeMarshaller(writer, converterLookup, mapper); }
Example #20
Source File: AbstractReferenceUnmarshaller.java From lams with GNU General Public License v2.0 | 4 votes |
public AbstractReferenceUnmarshaller(Object root, HierarchicalStreamReader reader, ConverterLookup converterLookup, Mapper mapper) { super(root, reader, converterLookup, mapper); }
Example #21
Source File: ReferenceByIdMarshallingStrategy.java From lams with GNU General Public License v2.0 | 4 votes |
protected TreeUnmarshaller createUnmarshallingContext(Object root, HierarchicalStreamReader reader, ConverterLookup converterLookup, Mapper mapper) { return new ReferenceByIdUnmarshaller(root, reader, converterLookup, mapper); }
Example #22
Source File: ReferenceByIdMarshallingStrategy.java From lams with GNU General Public License v2.0 | 4 votes |
protected TreeMarshaller createMarshallingContext( HierarchicalStreamWriter writer, ConverterLookup converterLookup, Mapper mapper) { return new ReferenceByIdMarshaller(writer, converterLookup, mapper); }
Example #23
Source File: SelfStreamingInstanceChecker.java From lams with GNU General Public License v2.0 | 4 votes |
/** * @since 1.4.5 */ public SelfStreamingInstanceChecker(ConverterLookup lookup, Object xstream) { this.lookup = lookup; this.self = xstream; }
Example #24
Source File: TreeMarshaller.java From lams with GNU General Public License v2.0 | 4 votes |
public TreeMarshaller( HierarchicalStreamWriter writer, ConverterLookup converterLookup, Mapper mapper) { this.writer = writer; this.converterLookup = converterLookup; this.mapper = mapper; }
Example #25
Source File: ObjectWithDefaultStringImplConverter.java From brooklyn-server with Apache License 2.0 | 4 votes |
public ObjectWithDefaultStringImplConverter(ConverterLookup lookup, ClassLoaderReference loader) { this.lookup = lookup; this.loader = loader; }
Example #26
Source File: HibernateProxyXPathMarshaller.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
public HibernateProxyXPathMarshaller(HierarchicalStreamWriter writer, ConverterLookup converterLookup, Mapper mapper, int mode) { super(writer, converterLookup, mapper, mode); }
Example #27
Source File: HibernateProxyConverter.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
public HibernateProxyConverter(Mapper arg0, ReflectionProvider arg1, ConverterLookup converterLookup) { super(arg0, arg1); this.converterLookup = converterLookup; }
Example #28
Source File: AbstractTreeMarshallingStrategy.java From lams with GNU General Public License v2.0 | 4 votes |
protected abstract TreeUnmarshaller createUnmarshallingContext(Object root, HierarchicalStreamReader reader, ConverterLookup converterLookup, Mapper mapper);
Example #29
Source File: AbstractFilePersistenceStrategy.java From lams with GNU General Public License v2.0 | 4 votes |
protected ConverterLookup getConverterLookup() { return xstream.getConverterLookup(); }
Example #30
Source File: NamedMapConverter.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Constructs a NamedMapConverter with attribute support handling an explicit Map type. * * @param type the Map type this instance will handle * @param mapper the mapper * @param entryName the name of the entry elements * @param keyName the name of the key elements * @param keyType the base type of key elements * @param valueName the name of the value elements * @param valueType the base type of value elements * @param keyAsAttribute flag to write key as attribute of entry element * @param valueAsAttribute flag to write value as attribute of entry element * @param lookup used to lookup SingleValueConverter for attributes * @since 1.4.5 */ public NamedMapConverter( Class type, Mapper mapper, String entryName, String keyName, Class keyType, String valueName, Class valueType, boolean keyAsAttribute, boolean valueAsAttribute, ConverterLookup lookup) { super(mapper, type); this.entryName = entryName != null && entryName.length() == 0 ? null : entryName; this.keyName = keyName != null && keyName.length() == 0 ? null : keyName; this.keyType = keyType; this.valueName = valueName != null && valueName.length() == 0 ? null : valueName; this.valueType = valueType; this.keyAsAttribute = keyAsAttribute; this.valueAsAttribute = valueAsAttribute; this.lookup = lookup; enumMapper = JVM.isVersion(5) ? UseAttributeForEnumMapper.createEnumMapper(mapper) : null; if (keyType == null || valueType == null) { throw new IllegalArgumentException("Class types of key and value are mandatory"); } if (entryName == null) { if (keyAsAttribute || valueAsAttribute) { throw new IllegalArgumentException( "Cannot write attributes to map entry, if map entry must be omitted"); } if (valueName == null) { throw new IllegalArgumentException( "Cannot write value as text of entry, if entry must be omitted"); } } if (keyName == null) { throw new IllegalArgumentException("Cannot write key without name"); } if (valueName == null) { if (valueAsAttribute) { throw new IllegalArgumentException( "Cannot write value as attribute without name"); } else if (!keyAsAttribute) { throw new IllegalArgumentException( "Cannot write value as text of entry, if key is also child element"); } } if (keyAsAttribute && valueAsAttribute && keyName.equals(valueName)) { throw new IllegalArgumentException( "Cannot write key and value with same attribute name"); } }