本文整理了Java中com.thoughtworks.xstream.XStream.registerConverter()
方法的一些代码示例,展示了XStream.registerConverter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.registerConverter()
方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:registerConverter
[英]Register a converter with normal priority.
[中]以正常优先级注册转换器。
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void registerConverter(SingleValueConverter converter) {
registerConverter(converter, PRIORITY_NORMAL);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
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 InternalBlackList(), 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 DateConverter(), PRIORITY_NORMAL);
registerConverter(new BitSetConverter(), 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);
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void registerConverter(Converter converter) {
registerConverter(converter, PRIORITY_NORMAL);
}
代码示例来源:origin: kiegroup/optaplanner
public static void registerScoreConverters(XStream xStream) {
xStream.registerConverter(new SimpleScoreXStreamConverter());
xStream.registerConverter(new SimpleLongScoreXStreamConverter());
xStream.registerConverter(new SimpleDoubleScoreXStreamConverter());
xStream.registerConverter(new SimpleBigDecimalScoreXStreamConverter());
xStream.registerConverter(new HardSoftScoreXStreamConverter());
xStream.registerConverter(new HardSoftLongScoreXStreamConverter());
xStream.registerConverter(new HardSoftDoubleScoreXStreamConverter());
xStream.registerConverter(new HardSoftBigDecimalScoreXStreamConverter());
xStream.registerConverter(new HardMediumSoftScoreXStreamConverter());
xStream.registerConverter(new HardMediumSoftLongScoreXStreamConverter());
xStream.registerConverter(new HardMediumSoftBigDecimalScoreXStreamConverter());
xStream.registerConverter(new BendableScoreXStreamConverter());
xStream.registerConverter(new BendableLongScoreXStreamConverter());
xStream.registerConverter(new BendableBigDecimalScoreXStreamConverter());
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
private void registerConverterDynamically(String className, int priority,
Class[] constructorParamTypes, Object[] constructorParamValues) {
try {
Class type = Class.forName(className, false, classLoaderReference.getReference());
Constructor constructor = type.getConstructor(constructorParamTypes);
Object instance = constructor.newInstance(constructorParamValues);
if (instance instanceof Converter) {
registerConverter((Converter)instance, priority);
} else if (instance instanceof SingleValueConverter) {
registerConverter((SingleValueConverter)instance, priority);
}
} catch (Exception e) {
throw new com.thoughtworks.xstream.InitializationException(
"Could not instantiate converter : " + className, e);
} catch (LinkageError e) {
throw new com.thoughtworks.xstream.InitializationException(
"Could not instantiate converter : " + className, e);
}
}
代码示例来源:origin: geoserver/geoserver
@Override
public void migrationPersister(XStreamPersister xp) {
xp.getXStream()
.registerConverter(
new Converter() {
代码示例来源:origin: spring-projects/spring-framework
for (int i = 0; i < this.converters.length; i++) {
if (this.converters[i] instanceof Converter) {
xstream.registerConverter((Converter) this.converters[i], i);
xstream.registerConverter((SingleValueConverter) this.converters[i], i);
代码示例来源:origin: AxonFramework/AxonFramework
/**
* Instantiate a {@link AbstractXStreamSerializer} based on the fields contained in the {@link Builder}.
*
* @param builder the {@link Builder} used to instantiate a {@link AbstractXStreamSerializer} instance
*/
protected AbstractXStreamSerializer(Builder builder) {
builder.validate();
this.charset = builder.charset;
this.xStream = builder.xStream;
this.converter = builder.converter;
this.revisionResolver = builder.revisionResolver;
if (converter instanceof ChainingConverter) {
registerConverters((ChainingConverter) converter);
}
xStream.addImmutableType(UUID.class, true);
// Message serialization
xStream.alias("domain-event", GenericDomainEventMessage.class);
xStream.alias("event", GenericEventMessage.class);
xStream.alias("command", GenericCommandMessage.class);
// For backward compatibility
xStream.alias("uuid", UUID.class);
xStream.alias("meta-data", MetaData.class);
xStream.registerConverter(new MetaDataConverter(xStream.getMapper()));
}
代码示例来源:origin: stackoverflow.com
magicApi.registerConverter(new MapEntryConverter());
magicApi.alias("root", Map.class);
代码示例来源:origin: kiegroup/optaplanner
/**
* @param solverConfigContext never null
*/
public XStreamXmlPlannerBenchmarkFactory(SolverConfigContext solverConfigContext) {
super(solverConfigContext);
xStream = XStreamXmlSolverFactory.buildXStream();
ClassLoader actualClassLoader = solverConfigContext.determineActualClassLoader();
xStream.setClassLoader(actualClassLoader);
xStream.processAnnotations(PlannerBenchmarkConfig.class);
xStream.registerConverter(new FileConverter() {
@Override
public String toString(Object obj) {
// Write "/" path separators (even on Windows) for portability
return FilenameUtils.separatorsToUnix(((File) obj).getPath());
}
});
}
代码示例来源:origin: geoserver/geoserver
xs.registerConverter(new ServiceInfoConverter());
xs.omitField(impl(ServiceInfo.class), "geoServer");
xs.registerConverter(new SpaceInfoConverter());
xs.registerConverter(new StoreInfoConverter());
xs.registerConverter(new ResourceInfoConverter());
xs.registerConverter(new FeatureTypeInfoConverter());
xs.registerConverter(new CoverageInfoConverter());
xs.registerConverter(new LayerInfoConverter());
xs.registerConverter(new LayerGroupInfoConverter());
xs.registerConverter(new GridGeometry2DConverter());
xs.registerConverter(new ProxyCollectionConverter(xs.getMapper()));
xs.registerConverter(new VirtualTableConverter());
xs.registerConverter(new KeywordInfoConverter());
xs.registerConverter(new SettingsInfoConverter());
"metadata",
new SettingsTolerantMapConverter(xs.getMapper(), MetadataMap.class));
xs.registerConverter(new MeasureConverter());
xs.registerConverter(new MultimapConverter(xs.getMapper()));
代码示例来源:origin: openmrs/openmrs-core
/**
* Constructor that takes a custom XStream object
* @param customXstream
* @throws SerializationException
*/
public SimpleXStreamSerializer(XStream customXstream) throws SerializationException {
if (customXstream == null) {
xstream = new XStream();
} else {
this.xstream = customXstream;
}
xstream.registerConverter(new OpenmrsDynamicProxyConverter(), XStream.PRIORITY_VERY_HIGH);
//this is added to read the prior simpleframework-serialized values.
// TODO find a better way to do this.
this.xstream.useAttributeFor(ImplementationId.class, "implementationId");
}
代码示例来源:origin: x-stream/xstream
/**
* Register a converter with normal priority.
*
* @param converter the converter instance
*/
public void registerConverter(final Converter converter) {
registerConverter(converter, PRIORITY_NORMAL);
}
代码示例来源:origin: x-stream/xstream
/**
* Register a single value converter with normal priority.
*
* @param converter the single value converter instance
*/
public void registerConverter(final SingleValueConverter converter) {
registerConverter(converter, PRIORITY_NORMAL);
}
代码示例来源:origin: stackoverflow.com
@Test
public void versioning() {
Person person = new Person();
person.setName("Davide");
XStream xStream = new XStream(new DomDriver());
xStream.registerConverter(new PersonConverter());
xStream.alias("person", Person.class);
System.out.println(xStream.toXML(person));
}
代码示例来源:origin: sakaiproject/sakai
protected static XStream getXStream() {
final XStream xstream = new XStream(new DomDriver()); // does not require XPP3 library
xstream.registerConverter(new Converter(xstream.getMapper(), xstream.getReflectionProvider()));
return xstream;
}
代码示例来源:origin: caelum/vraptor
@Override
protected XStream getXStream() {
XStream xStream = super.getXStream();
xStream.registerConverter(new MegaConverter());
return xStream;
}
};
代码示例来源:origin: caelum/vraptor
@Override
protected XStream getXStream() {
XStream xStream = super.getXStream();
xStream.registerConverter(new MegaConverter());
return xStream;
}
};
代码示例来源:origin: caelum/vraptor
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
this.restfulie = mock(Restfulie.class);
when(restfulie.newRelationBuilder()).thenReturn(builder);
Configuration config = mock(Configuration.class);
when(config.getApplicationPath()).thenReturn("http://www.caelum.com.br");
xstream = new XStream(new JsonHierarchicalStreamDriver());
ReflectionConverter base = new ReflectionConverter(xstream.getMapper(), xstream.getReflectionProvider());
xstream.registerConverter(new LinkConverterJSON(base, restfulie, config));
}
代码示例来源:origin: caelum/vraptor
@Test
public void whenMethodIsAnnotatedAddsItsContent() {
XStream x = new XStream();
x.alias("player", Player.class);
x.registerConverter(new MethodValueSupportConverter(new ReflectionConverter(x.getMapper(), x.getReflectionProvider())), XStream.PRIORITY_LOW);
String content = x.toXML(new Player());
assertThat(content, is(equalTo("<player>\n <name>custom_name</name>\n</player>")));
}
内容来源于网络,如有侵权,请联系作者删除!