it.unimi.di.mg4j.query
Class MarkingMutableString

java.lang.Object
  extended by it.unimi.dsi.lang.MutableString
      extended by it.unimi.di.mg4j.query.MarkingMutableString
All Implemented Interfaces:
Serializable, Appendable, CharSequence, Cloneable, Comparable<MutableString>

public class MarkingMutableString
extends MutableString

A mutable string with a special method to append text that should be marked.

A marking mutable string can mark several fields (which will often correspond to indexed fields). Each time you start a field, you pass some intervals to be marked. Then, you call appendAndMark(WordReader), which will add words and nonwords coming from the provided WordReader, marking as suggested by the interval set. The number of words around each interval can be set in the constructor. When a field is finished, you must call endField().

See Also:
Serialized Form

Nested Class Summary
static interface MarkingMutableString.EscapeStrategy
          An escaping strategy.
 
Field Summary
static int DEFAULT_INTERVAL_SURROUND
          The default number of words before and after each interval.
static MarkingMutableString.EscapeStrategy HTML_ESCAPE
          A singleton for the HTML escape strategy.
 boolean marking
           
static MarkingMutableString.EscapeStrategy NULL_ESCAPE
          A singleton for the null escape strategy (which does nothing).
 boolean resume
           
 
Fields inherited from class it.unimi.dsi.lang.MutableString
array, hashLength
 
Constructor Summary
MarkingMutableString(Marker marker)
          Creates a new loose empty marking mutable string with default interval surround, no escaping strategy and no term processor.
MarkingMutableString(Marker marker, MarkingMutableString.EscapeStrategy escapeStrategy)
          Creates a new loose empty marking mutable string default interval surround.
MarkingMutableString(Marker marker, MarkingMutableString.EscapeStrategy escapeStrategy, int intervalSurround)
          Creates a new loose empty marking mutable string.
 
Method Summary
 MarkingMutableString appendAndMark(MutableString s)
           
 MarkingMutableString appendAndMark(String s)
           
 MarkingMutableString appendAndMark(WordReader wordReader)
           
 MarkingMutableString endField()
          Closes the current field.
 MarkingMutableString startField(SelectedInterval[] interval)
          Prepares this marking mutable string for a new field.
 
Methods inherited from class it.unimi.dsi.lang.MutableString
append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, array, capacity, changed, charAt, charAt, clone, compact, compareTo, compareTo, compareTo, compareToIgnoreCase, compareToIgnoreCase, compareToIgnoreCase, copy, cospan, cospan, cospan, cospan, delete, delete, delete, delete, deleteCharAt, endsWith, endsWith, endsWith, endsWithIgnoreCase, endsWithIgnoreCase, endsWithIgnoreCase, ensureCapacity, equals, equals, equals, equals, equalsIgnoreCase, equalsIgnoreCase, equalsIgnoreCase, firstChar, getChars, getChars, hashCode, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOfAnyBut, indexOfAnyBut, indexOfAnyBut, indexOfAnyBut, indexOfAnyOf, indexOfAnyOf, indexOfAnyOf, indexOfAnyOf, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, isCompact, isLoose, lastChar, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOfAnyBut, lastIndexOfAnyBut, lastIndexOfAnyBut, lastIndexOfAnyBut, lastIndexOfAnyOf, lastIndexOfAnyOf, lastIndexOfAnyOf, lastIndexOfAnyOf, length, length, loose, print, print, println, println, read, readSelfDelimUTF8, readSelfDelimUTF8, readUTF8, readUTF8, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, reverse, setCharAt, setLength, skipSelfDelimUTF8, span, span, span, span, squeezeSpace, squeezeSpaces, squeezeWhitespace, startsWith, startsWith, startsWith, startsWithIgnoreCase, startsWithIgnoreCase, startsWithIgnoreCase, subSequence, substring, substring, toCharArray, toLowerCase, toString, toUpperCase, trim, trimLeft, trimRight, wrap, wrap, write, writeSelfDelimUTF8, writeSelfDelimUTF8, writeUTF8, writeUTF8
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_INTERVAL_SURROUND

public static final int DEFAULT_INTERVAL_SURROUND
The default number of words before and after each interval.

See Also:
Constant Field Values

resume

public boolean resume

marking

public boolean marking

NULL_ESCAPE

public static final MarkingMutableString.EscapeStrategy NULL_ESCAPE
A singleton for the null escape strategy (which does nothing).


HTML_ESCAPE

public static final MarkingMutableString.EscapeStrategy HTML_ESCAPE
A singleton for the HTML escape strategy.

Constructor Detail

MarkingMutableString

public MarkingMutableString(Marker marker,
                            MarkingMutableString.EscapeStrategy escapeStrategy,
                            int intervalSurround)
Creates a new loose empty marking mutable string.

Parameters:
marker - a marker that will decide how to highlight intervals.
escapeStrategy - the escape strategy for strings passed to appendAndMark(WordReader), or null.
intervalSurround - the number of words printed before and after each interval.

MarkingMutableString

public MarkingMutableString(Marker marker,
                            MarkingMutableString.EscapeStrategy escapeStrategy)
Creates a new loose empty marking mutable string default interval surround.

Parameters:
marker - a marker that will decide how to highlight intervals.
escapeStrategy - the escape strategy for strings passed to appendAndMark(WordReader), or null.

MarkingMutableString

public MarkingMutableString(Marker marker)
Creates a new loose empty marking mutable string with default interval surround, no escaping strategy and no term processor.

Parameters:
marker - a marker that will decide how to highlight intervals.
Method Detail

startField

public MarkingMutableString startField(SelectedInterval[] interval)
Prepares this marking mutable string for a new field. We append TextMarker.startOfField(), the interval marking state is reset and the intervals for marking are set to interval.

Parameters:
interval - the new selected-interval array for marking.

endField

public MarkingMutableString endField()
Closes the current field. The value of TextMarker.startOfField() is appended to the string.


appendAndMark

public MarkingMutableString appendAndMark(String s)

appendAndMark

public MarkingMutableString appendAndMark(MutableString s)

appendAndMark

public MarkingMutableString appendAndMark(WordReader wordReader)