public String aliasForAttribute(String attribute) { return delegate.aliasForAttribute(attribute); }
/** * @deprecated since 1.3, use combination of {@link #serializedMember(Class, String)} and {@link #getConverterFromItemType(String, Class, Class)} */ @Deprecated public String aliasForAttribute(Class definedIn, String fieldName) { return delegate.aliasForAttribute(definedIn, fieldName); }
/** * @deprecated As of 1.3, use combination of {@link #serializedMember(Class, String)} and * {@link #getConverterFromItemType(String, Class, Class)} */ public String aliasForAttribute(Class definedIn, String fieldName) { return aliasForAttributeMapper.aliasForAttribute(definedIn, fieldName); }
public String aliasForAttribute(String attribute) { return aliasForAttributeMapper.aliasForAttribute(attribute); }
private Class determineWhichClassDefinesField(HierarchicalStreamReader reader) { String definedIn = reader.getAttribute(mapper.aliasForAttribute("defined-in")); return definedIn == null ? null : mapper.realClass(definedIn); }
public void marshal(Object original, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Object source = serializationMethodInvoker.callWriteReplace(original); if (source.getClass() != original.getClass()) { writer.addAttribute(mapper.aliasForAttribute("resolves-to"), mapper.serializedClass(source.getClass())); } OwnerContext oc = OwnerContext.find(context); oc.startVisiting(writer, classOwnership.ownerOf(original.getClass())); try { doMarshal(source, writer, context); } finally { oc.stopVisiting(); } }
protected Object instantiateNewInstance(HierarchicalStreamReader reader, UnmarshallingContext context) { String readResolveValue = reader.getAttribute(mapper.aliasForAttribute("resolves-to")); Class type = readResolveValue != null ? mapper.realClass(readResolveValue) : context.getRequiredType(); Object currentObject = context.currentObject(); if (currentObject != null) { if (type.isInstance(currentObject)) return currentObject; } return reflectionProvider.newInstance(type); }
public void visit(String fieldName, Class type, Class definedIn, Object value) { SingleValueConverter converter = mapper.getConverterFromItemType(fieldName, type, definedIn); if (converter == null) converter = mapper.getConverterFromItemType(fieldName, type); if (converter == null) converter = mapper.getConverterFromItemType(type); if (converter != null) { if (value != null) { final String str = converter.toString(value); if (str != null) { writer.addAttribute(mapper.aliasForAttribute(fieldName), str); } } seenAsAttributes.add(fieldName); } } });
private Class determineType(HierarchicalStreamReader reader, boolean validField, Object result, String fieldName, Class definedInCls) { String classAttribute = reader.getAttribute(mapper.aliasForAttribute("class")); Class fieldType = reflectionProvider.getFieldType(result, fieldName, definedInCls); if (classAttribute != null) { Class specifiedType = mapper.realClass(classAttribute); if(fieldType.isAssignableFrom(specifiedType)) // make sure that the specified type in XML is compatible with the field type. // this allows the code to evolve in more flexible way. return specifiedType; } if (!validField) { Class itemType = mapper.getItemTypeForItemFieldName(result.getClass(), fieldName); if (itemType != null) { return itemType; } else { return mapper.realClass(reader.getNodeName()); } } else { return mapper.defaultImplementationOf(fieldType); } }
private void writeField(String fieldName, String aliasName, Class fieldType, Class definedIn, Object newObj) { try { if (!mapper.shouldSerializeMember(definedIn, aliasName)) { return; } ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(definedIn, aliasName), fieldType); Class actualType = newObj.getClass(); Class defaultType = mapper.defaultImplementationOf(fieldType); if (!actualType.equals(defaultType)) { String serializedClassName = mapper.serializedClass(actualType); if (!serializedClassName.equals(mapper.serializedClass(defaultType))) { writer.addAttribute(mapper.aliasForSystemAttribute("class"), serializedClassName); } } if (seenFields.contains(aliasName)) { writer.addAttribute(mapper.aliasForAttribute("defined-in"), mapper.serializedClass(definedIn)); } Field field = reflectionProvider.getField(definedIn,fieldName); marshallField(context, newObj, field); writer.endNode(); } catch (RuntimeException e) { // intercept an exception so that the stack trace shows how we end up marshalling the object in question throw new RuntimeException("Failed to serialize "+definedIn.getName()+"#"+fieldName+" for "+source.getClass(),e); } }
fieldName, type, definedIn); if (converter != null) { final String attribute = mapper.aliasForAttribute(mapper.serializedMember( definedIn, fieldName)); if (value != null) {
/** * @deprecated As of 1.3, use combination of {@link #serializedMember(Class, String)} and * {@link #getConverterFromItemType(String, Class, Class)} */ public String aliasForAttribute(Class definedIn, String fieldName) { return aliasForAttributeMapper.aliasForAttribute(definedIn, fieldName); }
/** * @deprecated As of 1.3, use combination of {@link #serializedMember(Class, String)} and {@link #getConverterFromItemType(String, Class, Class)} */ public String aliasForAttribute(Class definedIn, String fieldName) { return wrapped.aliasForAttribute(definedIn, fieldName); }
/** * @deprecated As of 1.3, use combination of {@link #serializedMember(Class, String)} and {@link #getConverterFromItemType(String, Class, Class)} */ public String aliasForAttribute(Class definedIn, String fieldName) { return wrapped.aliasForAttribute(definedIn, fieldName); }
/** * @deprecated since 1.3, use combination of {@link #serializedMember(Class, String)} and {@link #getConverterFromItemType(String, Class, Class)} */ @Deprecated public String aliasForAttribute(Class definedIn, String fieldName) { return delegate.aliasForAttribute(definedIn, fieldName); }
public void marshal(Object original, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Object source = serializationMethodInvoker.callWriteReplace(original); if (source.getClass() != original.getClass()) { writer.addAttribute(mapper.aliasForAttribute("resolves-to"), mapper.serializedClass(source.getClass())); } doMarshal(source, writer, context); }
public void marshal(Object original, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Object source = serializationMethodInvoker.callWriteReplace(original); if (source.getClass() != original.getClass()) { writer.addAttribute(mapper.aliasForAttribute("resolves-to"), mapper.serializedClass(source.getClass())); } doMarshal(source, writer, context); }
protected Object instantiateNewInstance(HierarchicalStreamReader reader, UnmarshallingContext context) { String readResolveValue = reader.getAttribute(mapper.aliasForAttribute("resolves-to")); Class type = readResolveValue != null ? mapper.realClass(readResolveValue) : context.getRequiredType(); Object currentObject = context.currentObject(); if (currentObject != null) { if (type.isInstance(currentObject)) return currentObject; } return reflectionProvider.newInstance(type); }
protected Object instantiateNewInstance(HierarchicalStreamReader reader, UnmarshallingContext context) { String readResolveValue = reader.getAttribute(mapper.aliasForAttribute("resolves-to")); Class type = readResolveValue != null ? mapper.realClass(readResolveValue) : context.getRequiredType(); Object currentObject = context.currentObject(); if (currentObject != null) { if (type.isInstance(currentObject)) return currentObject; } return reflectionProvider.newInstance(type); }
protected Object instantiateNewInstance(HierarchicalStreamReader reader, UnmarshallingContext context) { String readResolveValue = reader.getAttribute(mapper.aliasForAttribute("resolves-to")); Class type = readResolveValue != null ? mapper.realClass(readResolveValue) : context.getRequiredType(); Object currentObject = context.currentObject(); if (currentObject != null) { if (type.isInstance(currentObject)) return currentObject; } return reflectionProvider.newInstance(type); }