本文整理汇总了Java中com.thoughtworks.xstream.converters.basic.StringConverter类的典型用法代码示例。如果您正苦于以下问题:Java StringConverter类的具体用法?Java StringConverter怎么用?Java StringConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringConverter类属于com.thoughtworks.xstream.converters.basic包,在下文中一共展示了StringConverter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.thoughtworks.xstream.converters.basic.StringConverter; //导入依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
final ClassAliasingMapper classAliasingMapper = new ClassAliasingMapper(
new DefaultMapper(new ClassLoaderReference(getClass().getClassLoader())));
classAliasingMapper.addClassAlias("x", X.class);
classAliasingMapper.addClassAlias("software", Software.class);
classAliasingMapper.addClassAlias("open-source", OpenSourceSoftware.class);
mapper = new DefaultImplementationsMapper(new ArrayMapper(classAliasingMapper));
reflectionProvider = new SunUnsafeReflectionProvider();
driver = new XppDriver();
converterLookup = new DefaultConverterLookup();
converterLookup.registerConverter(
new SingleValueConverterWrapper(new StringConverter()), 0);
converterLookup.registerConverter(
new SingleValueConverterWrapper(new IntConverter()), 0);
converterLookup.registerConverter(new ArrayConverter(mapper), 0);
converterLookup.registerConverter(
new ReflectionConverter(mapper, reflectionProvider), -1);
}
示例2: testCanReplaceWithHigherPriority
import com.thoughtworks.xstream.converters.basic.StringConverter; //导入依赖的package包/类
public void testCanReplaceWithHigherPriority() {
// this test actually depends on the keyset implementation of the corresponding cache map.
final DefaultConverterLookup lookup = new DefaultConverterLookup();
Converter currentConverter = new SingleValueConverterWrapper(new StringConverter());
lookup.registerConverter(new BitSetConverter(), XStream.PRIORITY_VERY_HIGH);
lookup.registerConverter(currentConverter, -100);
lookup.lookupConverterForType(String.class);
lookup.lookupConverterForType(BitSet.class);
assertEquals(lookup.lookupConverterForType(String.class), currentConverter);
Converter newConverter = new SingleValueConverterWrapper(new StringConverter());
lookup.registerConverter(newConverter, 100);
assertEquals(lookup.lookupConverterForType(String.class), newConverter);
}
示例3: setupConverters
import com.thoughtworks.xstream.converters.basic.StringConverter; //导入依赖的package包/类
protected void setupConverters() {
registerConverter(new ReflectionConverter(mapper, reflectionProvider), PRIORITY_VERY_LOW);
registerConverter(new SerializableConverter(mapper, reflectionProvider, classLoaderReference), PRIORITY_LOW);
registerConverter(new ExternalizableConverter(mapper, classLoaderReference), PRIORITY_LOW);
registerConverter(new NullConverter(), PRIORITY_VERY_HIGH);
registerConverter(new IntConverter(), PRIORITY_NORMAL);
registerConverter(new FloatConverter(), PRIORITY_NORMAL);
registerConverter(new DoubleConverter(), PRIORITY_NORMAL);
registerConverter(new LongConverter(), PRIORITY_NORMAL);
registerConverter(new ShortConverter(), PRIORITY_NORMAL);
registerConverter((Converter)new CharConverter(), PRIORITY_NORMAL);
registerConverter(new BooleanConverter(), PRIORITY_NORMAL);
registerConverter(new ByteConverter(), PRIORITY_NORMAL);
registerConverter(new StringConverter(), PRIORITY_NORMAL);
registerConverter(new StringBufferConverter(), PRIORITY_NORMAL);
registerConverter(new StringBuilderConverter(), PRIORITY_NORMAL);
registerConverter(new ThrowableConverter(converterLookup), PRIORITY_NORMAL);
registerConverter(new StackTraceElementConverter(), PRIORITY_NORMAL);
registerConverter(new DateConverter(), PRIORITY_NORMAL);
registerConverter(new GregorianCalendarConverter(), PRIORITY_NORMAL);
registerConverter(new RegexPatternConverter(), PRIORITY_NORMAL);
registerConverter(new CurrencyConverter(), PRIORITY_NORMAL);
registerConverter(new CharsetConverter(), PRIORITY_NORMAL);
registerConverter(new LocaleConverter(), PRIORITY_NORMAL);
registerConverter(new BitSetConverter(), PRIORITY_NORMAL);
registerConverter(new UUIDConverter(), PRIORITY_NORMAL);
registerConverter(new URIConverter(), PRIORITY_NORMAL);
registerConverter(new URLConverter(), PRIORITY_NORMAL);
registerConverter(new BigIntegerConverter(), PRIORITY_NORMAL);
registerConverter(new BigDecimalConverter(), PRIORITY_NORMAL);
registerConverter(new ArrayConverter(mapper), PRIORITY_NORMAL);
registerConverter(new CharArrayConverter(), PRIORITY_NORMAL);
registerConverter(new CollectionConverter(mapper), PRIORITY_NORMAL);
registerConverter(new MapConverter(mapper), PRIORITY_NORMAL);
registerConverter(new TreeMapConverter(mapper), PRIORITY_NORMAL);
registerConverter(new TreeSetConverter(mapper), PRIORITY_NORMAL);
registerConverter(new SingletonCollectionConverter(mapper), PRIORITY_NORMAL);
registerConverter(new SingletonMapConverter(mapper), PRIORITY_NORMAL);
registerConverter(new PropertiesConverter(), PRIORITY_NORMAL);
registerConverter((Converter)new EncodedByteArrayConverter(), PRIORITY_NORMAL);
registerConverter(new EnumConverter(), PRIORITY_NORMAL);
registerConverter(new EnumSetConverter(mapper), PRIORITY_NORMAL);
registerConverter(new EnumMapConverter(mapper), PRIORITY_NORMAL);
registerConverter(new FileConverter(), PRIORITY_NORMAL);
if (JVM.isSQLAvailable()) {
registerConverter(new SqlTimestampConverter(), PRIORITY_NORMAL);
registerConverter(new SqlTimeConverter(), PRIORITY_NORMAL);
registerConverter(new SqlDateConverter(), PRIORITY_NORMAL);
}
registerConverter(new DynamicProxyConverter(mapper, classLoaderReference), PRIORITY_NORMAL);
registerConverter(new JavaClassConverter(classLoaderReference), PRIORITY_NORMAL);
registerConverter(new JavaMethodConverter(classLoaderReference), PRIORITY_NORMAL);
registerConverter(new JavaFieldConverter(classLoaderReference), PRIORITY_NORMAL);
if (JVM.isAWTAvailable()) {
registerConverter(new FontConverter(mapper), PRIORITY_NORMAL);
registerConverter(new ColorConverter(), PRIORITY_NORMAL);
registerConverter(new TextAttributeConverter(), PRIORITY_NORMAL);
}
if (JVM.isSwingAvailable()) {
registerConverter(new LookAndFeelConverter(mapper, reflectionProvider), PRIORITY_NORMAL);
}
if (JVM.loadClassForName("javax.security.auth.Subject") != null) {
registerConverterDynamically("com.thoughtworks.xstream.converters.extended.SubjectConverter",
PRIORITY_NORMAL, new Class[]{Mapper.class}, new Object[]{mapper});
}
if (JVM.loadClassForName("javax.xml.datatype.Duration") != null) {
registerConverterDynamically("com.thoughtworks.xstream.converters.extended.DurationConverter",
PRIORITY_NORMAL, null, null);
}
registerConverter(new SelfStreamingInstanceChecker(converterLookup, this), PRIORITY_NORMAL);
}