it.unimi.di.mg4j.query
Class SelectedInterval

java.lang.Object
  extended by it.unimi.di.mg4j.query.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

Nested Class Summary
static class SelectedInterval.IntervalType
          The type of a selected interval, as set by an IntervalSelector.
 
Field Summary
static SelectedInterval[] EMPTY_ARRAY
           
static SelectedInterval[] FALSE_ARRAY
          A marker array used to represent the (absence of) intervals associated with IntervalIterators.FALSE.
 Interval interval
          The underlying interval.
static SelectedInterval[] TRUE_ARRAY
          A marker array used to represent the (absence of) intervals associated with IntervalIterators.TRUE.
 SelectedInterval.IntervalType type
          The interval type, or null for an untyped interval.
 
Constructor Summary
SelectedInterval(Interval interval, SelectedInterval.IntervalType type)
          Creates a new selected interval by wrapping a given interval.
 
Method Summary
 int compareTo(SelectedInterval i)
          Compares two selected intervals by their left extremes.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final SelectedInterval[] EMPTY_ARRAY

TRUE_ARRAY

public static final SelectedInterval[] TRUE_ARRAY
A marker array used to represent the (absence of) intervals associated with IntervalIterators.TRUE.


FALSE_ARRAY

public static final SelectedInterval[] FALSE_ARRAY
A marker array used to represent the (absence of) intervals associated with IntervalIterators.FALSE.


interval

public final Interval interval
The underlying interval.


type

public final SelectedInterval.IntervalType type
The interval type, or null for an untyped interval.

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.

toString

public String toString()
Overrides:
toString in class Object