Interface Payload

  • All Superinterfaces:
    Comparable<Payload>, Serializable
    All Known Implementing Classes:
    AbstractPayload, DatePayload, IntegerPayload

    public interface Payload
    extends Serializable, Comparable<Payload>
    An index payload.

    The main responsibility of this class is that of providing efficient ways to read and write a payload from and to bit streams. An instance of this class has at any given time a current value, which is set when reading. and output when writing.

    The current value can be modified using set(Object), and each implementation must document thoroughly which objects are accepted by this method.

    It is expected that in most implementations reading and writing is much more efficient than reading, getting a value, setting that value in another instance, and finally writing.

    Implementation of a payload might have parameters. If you need to know whether two instances are compatible, in the sense that each instance can read correctly data written by the other one, you can invoke the compatibleWith(Payload) method.

    Optionally, implementations can feature a parse(String) method that returns an object of the correct type for set(Object). This method can be used (for instance, by reflection) to try to build a payload from a string specification (this is what happens in DocumentIteratorBuilderVisitor).

    • Method Summary

      Modifier and Type Method Description
      boolean compatibleWith​(Payload payload)
      Returns true if this payload instance is compatible with another instance.
      Payload copy()
      Returns a copy of this payload.
      Object get()
      Returns the value of this payload.
      org.apache.commons.collections.Predicate rangeFilter​(Payload left, Payload right)
      Returns a payload filter matching the interval defined by the given parameters.
      int read​(InputBitStream ibs)
      Sets the current value of this payload by reading from an input bit stream.
      void set​(Object o)
      Sets the current value of this payload.
      int write​(OutputBitStream obs)
      Serialises the current value of this payload to the given output bit stream.
    • Method Detail

      • write

        int write​(OutputBitStream obs)
           throws IOException
        Serialises the current value of this payload to the given output bit stream.
        Parameters:
        obs - the bit stream receiving the bits.
        Returns:
        the number of bits written.
        Throws:
        IllegalStateException - if this serialiser contains no object.
        IOException
      • read

        int read​(InputBitStream ibs)
          throws IOException
        Sets the current value of this payload by reading from an input bit stream.
        Parameters:
        ibs - a bit stream.
        Returns:
        the number of bits read.
        Throws:
        IOException
      • get

        Object get()
        Returns the value of this payload.

        Implementing classes are expected to override covariantly the return value to the actual class stored by the payload.

        Returns:
        the current value of this payload.
      • set

        void set​(Object o)
        Sets the current value of this payload.
        Parameters:
        o - the new value of this payload.
      • copy

        Payload copy()
        Returns a copy of this payload.

        Implementing classes are expected to override covariantly the return value to the actual payload type.

        Returns:
        a copy of this payload.
      • compatibleWith

        boolean compatibleWith​(Payload payload)
        Returns true if this payload instance is compatible with another instance.
        Returns:
        true if this payload instance is compatible with another instance.
      • rangeFilter

        org.apache.commons.collections.Predicate rangeFilter​(Payload left,
                                                             Payload right)
        Returns a payload filter matching the interval defined by the given parameters.
        Parameters:
        left - the left extreme of the interval (inclusive). It will be cached (but not copied) internally.
        right - the right extreme of the interval (exclusive). It will be cached (but not copied) internally.
        Returns:
        a payload filter for the interval defined above.