Class RuleMatchesAsJsonSerializer


  • public class RuleMatchesAsJsonSerializer
    extends java.lang.Object
    Write rule matches and some meta information as JSON.
    Since:
    3.4, public since 3.6
    • Field Detail

      • factory

        private static final com.fasterxml.jackson.core.JsonFactory factory
      • compactMode

        private final int compactMode
    • Constructor Detail

      • RuleMatchesAsJsonSerializer

        public RuleMatchesAsJsonSerializer()
      • RuleMatchesAsJsonSerializer

        public RuleMatchesAsJsonSerializer​(int compactMode)
        Since:
        4.7
    • 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. Use null if 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. Use null if 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