Class MergedResultObjectProvider

  • All Implemented Interfaces:
    ResultObjectProvider, Closeable
    Direct Known Subclasses:
    OrderingMergedResultObjectProvider

    public class MergedResultObjectProvider
    extends java.lang.Object
    implements ResultObjectProvider
    A result object provider that merges multiple result object provider delegates. Support exists for maintaining ordering of the internally held results, provided that each of the individual results is itself ordered.
    Author:
    Abe White, Marc Prud'hommeaux
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean absolute​(int pos)
      Move to the given 0-based position.
      void close()
      Free the resources associated with this provider.
      protected java.lang.Object getOrderingValue​(java.lang.Object val, int idx, ResultObjectProvider rop)
      Return the value to use for ordering on the given result value.
      java.lang.Object getResultObject()
      Instantiate the current result object.
      void handleCheckedException​(java.lang.Exception e)
      Any checked exceptions that are thrown will be passed to this method.
      boolean next()
      Advance the input to the next position.
      void open()
      Open the result.
      void reset()
      Reset this provider.
      int size()
      Return the number of items in the input, or Integer.MAX_VALUE if the size in unknown.
      boolean supportsRandomAccess()
      Return true if this provider supports random access.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MergedResultObjectProvider

        public MergedResultObjectProvider​(ResultObjectProvider[] rops)
        Constructor. Provide delegates.
      • MergedResultObjectProvider

        public MergedResultObjectProvider​(ResultObjectProvider[] rops,
                                          java.util.Comparator comp)
        Constructor. Provide delegates and optional comparator.
    • Method Detail

      • absolute

        public boolean absolute​(int pos)
                         throws java.lang.Exception
        Description copied from interface: ResultObjectProvider
        Move to the given 0-based position. This method is only called for providers that support random access. Return true if there is data at this position; otherwise false. This may be invoked in place of ResultObjectProvider.next().
        Specified by:
        absolute in interface ResultObjectProvider
        Throws:
        java.lang.Exception
      • size

        public int size()
                 throws java.lang.Exception
        Description copied from interface: ResultObjectProvider
        Return the number of items in the input, or Integer.MAX_VALUE if the size in unknown.
        Specified by:
        size in interface ResultObjectProvider
        Throws:
        java.lang.Exception
      • reset

        public void reset()
                   throws java.lang.Exception
        Description copied from interface: ResultObjectProvider
        Reset this provider. This is an optional operation. If supported, it should move the position of the provider to before the first element. Non-random-access providers may be able to support this method by re-acquiring all resources as if the result were just opened.
        Specified by:
        reset in interface ResultObjectProvider
        Throws:
        java.lang.Exception
      • handleCheckedException

        public void handleCheckedException​(java.lang.Exception e)
        Description copied from interface: ResultObjectProvider
        Any checked exceptions that are thrown will be passed to this method. The provider should re-throw the exception as an appropriate unchecked exception.
        Specified by:
        handleCheckedException in interface ResultObjectProvider
      • next

        public boolean next()
                     throws java.lang.Exception
        Description copied from interface: ResultObjectProvider
        Advance the input to the next position. Return true if there is more data; otherwise false.
        Specified by:
        next in interface ResultObjectProvider
        Throws:
        java.lang.Exception
      • getOrderingValue

        protected java.lang.Object getOrderingValue​(java.lang.Object val,
                                                    int idx,
                                                    ResultObjectProvider rop)
        Return the value to use for ordering on the given result value. Returns the result value by default.
        Parameters:
        val - the result value
        idx - the index of the result object provider in the array given on construction that produced the result value
        rop - the result object provider that produced the result value