Package it.unimi.di.big.mg4j.query
Class MarkingMutableString
- java.lang.Object
-
- it.unimi.dsi.lang.MutableString
-
- it.unimi.di.big.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 providedWordReader
, 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 callendField()
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
MarkingMutableString.EscapeStrategy
An escaping strategy.
-
Field Summary
Fields Modifier and Type Field Description 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
Constructors Constructor Description 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
Modifier and Type Method Description MarkingMutableString
appendAndMark(WordReader wordReader)
MarkingMutableString
appendAndMark(MutableString s)
MarkingMutableString
appendAndMark(String s)
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, isEmpty, 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
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
-
-
-
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 toappendAndMark(WordReader)
, ornull
.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 toappendAndMark(WordReader)
, ornull
.
-
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 appendTextMarker.startOfField()
, the interval marking state is reset and the intervals for marking are set tointerval
.- Parameters:
interval
- the new selected-interval array for marking.
-
endField
public MarkingMutableString endField()
Closes the current field. The value ofTextMarker.startOfField()
is appended to the string.
-
appendAndMark
public MarkingMutableString appendAndMark(String s)
-
appendAndMark
public MarkingMutableString appendAndMark(MutableString s)
-
appendAndMark
public MarkingMutableString appendAndMark(WordReader wordReader)
-
-