XStream
  1. XStream
  2. XSTR-287

XStream.aliasField ignores the alias

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2
    • Component/s: None
    • Labels:
      None

      Description

      The current implementation of the AttributeAliasConverter works only, if the given alias matches the field name:

      public void testWithAliasAndCustomConverter()

      { One one = new One(); one.two = new Two(); one.id = new ID("hullo"); xstream.aliasAttribute("id", ID.class); xstream.registerConverter(new MyIDConverter()); String expected = "<com.thoughtworks.acceptance.AttributeAliasTest-One id=\"hullo\">\n" + " <two/>\n" + "</com.thoughtworks.acceptance.AttributeAliasTest-One>"; assertBothWays(one, expected); }

      Setting

      xstream.aliasAttribute("uid", ID.class);

      showa, that the marshalled XML still just have an "id" attribute instead of the attribute "uid" and additionally will fail with an NPE unmarshalling this XML again. Basically it does make sense to support "XStream.aliasField(ID.class)". In this case the attribute name is always taken from the filed name.

      See also http://thread.gmane.org/gmane.comp.java.xstream.user/1665 for a use case.

        People

        • Assignee:
          Unassigned
          Reporter:
          Jörg Schaible
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: