Package org.openstreetmap.josm.tools
Class TextTagParser
java.lang.Object
org.openstreetmap.josm.tools.TextTagParser
Class that helps to parse tags from arbitrary text
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCalled when a problematic tag is encountered. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final intprivate static final intprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetValidatedTagsFromText(String buf, TextTagParser.TagWarningCallback callback) Gets a list of tags that are in the given textreadTagsByRegexp(String text, String splitRegex, String tagRegex, boolean unescapeTextInQuotes, boolean unescapePipe) Try to find tag-value pairs in given textreadTagsFromText(String buf) Apply different methods to extract tag-value pairs from arbitrary text(package private) static Stringstatic booleanvalidateTags(Map<String, String> tags, TextTagParser.TagWarningCallback callback) Check tags for correctness and display warnings if needed
-
Field Details
-
MAX_KEY_LENGTH
-
MAX_KEY_COUNT
-
KEY_PATTERN
-
MAX_VALUE_LENGTH
- See Also:
-
-
Constructor Details
-
TextTagParser
private TextTagParser()
-
-
Method Details
-
unescape
-
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 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 thoroughlyunescapePipe- - if true, then replace all '\|' by '|' (issue #14490)- Returns:
- map of tags
- Since:
- 19571 (parameter unescapePipe added)
-
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
nullif the tags are not valid - Since:
- 12683
-
readTagsFromText
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
-