XStream
  1. XStream
  2. XSTR-69

make ReflectionConverter subclassable

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2
    • Component/s: Converters
    • Labels:
      None

      Description

      We've found it convenient to subclass ReflectionConverter to make changes to how some fields are marshalled and unmarshalled, while still using the default behavior for fields that don't need to be handled specially. However, it's not designed to be subclassed, so we ended up copying it into our code base.

      After refactoring, here are the methods we found useful to override in the subclass. (I'm going by memory so this might not be slightly inaccurate.)

      marshal(...)

      visitFieldWhileMarshalling(Object source, HierarchicalStreamWriter writer,
      MarshallingContext context,
      String fieldName, Class fieldType, Object fieldValue)

      unmarshal(...)

      getFieldType(String xmlName)

      visitFieldWhileUnmarshalling(Object result, Class fieldType,
      String fieldName, Object fieldValue)

      Also, we used these new methods but didn't need to override them:

      writeXMLField(HierarchicalStreamWriter writer.
      MarshallingContext context,
      String fieldName, Object fieldValue)

      readObjectField(Object source, String fieldName)
      writeObjectField(Object dest, String fieldName, Object value)

        People

        • Assignee:
          Unassigned
          Reporter:
          Brian Slesinsky
        • Votes:
          3 Vote for this issue
          Watchers:
          2 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: