Package org.languagetool.tools
Class ContextTools
java.lang.Object
org.languagetool.tools.ContextTools
Helper class to mark errors in text.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetContext
(int fromPos, int toPos, String contents) private StringBuilder
getMarker
(int fromPos, int toPos, int textLength) getPlainTextContext
(int fromPos, int toPos, String contents) Get a plain text context that uses^
characters in a new line as a marker of the given string region.void
setContextSize
(int contextSize) The context size of the error.void
setErrorMarkerEnd
(String errorMarkerEnd) Set the string used to mark the end of an error, e.g.void
setErrorMarkerStart
(String errorMarkerStart) Set the string used to mark the beginning of an error, e.g.void
setEscapeHtml
(boolean escapeHtml) Whether HTML special characters should be escaped.
-
Field Details
-
contextSize
private int contextSize -
escapeHtml
private boolean escapeHtml -
errorMarkerStart
-
errorMarkerEnd
-
-
Constructor Details
-
ContextTools
public ContextTools()
-
-
Method Details
-
getContext
-
getPlainTextContext
Get a plain text context that uses^
characters in a new line as a marker of the given string region. IgnoressetEscapeHtml(boolean)
.- Since:
- 2.3
-
setErrorMarkerStart
Set the string used to mark the beginning of an error, e.g.<span class="error">
-
setErrorMarkerEnd
Set the string used to mark the end of an error, e.g.</span>
-
setContextSize
public void setContextSize(int contextSize) The context size of the error. This many characters of the original text will be used from the left and from the right context of the error. -
setEscapeHtml
public void setEscapeHtml(boolean escapeHtml) Whether HTML special characters should be escaped. -
getMarker
-