Package org.openstreetmap.josm.tools
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TextTagParser.TagWarningCallback
Called when a problematic tag is encountered.
-
Field Summary
Fields Modifier and Type Field Description private static String
KEY_PATTERN
private static int
MAX_KEY_COUNT
private static int
MAX_KEY_LENGTH
private static int
MAX_VALUE_LENGTH
-
Constructor Summary
Constructors Modifier Constructor Description private
TextTagParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,String>
getValidatedTagsFromText(String buf, TextTagParser.TagWarningCallback callback)
Gets a list of tags that are in the given textstatic Map<String,String>
readTagsByRegexp(String text, String splitRegex, String tagRegex, boolean unescapeTextInQuotes)
Try to find tag-value pairs in given textstatic Map<String,String>
readTagsFromText(String buf)
Apply different methods to extract tag-value pairs from arbitrary text(package private) static String
unescape(String k)
static boolean
validateTags(Map<String,String> tags, TextTagParser.TagWarningCallback callback)
Check tags for correctness and display warnings if needed
-
-
-
Field Detail
-
MAX_KEY_LENGTH
private static final int MAX_KEY_LENGTH
-
MAX_KEY_COUNT
private static final int MAX_KEY_COUNT
-
KEY_PATTERN
private static final String KEY_PATTERN
-
MAX_VALUE_LENGTH
private static final int MAX_VALUE_LENGTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TextTagParser
private TextTagParser()
-
-
Method Detail
-
readTagsByRegexp
public static Map<String,String> readTagsByRegexp(String text, String splitRegex, String tagRegex, boolean unescapeTextInQuotes)
Try to find tag-value pairs in given text- Parameters:
text
- - text in which tags are looked forsplitRegex
- - text is split into parts with this delimitertagRegex
- - each part is matched against this regexunescapeTextInQuotes
- - if true, matched tag and value will be analyzed more thoroughly- Returns:
- map of tags
-
getValidatedTagsFromText
public static Map<String,String> getValidatedTagsFromText(String buf, TextTagParser.TagWarningCallback callback)
Gets a list of tags that are in the given text- Parameters:
buf
- The text to parsecallback
- 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 checkcallback
- warning callback- Returns:
- true if the tags should be pasted
- Since:
- 12683
-
-