Class TextTagParser


  • public final class TextTagParser
    extends java.lang.Object
    Class that helps to parse tags from arbitrary text
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  TextTagParser.TagWarningCallback
      Called when a problematic tag is encountered.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private TextTagParser()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.String> getValidatedTagsFromText​(java.lang.String buf, TextTagParser.TagWarningCallback callback)
      Gets a list of tags that are in the given text
      static java.util.Map<java.lang.String,​java.lang.String> readTagsByRegexp​(java.lang.String text, java.lang.String splitRegex, java.lang.String tagRegex, boolean unescapeTextInQuotes)
      Try to find tag-value pairs in given text
      static java.util.Map<java.lang.String,​java.lang.String> readTagsFromText​(java.lang.String buf)
      Apply different methods to extract tag-value pairs from arbitrary text
      (package private) static java.lang.String unescape​(java.lang.String k)  
      static boolean validateTags​(java.util.Map<java.lang.String,​java.lang.String> tags, TextTagParser.TagWarningCallback callback)
      Check tags for correctness and display warnings if needed
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • unescape

        static java.lang.String unescape​(java.lang.String k)
      • readTagsByRegexp

        public static java.util.Map<java.lang.String,​java.lang.String> readTagsByRegexp​(java.lang.String text,
                                                                                              java.lang.String splitRegex,
                                                                                              java.lang.String tagRegex,
                                                                                              boolean unescapeTextInQuotes)
        Try to find tag-value pairs in given text
        Parameters:
        text - - text in which tags are looked for
        splitRegex - - text is split into parts with this delimiter
        tagRegex - - each part is matched against this regex
        unescapeTextInQuotes - - if true, matched tag and value will be analyzed more thoroughly
        Returns:
        map of tags
      • getValidatedTagsFromText

        public static java.util.Map<java.lang.String,​java.lang.String> getValidatedTagsFromText​(java.lang.String buf,
                                                                                                      TextTagParser.TagWarningCallback callback)
        Gets a list of tags that are in the given text
        Parameters:
        buf - The text to parse
        callback - warning callback
        Returns:
        The tags or null if the tags are not valid
        Since:
        12683
      • readTagsFromText

        public static java.util.Map<java.lang.String,​java.lang.String> readTagsFromText​(java.lang.String buf)
        Apply different methods to extract tag-value pairs from arbitrary text
        Parameters:
        buf - buffer
        Returns:
        null if no format is suitable
      • validateTags

        public static boolean validateTags​(java.util.Map<java.lang.String,​java.lang.String> tags,
                                           TextTagParser.TagWarningCallback callback)
        Check tags for correctness and display warnings if needed
        Parameters:
        tags - - map key → value to check
        callback - warning callback
        Returns:
        true if the tags should be pasted
        Since:
        12683