public final class EditorUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
addBidiAroundTags(java.lang.String text,
SourceTextEntry ste)
Add RTL+LTR around tags.
|
static java.lang.String |
doChangeCase(java.lang.String input,
IEditor.CHANGE_CASE_TO toWhat)
Change the case of the input string to the indicated case.
|
static java.lang.String |
doChangeCase(java.lang.String input,
IEditor.CHANGE_CASE_TO toWhat,
java.util.Locale locale,
ITokenizer tokenizer)
Change the case of the input string to the indicated case.
|
static int |
getWordEnd(javax.swing.text.JTextComponent c,
int offs)
Determines the end of a word for the given model location.
|
static int |
getWordStart(javax.swing.text.JTextComponent c,
int offs)
Determines the start of a word for the given model location.
|
static boolean |
hasBidiAroundTag(java.lang.String text,
java.lang.String tag,
int pos) |
static java.lang.String |
removeDirectionChars(java.lang.String text)
Remove invisible direction chars from string.
|
static java.lang.String |
removeDirectionCharsAroundTags(java.lang.String text,
SourceTextEntry ste)
Remove bidi chars around tags only.
|
static java.lang.String |
replaceGlossaryEntries(java.lang.String text)
Convenience method for
replaceGlossaryEntries(String, List, Locale, ITokenizer) . |
static java.lang.String |
replaceGlossaryEntries(java.lang.String text,
java.util.List<GlossaryEntry> entries,
java.util.Locale locale,
ITokenizer tokenizer)
Given a list of glossary entries, replace any instances of the source term appearing in the given text with the
target term.
|
public static int getWordStart(javax.swing.text.JTextComponent c, int offs) throws javax.swing.text.BadLocationException
c
- offs
- javax.swing.text.BadLocationException
public static int getWordEnd(javax.swing.text.JTextComponent c, int offs) throws javax.swing.text.BadLocationException
c
- offs
- javax.swing.text.BadLocationException
public static java.lang.String removeDirectionChars(java.lang.String text)
text
- string with direction charspublic static java.lang.String removeDirectionCharsAroundTags(java.lang.String text, SourceTextEntry ste)
text
- string with direction charspublic static java.lang.String doChangeCase(java.lang.String input, IEditor.CHANGE_CASE_TO toWhat)
IEditor.CHANGE_CASE_TO.CYCLE
the result will be UPPER > LOWER > SENTENCE
> TITLE > UPPER.
This is a convenience method for
#doChangeCase(String, CHANGE_CASE_TO, Locale, ITokenizer)
. The
locale and tokenizer will be taken from the current project's target
language values.
input
- The string to changetoWhat
- The case to change to, or IEditor.CHANGE_CASE_TO.CYCLE
public static java.lang.String doChangeCase(java.lang.String input, IEditor.CHANGE_CASE_TO toWhat, java.util.Locale locale, ITokenizer tokenizer)
IEditor.CHANGE_CASE_TO.CYCLE
the result will be UPPER > LOWER > SENTENCE
> TITLE > UPPER.input
- The string to changetoWhat
- The case to change to, or IEditor.CHANGE_CASE_TO.CYCLE
locale
- The locale of the input stringtokenizer
- A tokenizer for the input string languagepublic static java.lang.String replaceGlossaryEntries(java.lang.String text)
replaceGlossaryEntries(String, List, Locale, ITokenizer)
. Glossary entries are
retrieved from GlossaryManager
; the locale and tokenizer are taken from the project's current values for
the source language.text
- Text in which to replace glossary hits. Assumed to be in the project's source language.public static java.lang.String replaceGlossaryEntries(java.lang.String text, java.util.List<GlossaryEntry> entries, java.util.Locale locale, ITokenizer tokenizer)
text
- Text in which to replace glossary hits (assumed to be in the project's source language)entries
- List of glossary entrieslocale
- Locale with which to perform capitalization matching (assumed to be source locale)tokenizer
- Tokenizer with which to split text (assumed to be project's source tokenizer)public static java.lang.String addBidiAroundTags(java.lang.String text, SourceTextEntry ste)
public static boolean hasBidiAroundTag(java.lang.String text, java.lang.String tag, int pos)