/** * @deprecated As of 1.3, method was a leftover of an old implementation */ public void addClassAttributeAlias(String name, Class type) { addClassAlias(name, type); }
/** * Alias a type to a shorter name to be used in XML elements. Any class that is assignable * to this type will be aliased to the same name. * * @param name Short name * @param type Type to be aliased * @since 1.2 * @throws InitializationException if no {@link ClassAliasingMapper} is available */ public void aliasType(String name, Class type) { if (classAliasingMapper == null) { throw new com.thoughtworks.xstream.InitializationException("No " + ClassAliasingMapper.class.getName() + " available"); } classAliasingMapper.addTypeAlias(name, type); }
(ClassAliasingMapper) mapper().lookupMapperOfType(ClassAliasingMapper.class); String elementName = cam.serializedClass(clazz); if (elementName == null) { elementName = cam.serializedClass(item.getClass()); + Arrays.toString(subclasses)); String typeName = cam.serializedClass(theClass); writer.addAttribute("type", typeName);
mapper = new ClassAliasingMapper(mapper); mapper = new ElementIgnoringMapper(mapper); mapper = new FieldAliasingMapper(mapper);
xs.alias("accessInfo", ProcessInfoImpl.class); xs.registerConverter(new NameConverter()); ClassAliasingMapper mapper = new ClassAliasingMapper(xs.getMapper()); mapper.addClassAlias("role", String.class); xs.registerLocalConverter( ProcessGroupInfoImpl.class, "roles", new CollectionConverter(mapper));
public Class realClass(String elementName) { String mappedName = (String) nameToType.get(elementName); if (mappedName != null) { Class type = primitiveClassNamed(mappedName); if (type != null) { return type; } elementName = mappedName; } return super.realClass(elementName); }
private Mapper buildMapper(ClassLoader cl) { // method exists to replace the default Mapper with the ClassLoaderMapper Mapper mapper = new ClassLoaderMapper(registry, cl); // note do not use XStream11XmlFriendlyMapper mapper = new ClassAliasingMapper(mapper); mapper = new FieldAliasingMapper(mapper); mapper = new AttributeAliasingMapper(mapper); mapper = new AttributeMapper(mapper); mapper = new ImplicitCollectionMapper(mapper); mapper = new DynamicProxyMapper(mapper); if (JVM.is15()) { mapper = new EnumMapper(mapper); } mapper = new OuterClassMapper(mapper); mapper = new ArrayMapper(mapper); mapper = new DefaultImplementationsMapper(mapper); mapper = new ImmutableTypesMapper(mapper); mapper = new CachingMapper(mapper); return mapper; }
xStream.alias("synchList", synchronizedListType); ClassAliasingMapper optionsMapper = new ClassAliasingMapper(xStream.getMapper()); optionsMapper.addClassAlias("option", String.class); xStream.registerLocalConverter( AbstractExecutionAdapter.class, ClassAliasingMapper warningsMapper = new ClassAliasingMapper(xStream.getMapper()); warningsMapper.addClassAlias(Level.WARNING.getName(), RuntimeException.class); warningsMapper.addClassAlias(Level.WARNING.getName(), CatalogException.class); xStream.registerLocalConverter( AbstractExecutionAdapter.class, "liFilter", xStream.getMapper(), xStream.getReflectionProvider())); ClassAliasingMapper stepExecutionsMapper = new ClassAliasingMapper(xStream.getMapper()); stepExecutionsMapper.addClassAlias("step", StepExecution.class); xStream.registerLocalConverter( JobExecution.class,
public Class realClass(String elementName) { String mappedName = (String) nameToType.get(elementName); if (mappedName != null) { Class type = primitiveClassNamed(mappedName); if (type != null) { return type; } elementName = mappedName; } return super.realClass(elementName); }
/** * Alias a Class to a shorter name to be used in XML elements. * * @param name Short name * @param type Type to be aliased * @throws InitializationException if no {@link ClassAliasingMapper} is available */ public void alias(String name, Class type) { if (classAliasingMapper == null) { throw new com.thoughtworks.xstream.InitializationException("No " + ClassAliasingMapper.class.getName() + " available"); } classAliasingMapper.addClassAlias(name, type); }
private void processAliasTypeAnnotation(final Class<?> type) { final XStreamAliasType aliasAnnotation = type.getAnnotation(XStreamAliasType.class); if (aliasAnnotation != null) { if (classAliasingMapper == null) { throw new InitializationException("No " + ClassAliasingMapper.class.getName() + " available"); } classAliasingMapper.addTypeAlias(aliasAnnotation.value(), type); } }
mapper = new ClassAliasingMapper(mapper); mapper = new FieldAliasingMapper(mapper); mapper = new AttributeAliasingMapper(mapper);
/** * Returns the name of the items in the list, subclasses can override * @param xp * @return */ protected String getItemName(XStreamPersister xp) { return xp.getClassAliasingMapper().serializedClass( clazz ); }
private void processAliasAnnotation(final Class<?> type, final Set<Class<?>> types) { final XStreamAlias aliasAnnotation = type.getAnnotation(XStreamAlias.class); if (aliasAnnotation != null) { if (classAliasingMapper == null) { throw new InitializationException("No " + ClassAliasingMapper.class.getName() + " available"); } classAliasingMapper.addClassAlias(aliasAnnotation.value(), type); if (aliasAnnotation.impl() != Void.class) { // Alias for Interface/Class with an impl defaultImplementationsMapper.addDefaultImplementation( aliasAnnotation.impl(), type); if (type.isInterface()) { types.add(aliasAnnotation.impl()); // alias Interface's impl } } } }
@Override public void addTypeAlias(final String name, final Class type) { super.addTypeAlias(name, type); if (typeWhitelist != null) { typeWhitelist.allowType(type); } } };
mapper = new ClassAliasingMapper(mapper); mapper = new FieldAliasingMapper(mapper); mapper = new AttributeAliasingMapper(mapper);
protected String getItemName(XStreamPersister xp, Class<?> clazz) { return xp.getClassAliasingMapper().serializedClass(clazz); }
ClassAliasingMapper mapper = new ClassAliasingMapper(xstream.getMapper()); mapper.addClassAlias("tag", String.class); xstream.registerLocalConverter( Test.class, "tags", new CollectionConverter(mapper) );
/** * Alias a type to a shorter name to be used in XML elements. Any class that is assignable to this type will be * aliased to the same name. * * @param name Short name * @param type Type to be aliased * @since 1.2 * @throws InitializationException if no {@link ClassAliasingMapper} is available */ public void aliasType(final String name, final Class<?> type) { if (classAliasingMapper == null) { throw new InitializationException("No " + ClassAliasingMapper.class.getName() + " available"); } classAliasingMapper.addTypeAlias(name, type); }
mapper = new ClassAliasingMapper(mapper); mapper = new FieldAliasingMapper(mapper); mapper = new AttributeAliasingMapper(mapper);