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


Java ConverterMatcher类代码示例

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


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

示例1: newInstance

import com.thoughtworks.xstream.converters.ConverterMatcher; //导入依赖的package包/类
private Converter newInstance(Class<? extends ConverterMatcher> paramClass)
{
  try
  {
    if (SingleValueConverter.class.isAssignableFrom(paramClass))
      return new SingleValueConverterWrapper((SingleValueConverter)paramClass.getConstructor(new Class[0]).newInstance(new Object[0]));
    Converter localConverter = (Converter)paramClass.getConstructor(new Class[0]).newInstance(new Object[0]);
    return localConverter;
  }
  catch (InvocationTargetException localInvocationTargetException)
  {
    throw new ObjectAccessException("Cannot construct " + paramClass.getName(), localInvocationTargetException.getCause());
  }
  catch (InstantiationException localInstantiationException)
  {
    throw new ObjectAccessException("Cannot construct " + paramClass.getName(), localInstantiationException);
  }
  catch (IllegalAccessException localIllegalAccessException)
  {
    throw new ObjectAccessException("Cannot construct " + paramClass.getName(), localIllegalAccessException);
  }
  catch (NoSuchMethodException localNoSuchMethodException)
  {
    throw new ObjectAccessException("Cannot construct " + paramClass.getName(), localNoSuchMethodException);
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:27,代码来源:AnnotationReflectionConverter.java

示例2: registerConverter

import com.thoughtworks.xstream.converters.ConverterMatcher; //导入依赖的package包/类
public void registerConverter(Class<? extends ConverterMatcher>... converterClass) throws Exception {
    XStreamMarshaller marshaller = (XStreamMarshaller) getMarshaller();
    marshaller.setConverters(new ConverterMatcher[] {});
    if (converterClass == null) {
        return;
    }

    List<ConverterMatcher> converters = new ArrayList<ConverterMatcher>(converterClass.length);
    for (Class<? extends ConverterMatcher> clazz : converterClass) {
        if (clazz == null)
            continue;
        ConverterMatcher converter = clazz.getConstructor(Mapper.class).newInstance(marshaller.getXStream().getMapper());
        converters.add(converter);

    }
    marshaller.setConverters(converters.toArray(new ConverterMatcher[converters.size()]));
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:18,代码来源:OxmConverter.java

示例3: setUp

import com.thoughtworks.xstream.converters.ConverterMatcher; //导入依赖的package包/类
/**
 * @throws Exception
 *             if there is a problem initializing the unmarshaller
 */
@Before
public final void setUp() throws Exception {
	QNameMapFactory qNameMapFactory = new QNameMapFactory();
	qNameMapFactory.afterPropertiesSet();
	ReflectionProviderFactory reflectionProviderFactory = new ReflectionProviderFactory();
	reflectionProviderFactory.afterPropertiesSet();

	StaxDriver streamDriver = new StaxDriver(qNameMapFactory.getObject());
	streamDriver.setRepairingNamespace(false);

	unmarshaller = new XStreamMarshaller();

	((XStreamMarshaller) unmarshaller).setAutodetectAnnotations(true);
	Map<String, Class<?>> aliases = new HashMap<String, Class<?>>();
	aliases.put("Representation", Representation.class);
	aliases.put("Agent", Agent.class);
	aliases.put("TaxonName", TaxonName.class);
	aliases.put("CategoricalCharacter", CategoricalCharacter.class);
	aliases.put("StateDefinition", StateDefinition.class);
	aliases.put("Dataset", Dataset.class);

	((XStreamMarshaller) unmarshaller).setAliases(aliases);

	((XStreamMarshaller) unmarshaller).setStreamDriver(streamDriver);
	((XStreamMarshaller) unmarshaller)
	.setConverters(new ConverterMatcher[] { new URIConverter(), new IgnoreConverter() });
	((XStreamMarshaller) unmarshaller).afterPropertiesSet();

}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:34,代码来源:AbstractIdentificationKeyMarshallingTest.java

示例4: setConverters

import com.thoughtworks.xstream.converters.ConverterMatcher; //导入依赖的package包/类
/**
 * Set the {@code Converters} or {@code SingleValueConverters} to be registered
 * with the {@code XStream} instance.
 * @see Converter
 * @see SingleValueConverter
 */
public void setConverters(ConverterMatcher... converters) {
	for (int i = 0; i < converters.length; i++) {
		if (converters[i] instanceof Converter) {
			getXStream().registerConverter((Converter) converters[i], i);
		}
		else if (converters[i] instanceof SingleValueConverter) {
			getXStream().registerConverter((SingleValueConverter) converters[i], i);
		}
		else {
			throw new IllegalArgumentException("Invalid ConverterMatcher [" + converters[i] + "]");
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:XStreamMarshaller.java

示例5: ensureCache

import com.thoughtworks.xstream.converters.ConverterMatcher; //导入依赖的package包/类
private void ensureCache(Class<? extends ConverterMatcher> paramClass)
{
  if (!this.cachedConverters.containsKey(paramClass))
    this.cachedConverters.put(paramClass, newInstance(paramClass));
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:6,代码来源:AnnotationReflectionConverter.java

示例6: setConverters

import com.thoughtworks.xstream.converters.ConverterMatcher; //导入依赖的package包/类
/**
 * Set the {@code Converters} or {@code SingleValueConverters} to be registered
 * with the {@code XStream} instance.
 * @see Converter
 * @see SingleValueConverter
 */
public void setConverters(ConverterMatcher... converters) {
	this.converters = converters;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:XStreamMarshaller.java


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