Class TextTagParser

java.lang.Object
org.openstreetmap.josm.tools.TextTagParser

public final class TextTagParser extends Object
Class that helps to parse tags from arbitrary text
  • Field Details

  • Constructor Details

  • Method Details

    • unescape

      static String unescape(String k)
    • readTagsByRegexp

      public static Map<String,String> readTagsByRegexp(String text, String splitRegex, String tagRegex, boolean unescapeTextInQuotes, boolean unescapePipe)
      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
      unescapePipe - - if true, then replace all '\|' by '|' (issue #14490)
      Returns:
      map of tags
      Since:
      19571 (parameter unescapePipe added)
    • getValidatedTagsFromText

      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 Map<String,String> readTagsFromText(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(Map<String,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