Package org.omegat.util
Class TagUtil
- java.lang.Object
-
- org.omegat.util.TagUtil
-
public final class TagUtil extends java.lang.Object
A collection of tag-related static utilities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TagUtil.Tag
static class
TagUtil.TagInfo
A tuple containing A tag's name The tag'sTagUtil.TagType
typestatic class
TagUtil.TagType
Indicates the type of a tag, e.g.: <foo> = START </foo> = END <bar/> = SINGLE
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
TAG_SEPARATOR_SENTINEL
static char
TEXT_REPLACEMENT
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addExtraTags(java.util.List<TagUtil.Tag> resultList, java.util.List<TagUtil.Tag> srcTags, java.lang.String str)
static java.util.List<ProtectedPart>
applyCustomProtectedParts(java.lang.String source, java.util.regex.Pattern protectedPartsPatterns, java.util.List<ProtectedPart> protectedParts)
Find some protected parts according to the given regular expression.static java.util.List<TagUtil.Tag>
buildTagList(java.lang.String str, ProtectedPart[] protectedParts)
Builds a list of format tags within the supplied string.static java.lang.String
buildTagListForRemove(java.lang.String str)
Builds a list of format tags within the supplied string.static boolean
containsTag(java.util.List<TagUtil.Tag> tags, java.lang.String tag)
Check whether a tag belongs to a list of tagsstatic java.util.List<TagUtil.Tag>
getAllTagsInSource()
static java.util.List<TagUtil.Tag>
getAllTagsMissingFromTarget()
static java.lang.String
getFirstTag(java.lang.String str)
Find the first tag in a segmentstatic java.util.List<java.lang.String>
getGroupedMissingTagsFromTarget()
static java.lang.String
stripXmlTags(java.lang.String xml)
Strips all XML tags (converts to plain text).
-
-
-
Field Detail
-
TAG_SEPARATOR_SENTINEL
public static final java.lang.String TAG_SEPARATOR_SENTINEL
- See Also:
- Constant Field Values
-
TEXT_REPLACEMENT
public static final char TEXT_REPLACEMENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAllTagsInSource
public static java.util.List<TagUtil.Tag> getAllTagsInSource()
-
getAllTagsMissingFromTarget
public static java.util.List<TagUtil.Tag> getAllTagsMissingFromTarget()
-
getGroupedMissingTagsFromTarget
public static java.util.List<java.lang.String> getGroupedMissingTagsFromTarget()
-
buildTagList
public static java.util.List<TagUtil.Tag> buildTagList(java.lang.String str, ProtectedPart[] protectedParts)
Builds a list of format tags within the supplied string. Format tags are 'protected parts' and OmegaT style tags: <xx02> or </yy01>.
-
addExtraTags
public static void addExtraTags(java.util.List<TagUtil.Tag> resultList, java.util.List<TagUtil.Tag> srcTags, java.lang.String str)
-
containsTag
public static boolean containsTag(java.util.List<TagUtil.Tag> tags, java.lang.String tag)
Check whether a tag belongs to a list of tags- Parameters:
tags
-tag
-- Returns:
- true or false
-
buildTagListForRemove
public static java.lang.String buildTagListForRemove(java.lang.String str)
Builds a list of format tags within the supplied string. Format tags are OmegaT style tags: <xx02> or </yy01>.- Returns:
- a string containing the tags
-
getFirstTag
public static java.lang.String getFirstTag(java.lang.String str)
Find the first tag in a segment- Parameters:
str
- A segment- Returns:
- the first tag in the segment, or null if there are no tags
-
applyCustomProtectedParts
public static java.util.List<ProtectedPart> applyCustomProtectedParts(java.lang.String source, java.util.regex.Pattern protectedPartsPatterns, java.util.List<ProtectedPart> protectedParts)
Find some protected parts according to the given regular expression. E.g. printf variables, java MessageFormat patterns, user defined custom tags. These protected parts shouldn't affect statistic but just be displayed in gray in editor and take part in tag validation.
-
stripXmlTags
public static java.lang.String stripXmlTags(java.lang.String xml)
Strips all XML tags (converts to plain text). Tags detected only by pattern. Protected parts are not used.
-
-