本文整理汇总了Java中com.thoughtworks.xstream.converters.ConverterLookup类的典型用法代码示例。如果您正苦于以下问题:Java ConverterLookup类的具体用法?Java ConverterLookup怎么用?Java ConverterLookup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConverterLookup类属于com.thoughtworks.xstream.converters包,在下文中一共展示了ConverterLookup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ToAttributedValueConverter
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
/**
* 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, final 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 (final NoSuchFieldException e) {
throw new IllegalArgumentException(e.getMessage() + ": " + valueFieldName);
}
valueField = field;
}
enumMapper = UseAttributeForEnumMapper.createEnumMapper(mapper);
}
示例2: XStream
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
private XStream(
final ReflectionProvider reflectionProvider, final HierarchicalStreamDriver driver,
final ClassLoaderReference classLoader, final Mapper mapper,
final DefaultConverterLookup defaultConverterLookup) {
this(reflectionProvider, driver, classLoader, mapper, new ConverterLookup() {
@Override
public Converter lookupConverterForType(final Class<?> type) {
return defaultConverterLookup.lookupConverterForType(type);
}
}, new ConverterRegistry() {
@Override
public void registerConverter(final Converter converter, final int priority) {
defaultConverterLookup.registerConverter(converter, priority);
}
});
}
示例3: IdentifiableToIdConverter
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
/**
* 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);
}
}
示例4: AnnotationMapper
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
/**
* 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)};
}
示例5: testCanReadXmlUnfriendlyXPathReferences
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
public void testCanReadXmlUnfriendlyXPathReferences() {
xstream.setMarshallingStrategy(new ReferenceByXPathMarshallingStrategy(ReferenceByXPathMarshallingStrategy.RELATIVE) {
protected TreeUnmarshaller createUnmarshallingContext(Object root,
HierarchicalStreamReader reader, ConverterLookup converterLookup, Mapper mapper) {
return new XStream12ReferenceByXPathUnmarshaller(root, reader, converterLookup, mapper);
}
});
xstream.alias("foo$bar", StringBuffer.class);
xstream.alias("x_y", StringBuffer.class);
String xml =
"<list>\n" +
" <foo_-bar>foo</foo_-bar>\n" +
" <foo_-bar reference=\"../foo$bar\"/>\n" +
" <x__y>bar</x__y>\n" +
" <x__y reference=\"../x_y\"/>\n" +
"</list>";
List list = (List)xstream.fromXML(xml);
assertEquals(4, list.size());
assertSame(list.get(0), list.get(1));
assertEquals("foo", list.get(0).toString());
assertSame(list.get(2), list.get(3));
assertEquals("bar", list.get(2).toString());
}
示例6: XStream
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
public XStream(ReflectionProvider paramReflectionProvider, HierarchicalStreamDriver paramHierarchicalStreamDriver, ClassLoaderReference paramClassLoaderReference, Mapper paramMapper, ConverterLookup paramConverterLookup, ConverterRegistry paramConverterRegistry)
{
if (paramReflectionProvider == null)
paramReflectionProvider = JVM.newReflectionProvider();
this.reflectionProvider = paramReflectionProvider;
this.hierarchicalStreamDriver = paramHierarchicalStreamDriver;
this.classLoaderReference = paramClassLoaderReference;
this.converterLookup = paramConverterLookup;
this.converterRegistry = paramConverterRegistry;
Mapper localMapper;
if (paramMapper == null)
localMapper = buildMapper();
else
localMapper = paramMapper;
this.mapper = localMapper;
setupMappers();
setupSecurity();
setupAliases();
setupDefaultImplementations();
setupConverters();
setupImmutableTypes();
setMode(1003);
}
示例7: AnnotationMapper
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
/**
* 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>(ClassLoader.class)};
}
示例8: ReferenceByXPathUnmarshaller
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
public ReferenceByXPathUnmarshaller(
final Object root, final HierarchicalStreamReader reader, final ConverterLookup converterLookup,
final Mapper mapper) {
super(root, reader, converterLookup, mapper);
this.reader = new PathTrackingReader(reader, pathTracker);
isNameEncoding = reader.underlyingReader() instanceof AbstractReader;
}
示例9: TreeUnmarshaller
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
public TreeUnmarshaller(
final Object root, final HierarchicalStreamReader reader, final ConverterLookup converterLookup,
final Mapper mapper) {
this.root = root;
this.reader = reader;
this.converterLookup = converterLookup;
this.mapper = mapper;
}
示例10: setConverterLookup
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
/**
* 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;
}
}
示例11: marshal
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
public void marshal(HierarchicalStreamWriter writer, Object obj,
ConverterLookup converterLookup, Mapper mapper, DataHolder dataHolder) {
if (marshaller == null) {
marshaller = new ReferenceByIdMarshaller(writer, converterLookup, mapper);
}
marshaller.start(obj, dataHolder);
}
示例12: unmarshal
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
public Object unmarshal(Object root, HierarchicalStreamReader reader,
DataHolder dataHolder, ConverterLookup converterLookup, Mapper mapper) {
if (unmarshaller == null) {
unmarshaller = new ReferenceByIdUnmarshaller(
root, reader, converterLookup, mapper);
}
return unmarshaller.start(dataHolder);
}
示例13: createUnmarshallingContext
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
@Override
protected ReferenceByXPathUnmarshaller createUnmarshallingContext(Object root,
HierarchicalStreamReader reader,
ConverterLookup converterLookup,
Mapper mapper) {
assertNull("strategy can only make one unmarshaller", requestedUnmarshaller);
requestedUnmarshaller = (ReferenceByXPathUnmarshaller) super.createUnmarshallingContext(root, reader, converterLookup, mapper);
return requestedUnmarshaller;
}
示例14: createMarshallingContext
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
@Override
protected ReferenceByXPathMarshaller createMarshallingContext(HierarchicalStreamWriter writer,
ConverterLookup converterLookup,
Mapper mapper) {
assertNull("strategy can only make one marshaller", requestedMarshaller);
requestedMarshaller = (ReferenceByXPathMarshaller) super.createMarshallingContext(writer, converterLookup, mapper);
return requestedMarshaller;
}
示例15: TreeUnmarshaller
import com.thoughtworks.xstream.converters.ConverterLookup; //导入依赖的package包/类
public TreeUnmarshaller(Object paramObject, HierarchicalStreamReader paramHierarchicalStreamReader, ConverterLookup paramConverterLookup, Mapper paramMapper)
{
this.root = paramObject;
this.reader = paramHierarchicalStreamReader;
this.converterLookup = paramConverterLookup;
this.mapper = paramMapper;
}