当前位置: 首页>>代码示例>>Java>>正文


Java ReflectionConverter类代码示例

本文整理汇总了Java中com.thoughtworks.xstream.converters.reflection.ReflectionConverter的典型用法代码示例。如果您正苦于以下问题:Java ReflectionConverter类的具体用法?Java ReflectionConverter怎么用?Java ReflectionConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ReflectionConverter类属于com.thoughtworks.xstream.converters.reflection包,在下文中一共展示了ReflectionConverter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.thoughtworks.xstream.converters.reflection.ReflectionConverter; //导入依赖的package包/类
/**
 * Setup the data to deserialize.
 *
 * @param params the parameters of the benchmark
 * @since 1.4.9
 */
@Setup(Level.Trial)
public void setUp(final BenchmarkParams params) {
    xstream = new XStream(new Xpp3Driver());
    xstream.addPermission(NoTypePermission.NONE);
    xstream.addPermission(ArrayTypePermission.ARRAYS);
    xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
    xstream.allowTypes(Model.class, String.class, BigInteger.class, UUID.class);
    final String benchmark = params.getBenchmark();
    switch (benchmark.substring(ConverterTypeBenchmark.class.getName().length() + 1)) {
    case "reflection":
        xstream.registerConverter(new ReflectionConverter(xstream.getMapper(), xstream.getReflectionProvider(),
            Model.class));
        break;
    case "javaBean":
        xstream.registerConverter(new JavaBeanConverter(xstream.getMapper(), Model.class));
        break;
    case "custom":
        xstream.registerConverter(new ModelConverter());
        break;
    default:
        throw new IllegalStateException("Unsupported benchmark type: " + benchmark);
    }
    xml = xstream.toXML(array);
    // System.out.println(xstream.toXML(array[0]));
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:32,代码来源:ConverterTypeBenchmark.java

示例2: testFailsFastIfFieldIsDefinedTwice

import com.thoughtworks.xstream.converters.reflection.ReflectionConverter; //导入依赖的package包/类
public void testFailsFastIfFieldIsDefinedTwice() {
    String input = "" +
            "<thing>\n" +
            "  <one>1.0</one>\n" +
            "  <one>2.0</one>\n" +
            "</thing>";
    xstream.alias("thing", FieldWithObjectType.class);

    try {

        xstream.fromXML(input);
        fail("Expected exception");

    } catch (ReflectionConverter.DuplicateFieldException expected) {
        assertEquals("one", expected.get("field"));
    }
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:18,代码来源:CustomClassesTest.java

示例3: setUp

import com.thoughtworks.xstream.converters.reflection.ReflectionConverter; //导入依赖的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);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:23,代码来源:ToAttributedValueConverterTest.java

示例4: setupConverters

import com.thoughtworks.xstream.converters.reflection.ReflectionConverter; //导入依赖的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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:79,代码来源:XStream.java

示例5: FileConverter

import com.thoughtworks.xstream.converters.reflection.ReflectionConverter; //导入依赖的package包/类
public FileConverter(XStream xstream) {
    this.defaultConverter = new ReflectionConverter(xstream.getMapper(), xstream.getReflectionProvider());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:ExportToolContentService.java

示例6: setUp

import com.thoughtworks.xstream.converters.reflection.ReflectionConverter; //导入依赖的package包/类
protected void setUp() throws Exception {
    super.setUp();
    xstream.alias("mbool", MultiBoolean.class);
    xstream.registerConverter(new ReflectionConverter(
        xstream.getMapper(), new PureJavaReflectionProvider()), XStream.PRIORITY_VERY_LOW);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:7,代码来源:LocalConverterTest.java

示例7: registerConverter

import com.thoughtworks.xstream.converters.reflection.ReflectionConverter; //导入依赖的package包/类
@Override
public void registerConverter(Converter converter, int priority) {
    if(!(converter instanceof ReflectionConverter)){
        super.registerConverter(converter, priority);
    }
}
 
开发者ID:jenkinsci,项目名称:xldeploy-plugin,代码行数:7,代码来源:XStreamReaderWriter.java


注:本文中的com.thoughtworks.xstream.converters.reflection.ReflectionConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。