XStream
  1. XStream
  2. XSTR-675

Extend StreamReader interface with peekNextChild method

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.2
    • Component/s: Core, IO
    • Labels:
      None

      Description

      It would be great to have methods, that peeks the tag name of the child in situations where StreamReader#hasMoreChildren() returns true. I have attached patch with complete implementation of my proposal.
      May be there is a workaround, which can help to do the same without applying this patch
      Thanks for help.

        Issue Links

          Activity

          Hide
          Jörg Schaible added a comment -

          Hi Nikita,

          my first reaction was: Ahh, no, this is not possible. XStream has a stream-based model and therefore ... blah, blah. However, looking at the patch I realized that the different streaming readers already read one element ahead - it's just not exposed. Boy, that reader code was written before my time

          Now, after playing a bit with enhanced unit tests and fixing some stuff, I have it running. The problem is, that we cannot simply extend the HierarchicalStreamReader without seriously breaking backwards compatibility. All that currently comes to my mind is:

          interface ExtendedHierarchicalStreamReader extends HierarchicalStreamReader {
          String peekNextChild();
          }
          

          XStream's own reader implementations would implement this, but you would have to cast the provided reader in the converters yourself. Unfortunately this implies also that we cannot use it in our own converters for now (TreeSetConverter/TreeMapConverter). Any other idea?

          Show
          Jörg Schaible added a comment - Hi Nikita, my first reaction was: Ahh, no, this is not possible. XStream has a stream-based model and therefore ... blah, blah. However, looking at the patch I realized that the different streaming readers already read one element ahead - it's just not exposed. Boy, that reader code was written before my time Now, after playing a bit with enhanced unit tests and fixing some stuff, I have it running. The problem is, that we cannot simply extend the HierarchicalStreamReader without seriously breaking backwards compatibility. All that currently comes to my mind is: interface ExtendedHierarchicalStreamReader extends HierarchicalStreamReader { String peekNextChild(); } XStream's own reader implementations would implement this, but you would have to cast the provided reader in the converters yourself. Unfortunately this implies also that we cannot use it in our own converters for now (TreeSetConverter/TreeMapConverter). Any other idea?
          Hide
          Jörg Schaible added a comment -

          Added in HEAD with extended interface as proposed.

          Show
          Jörg Schaible added a comment - Added in HEAD with extended interface as proposed.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: