Package org.openstreetmap.josm.tools
Class TextTagParser
- java.lang.Object
-
- org.openstreetmap.josm.tools.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.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.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 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 textstatic 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 textstatic 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
-
-
-
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 java.lang.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
-
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 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 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 parsecallback
- 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 checkcallback
- warning callback- Returns:
- true if the tags should be pasted
- Since:
- 12683
-
-