Package org.languagetool.tools
Class RuleMatchesAsJsonSerializer
- java.lang.Object
-
- org.languagetool.tools.RuleMatchesAsJsonSerializer
-
public class RuleMatchesAsJsonSerializer extends java.lang.ObjectWrite rule matches and some meta information as JSON.- Since:
- 3.4, public since 3.6
-
-
Field Summary
Fields Modifier and Type Field Description private static intAPI_VERSIONprivate intcompactModeprivate static com.fasterxml.jackson.core.JsonFactoryfactoryprivate static java.lang.StringPREMIUM_HINTprivate static java.lang.StringSTART_MARKERprivate static java.lang.StringSTATUS
-
Constructor Summary
Constructors Constructor Description RuleMatchesAsJsonSerializer()RuleMatchesAsJsonSerializer(int compactMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringcleanSuggestion(java.lang.String s)java.lang.StringruleMatchesToJson(java.util.List<RuleMatch> matches, java.lang.String text, int contextSize, DetectedLanguage detectedLang)java.lang.StringruleMatchesToJson(java.util.List<RuleMatch> matches, java.util.List<RuleMatch> hiddenMatches, java.lang.String text, int contextSize, DetectedLanguage detectedLang, java.lang.String incompleteResultsReason)java.lang.StringruleMatchesToJson(java.util.List<RuleMatch> matches, java.util.List<RuleMatch> hiddenMatches, AnnotatedText text, int contextSize, DetectedLanguage detectedLang, java.lang.String incompleteResultsReason)private voidwriteCategory(com.fasterxml.jackson.core.JsonGenerator g, Category category)private voidwriteContext(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match, AnnotatedText text, ContextTools contextTools)private voidwriteLanguageSection(com.fasterxml.jackson.core.JsonGenerator g, DetectedLanguage detectedLang)private voidwriteMatchesSection(java.lang.String sectionName, com.fasterxml.jackson.core.JsonGenerator g, java.util.List<RuleMatch> matches, AnnotatedText text, ContextTools contextTools)private voidwriteReplacements(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match)private voidwriteRule(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match)private voidwriteSoftwareSection(com.fasterxml.jackson.core.JsonGenerator g)private voidwriteWarningsSection(com.fasterxml.jackson.core.JsonGenerator g, java.lang.String incompleteResultsReason)
-
-
-
Field Detail
-
API_VERSION
private static final int API_VERSION
- See Also:
- Constant Field Values
-
STATUS
private static final java.lang.String STATUS
- See Also:
- Constant Field Values
-
PREMIUM_HINT
private static final java.lang.String PREMIUM_HINT
- See Also:
- Constant Field Values
-
START_MARKER
private static final java.lang.String START_MARKER
- See Also:
- Constant Field Values
-
factory
private static final com.fasterxml.jackson.core.JsonFactory factory
-
compactMode
private final int compactMode
-
-
Method Detail
-
ruleMatchesToJson
public java.lang.String ruleMatchesToJson(java.util.List<RuleMatch> matches, java.lang.String text, int contextSize, DetectedLanguage detectedLang)
-
ruleMatchesToJson
public java.lang.String ruleMatchesToJson(java.util.List<RuleMatch> matches, java.util.List<RuleMatch> hiddenMatches, java.lang.String text, int contextSize, DetectedLanguage detectedLang, java.lang.String incompleteResultsReason)
- Parameters:
incompleteResultsReason- use a string that explains why results are incomplete (e.g. due to a timeout) - a 'warnings' section will be added to the JSON. Usenullif results are complete.- Since:
- 3.7
-
ruleMatchesToJson
public java.lang.String ruleMatchesToJson(java.util.List<RuleMatch> matches, java.util.List<RuleMatch> hiddenMatches, AnnotatedText text, int contextSize, DetectedLanguage detectedLang, java.lang.String incompleteResultsReason)
- Parameters:
incompleteResultsReason- use a string that explains why results are incomplete (e.g. due to a timeout) - a 'warnings' section will be added to the JSON. Usenullif results are complete.- Since:
- 4.3
-
writeSoftwareSection
private void writeSoftwareSection(com.fasterxml.jackson.core.JsonGenerator g) throws java.io.IOException- Throws:
java.io.IOException
-
writeWarningsSection
private void writeWarningsSection(com.fasterxml.jackson.core.JsonGenerator g, java.lang.String incompleteResultsReason) throws java.io.IOException- Throws:
java.io.IOException
-
writeLanguageSection
private void writeLanguageSection(com.fasterxml.jackson.core.JsonGenerator g, DetectedLanguage detectedLang) throws java.io.IOException- Throws:
java.io.IOException
-
writeMatchesSection
private void writeMatchesSection(java.lang.String sectionName, com.fasterxml.jackson.core.JsonGenerator g, java.util.List<RuleMatch> matches, AnnotatedText text, ContextTools contextTools) throws java.io.IOException- Throws:
java.io.IOException
-
cleanSuggestion
private java.lang.String cleanSuggestion(java.lang.String s)
-
writeReplacements
private void writeReplacements(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match) throws java.io.IOException- Throws:
java.io.IOException
-
writeContext
private void writeContext(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match, AnnotatedText text, ContextTools contextTools) throws java.io.IOException- Throws:
java.io.IOException
-
writeRule
private void writeRule(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match) throws java.io.IOException- Throws:
java.io.IOException
-
writeCategory
private void writeCategory(com.fasterxml.jackson.core.JsonGenerator g, Category category) throws java.io.IOException- Throws:
java.io.IOException
-
-