Class SelectedInterval

  • All Implemented Interfaces:
    Serializable, Comparable<SelectedInterval>

    public class SelectedInterval
    extends Object
    implements Comparable<SelectedInterval>, Serializable
    An interval selected for display.

    MG4J uses intervals returned by a DocumentIterator to produce snippet of text that help the user to understand why a document satisfies a query. This class wraps an Interval, adding some information that is useful for displaying the interval itself (e.g., whether the interval is an actual interval satisfying the query or was generated by an IntervalSelector). Whereas the query-solving process uses exclusively Interval (which is on purpose a small, final and very lightweight class), the snippeting process uses exclusively instances of this class.

    See Also:
    Serialized Form
    • Constructor Detail

      • SelectedInterval

        public SelectedInterval​(Interval interval,
                                SelectedInterval.IntervalType type)
        Creates a new selected interval by wrapping a given interval.
        Parameters:
        interval - the underlying interval.
        type - the interval type, or null for a pure wrapper.
    • Method Detail

      • compareTo

        public int compareTo​(SelectedInterval i)
        Compares two selected intervals by their left extremes.
        Specified by:
        compareTo in interface Comparable<SelectedInterval>
        Parameters:
        i - a selected interval.
        Returns:
        the difference between the left extreme this interval and that of i.