/** * Create an alias for a field name. * * @param alias the alias itself * @param definedIn the type that declares the field * @param fieldName the name of the field * @throws InitializationException if no {@link FieldAliasingMapper} is available */ public void aliasField(String alias, Class definedIn, String fieldName) { if (fieldAliasingMapper == null) { throw new com.thoughtworks.xstream.InitializationException("No " + FieldAliasingMapper.class.getName() + " available"); } fieldAliasingMapper.addFieldAlias(alias, definedIn, fieldName); }
public String serializedMember(Class type, String memberName) { String alias = getMember(type, memberName, fieldToAliasMap); if (alias == null) { return super.serializedMember(type, memberName); } else { return alias; } }
mapper = new ClassAliasingMapper(mapper); mapper = new ElementIgnoringMapper(mapper); mapper = new FieldAliasingMapper(mapper); mapper = new AttributeAliasingMapper(mapper); mapper = new SystemAttributeAliasingMapper(mapper);
private void processOmitFieldAnnotation(final Field field) { final XStreamOmitField omitFieldAnnotation = field .getAnnotation(XStreamOmitField.class); if (omitFieldAnnotation != null) { if (fieldAliasingMapper == null) { throw new InitializationException("No " + FieldAliasingMapper.class.getName() + " available"); } fieldAliasingMapper.omitField(field.getDeclaringClass(), field.getName()); } }
public FieldAliasingMapper(Mapper wrapped) { super(wrapped); elementIgnoringMapper = (ElementIgnoringMapper)lookupMapperOfType(ElementIgnoringMapper.class); }
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; }
private void processOmitFieldAnnotation(final Field field) { final XStreamOmitField omitFieldAnnotation = field .getAnnotation(XStreamOmitField.class); if (omitFieldAnnotation != null) { if (fieldAliasingMapper == null) { throw new InitializationException("No " + FieldAliasingMapper.class.getName() + " available"); } fieldAliasingMapper.omitField(field.getDeclaringClass(), field.getName()); } }
public FieldAliasingMapper(Mapper wrapped) { super(wrapped); elementIgnoringMapper = (ElementIgnoringMapper)lookupMapperOfType(ElementIgnoringMapper.class); }
private String getMember(Class type, String name, Map map) { String member = null; for (Class declaringType = type; member == null && declaringType != Object.class && declaringType != null; declaringType = declaringType.getSuperclass()) { member = (String) map.get(key(declaringType, name)); } return member; } }
private void processFieldAliasAnnotation(final Field field) { final XStreamAlias aliasAnnotation = field.getAnnotation(XStreamAlias.class); if (aliasAnnotation != null) { if (fieldAliasingMapper == null) { throw new InitializationException("No " + FieldAliasingMapper.class.getName() + " available"); } fieldAliasingMapper.addFieldAlias( aliasAnnotation.value(), field.getDeclaringClass(), field.getName()); } }
public String realMember(Class type, String serialized) { String real = getMember(type, serialized, aliasToFieldMap); if (real == null) { return super.realMember(type, serialized); } else { return real; } }
mapper = new PackageAliasingMapper(mapper); mapper = new ClassAliasingMapper(mapper); mapper = new FieldAliasingMapper(mapper); mapper = new AttributeAliasingMapper(mapper); mapper = new SystemAttributeAliasingMapper(mapper);
private void processOmitFieldAnnotation(final Field field) { final XStreamOmitField omitFieldAnnotation = field .getAnnotation(XStreamOmitField.class); if (omitFieldAnnotation != null) { if (fieldAliasingMapper == null) { throw new InitializationException("No " + FieldAliasingMapper.class.getName() + " available"); } fieldAliasingMapper.omitField(field.getDeclaringClass(), field.getName()); } }
public FieldAliasingMapper(Mapper wrapped) { super(wrapped); elementIgnoringMapper = (ElementIgnoringMapper)lookupMapperOfType(ElementIgnoringMapper.class); }
@Override public void addFieldAlias(final String alias, final Class type, final String fieldName) { super.addFieldAlias(alias, type, fieldName); if (typeWhitelist != null) { typeWhitelist.allowType(type); } } };
public String serializedMember(Class type, String memberName) { String alias = getMember(type, memberName, fieldToAliasMap); if (alias == null) { return super.serializedMember(type, memberName); } else { return alias; } }
mapper = new PackageAliasingMapper(mapper); mapper = new ClassAliasingMapper(mapper); mapper = new FieldAliasingMapper(mapper); mapper = new AttributeAliasingMapper(mapper); mapper = new SystemAttributeAliasingMapper(mapper);
private void processOmitFieldAnnotation(final Field field) { final XStreamOmitField omitFieldAnnotation = field .getAnnotation(XStreamOmitField.class); if (omitFieldAnnotation != null) { if (fieldAliasingMapper == null) { throw new InitializationException("No " + FieldAliasingMapper.class.getName() + " available"); } fieldAliasingMapper.omitField(field.getDeclaringClass(), field.getName()); } }