本文整理了Java中com.thoughtworks.xstream.XStream.registerLocalConverter()
方法的一些代码示例,展示了XStream.registerLocalConverter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.registerLocalConverter()
方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:registerLocalConverter
[英]Register a local Converter for a field.
[中]为字段注册本地转换器。
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* Register a local {@link SingleValueConverter} for a field.
*
* @param definedIn the class type the field is defined in
* @param fieldName the field name
* @param converter the converter to use
* @since 1.3
*/
public void registerLocalConverter(Class definedIn, String fieldName,
SingleValueConverter converter) {
registerLocalConverter(
definedIn, fieldName, (Converter)new SingleValueConverterWrapper(converter));
}
代码示例来源:origin: geoserver/geoserver
/** Configures the xstream instance used to serialize/deserialize provider configuration. */
public void configure(XStreamPersister xp) {
// register converter for fields to be encrypted
for (Entry<Class<?>, Set<String>> entry : getFieldsForEncryption().entrySet()) {
for (String fieldName : entry.getValue()) {
xp.getXStream().registerLocalConverter(entry.getKey(), fieldName, encrypter);
}
}
}
代码示例来源:origin: javamelody/javamelody
private static XStream createXStream(boolean json) {
final XStream xstream;
if (json) {
// format json
xstream = new XStream(new JsonHierarchicalStreamDriver());
xstream.setMode(XStream.NO_REFERENCES);
} else {
// sinon format xml, utilise la dépendance XPP3 par défaut
xstream = new XStream();
}
for (final Map.Entry<String, Class<?>> entry : XStreamAlias.getMap().entrySet()) {
xstream.alias(entry.getKey(), entry.getValue());
}
final MapConverter mapConverter = new MapConverter(xstream.getMapper()) {
/** {@inheritDoc} */
@SuppressWarnings("rawtypes")
@Override
public boolean canConvert(Class type) {
return true; // Counter.requests est bien une map
}
};
xstream.registerLocalConverter(Counter.class, "requests", mapConverter);
xstream.registerLocalConverter(Counter.class, "rootCurrentContextsByThreadId",
mapConverter);
return xstream;
}
}
代码示例来源:origin: geoserver/geoserver
private XStreamPersister buildGlobalPersister() {
XStreamPersister xp = buildPersister();
xp.getXStream().alias("security", SecurityManagerConfig.class);
xp.getXStream().alias("masterPassword", MasterPasswordConfig.class);
xp.getXStream()
.registerLocalConverter(
SecurityManagerConfig.class,
"filterChain",
new FilterChainConverter(xp.getXStream().getMapper()));
// The field anonymousAuth is deprecated
xp.getXStream().omitField(SecurityManagerConfig.class, "anonymousAuth");
return xp;
}
代码示例来源:origin: geoserver/geoserver
xs.registerLocalConverter(
impl(GeoServerInfo.class), "metadata", new MetadataMapConverter());
xs.registerLocalConverter(
impl(ServiceInfo.class), "workspace", new ReferenceConverter(WorkspaceInfo.class));
xs.registerLocalConverter(impl(ServiceInfo.class), "metadata", new MetadataMapConverter());
xs.registerLocalConverter(impl(ServiceInfo.class), "keywords", new KeywordListConverter());
xs.registerLocalConverter(
DefaultCatalogFacade.class, "stores", new StoreMultiHashMapConverter());
xs.registerLocalConverter(
DefaultCatalogFacade.class, "namespaces", new SpaceMapConverter("namespace"));
xs.registerLocalConverter(
DefaultCatalogFacade.class, "workspaces", new SpaceMapConverter("workspace"));
xs.registerLocalConverter(
impl(WorkspaceInfo.class), "metadata", new MetadataMapConverter());
xs.registerLocalConverter(
impl(NamespaceInfo.class), "metadata", new MetadataMapConverter());
xs.registerLocalConverter(
impl(StoreInfo.class), "workspace", new ReferenceConverter(WorkspaceInfo.class));
xs.registerLocalConverter(
impl(StoreInfo.class), "connectionParameters", new BreifMapConverter());
xs.registerLocalConverter(impl(StoreInfo.class), "metadata", new MetadataMapConverter());
xs.registerLocalConverter(
impl(WMSStoreInfo.class), "password", new EncryptedFieldConverter());
xs.registerLocalConverter(
代码示例来源:origin: stackoverflow.com
import com.thoughtworks.xstream.*;
import com.thoughtworks.xstream.converters.collections.*;
import com.thoughtworks.xstream.mapper.*;
import java.util.*;
public class Test {
public List<String> tags = new ArrayList<String>();
public List<String> notags = new ArrayList<String>();
public Test(String tag, String tag2) {
tags.add(tag); tags.add(tag2);
notags.add(tag); notags.add(tag2);
}
public static void main(String[] args) {
Test test = new Test("foo", "bar");
XStream xstream = new XStream();
ClassAliasingMapper mapper = new ClassAliasingMapper(xstream.getMapper());
mapper.addClassAlias("tag", String.class);
xstream.registerLocalConverter(
Test.class,
"tags",
new CollectionConverter(mapper)
);
System.out.println(xstream.toXML(test));
}
}
代码示例来源:origin: ovea-deprecated/jetty-session-redis
/**
* Register a local {@link SingleValueConverter} for a field.
*
* @param definedIn the class type the field is defined in
* @param fieldName the field name
* @param converter the converter to use
* @since 1.3
*/
public void registerLocalConverter(Class definedIn, String fieldName, SingleValueConverter converter) {
registerLocalConverter(definedIn, fieldName, (Converter)new SingleValueConverterWrapper(converter));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream-java8
/**
* Register a local {@link SingleValueConverter} for a field.
*
* @param definedIn the class type the field is defined in
* @param fieldName the field name
* @param converter the converter to use
* @since 1.3
*/
public void registerLocalConverter(Class definedIn, String fieldName,
SingleValueConverter converter) {
registerLocalConverter(
definedIn, fieldName, (Converter)new SingleValueConverterWrapper(converter));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream
/**
* Register a local {@link SingleValueConverter} for a field.
*
* @param definedIn the class type the field is defined in
* @param fieldName the field name
* @param converter the converter to use
* @since 1.3
*/
public void registerLocalConverter(Class definedIn, String fieldName,
SingleValueConverter converter) {
registerLocalConverter(
definedIn, fieldName, (Converter)new SingleValueConverterWrapper(converter));
}
代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin
@Override
public void configureXStream(final XStream xstream) {
xstream.registerLocalConverter(SmtpSettingsResource.class, "username", new HtmlUnescapeStringConverter(true));
xstream.registerLocalConverter(SmtpSettingsResource.class, "password", new HtmlUnescapeStringConverter(true));
}
}
代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin
@Override
public void configureXStream(final XStream xstream) {
xstream.registerLocalConverter(SmtpSettings.class, "username", new HtmlUnescapeStringConverter(true));
xstream.registerLocalConverter(SmtpSettings.class, "password", new HtmlUnescapeStringConverter(true));
}
}
代码示例来源:origin: org.jvnet.hudson/xstream
/**
* Register a local {@link SingleValueConverter} for a field.
*
* @param definedIn the class type the field is defined in
* @param fieldName the field name
* @param converter the converter to use
* @since 1.3
*/
public void registerLocalConverter(Class definedIn, String fieldName, SingleValueConverter converter) {
registerLocalConverter(definedIn, fieldName, (Converter)new SingleValueConverterWrapper(converter));
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Register a local {@link SingleValueConverter} for a field.
*
* @param definedIn the class type the field is defined in
* @param fieldName the field name
* @param converter the converter to use
* @since 1.3
*/
public void registerLocalConverter(Class definedIn, String fieldName,
SingleValueConverter converter) {
registerLocalConverter(
definedIn, fieldName, (Converter)new SingleValueConverterWrapper(converter));
}
代码示例来源:origin: x-stream/xstream
/**
* Register a local {@link SingleValueConverter} for a field.
*
* @param definedIn the class type the field is defined in
* @param fieldName the field name
* @param converter the converter to use
* @since 1.3
*/
public void registerLocalConverter(final Class<?> definedIn, final String fieldName,
final SingleValueConverter converter) {
final Converter wrapper = new SingleValueConverterWrapper(converter);
registerLocalConverter(definedIn, fieldName, wrapper);
}
代码示例来源:origin: org.sonatype.security/security-rest-api
@Override
public void configureXStream( final XStream xstream )
{
super.configureXStream( xstream );
xstream.registerLocalConverter( UserChangePasswordResource.class, "oldPassword", new HtmlUnescapeStringConverter( true ) );
xstream.registerLocalConverter( UserChangePasswordResource.class, "newPassword", new HtmlUnescapeStringConverter( true ) );
}
代码示例来源:origin: org.geoserver/xslt
/**
* Sets up xstream to get nice xml output
*
* @param catalog
*/
private void initXStream(Catalog catalog) {
xs = new XStream();
xs.omitField(TransformInfo.class, "name");
xs.alias("transform", TransformInfo.class);
xs.registerLocalConverter(TransformInfo.class, "featureType", new ReferenceConverter(
FeatureTypeInfo.class, catalog));
xs.addDefaultImplementation(FeatureTypeInfoImpl.class, FeatureTypeInfo.class);
}
代码示例来源:origin: org.geoserver/xslt
@Override
protected void configureXStream(XStream xs) {
super.configureXStream(xs);
xs.alias("transform", TransformInfo.class);
xs.registerConverter(new TransformConverter(xs.getMapper(), xs.getReflectionProvider()));
xs.registerLocalConverter(TransformInfo.class, "featureType",
new FeatureTypeLinkConverter());
xs.addDefaultImplementation(FeatureTypeInfoImpl.class, FeatureTypeInfo.class);
}
代码示例来源:origin: org.geoserver.community/gs-notification-common
@Override
public void init(XStream xs) {
xs.aliasAttribute(DefaultNotificationProcessor.class, "sender", name);
xs.registerLocalConverter(
DefaultNotificationProcessor.class,
"sender",
new SenderConverter(xs.getMapper(), xs.getReflectionProvider(), this));
}
代码示例来源:origin: org.sonatype.nexus.plugins/nexus-plugin-console-plugin
@Override
public void configureXStream(XStream xstream) {
super.configureXStream(xstream);
xstream.processAnnotations(PluginInfoDTO.class);
xstream.processAnnotations(PluginInfoListResponseDTO.class);
xstream.registerLocalConverter(PluginInfoListResponseDTO.class, "data", new AliasingListConverter(
PluginInfoDTO.class, "pluginInfo"));
}
代码示例来源:origin: org.geoserver.community/gs-notification-common
@Override
public void init(XStream xs) {
xs.aliasAttribute(DefaultNotificationProcessor.class, "encoder", name);
xs.registerLocalConverter(
DefaultNotificationProcessor.class,
"encoder",
new EncoderConverter(xs.getMapper(), xs.getReflectionProvider(), this));
}
内容来源于网络,如有侵权,请联系作者删除!