Details

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

      Description

      — From Eric Snell —

      Great product. I don't have time to become a developer right now, but I wanted to make this contribution. I'm using 1.5 and needed an Enum converter. Hope this method helps:

      private void installEnumConverter(XStream stream) {
      final Converter converter = stream.getConverterLookup().lookupConverterForType(Enum.class);
      if (converter.getClass() == ReflectionConverter.class) {
      stream.registerConverter(new Converter() {
      public boolean canConvert(Class type)

      { return (type.isEnum()); }

      public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context)

      { converter.marshal(source, writer, context); }

      public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)

      { Enum rc = (Enum)converter.unmarshal(reader, context); return Enum.valueOf(rc.getDeclaringClass(), rc.name()); }

      });
      }
      }

        People

        • Assignee:
          Unassigned
          Reporter:
          Joe Walnes
        • Votes:
          1 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: