|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectStringTools
public final class StringTools
Tools for reading files etc.
| Nested Class Summary | |
|---|---|
static class |
StringTools.XmlPrintMode
Constants for printing XML rule matches. |
| Method Summary | |
|---|---|
static String |
addSpace(String word,
Language language)
Adds spaces before words that are not punctuation. |
static String |
asString(CharSequence s)
|
static void |
assureSet(String s,
String varName)
Throw exception if the given string is null or empty or only whitespace. |
static String |
escapeHTML(String s)
Escapes these characters: less than, bigger than, quote, ampersand. |
static String |
escapeXML(String s)
Calls escapeHTML(String). |
static String |
filterXML(String str)
Simple XML filtering routing |
static String |
getContext(int fromPos,
int toPos,
String fileContents)
|
static String |
getContext(int fromPos,
int toPos,
String contents,
int contextSize)
|
static String |
getLabel(String label)
Returns translation of the UI element without the control character "&". |
static char |
getMnemonic(String label)
Returns mnemonic of a UI element. |
static String |
getOOoLabel(String label)
Returns the UI element string with mnemonics encoded in OpenOffice.org convention (using "~"). |
static boolean |
isAllUppercase(String str)
Returns true if str is made up of all-uppercase characters
(ignoring characters for which no upper-/lowercase distinction exists). |
static boolean |
isCapitalizedWord(String str)
|
static boolean |
isEmpty(String str)
Helper method to replace calls to "".equals(). |
static boolean |
isMixedCase(String str)
|
static boolean |
isPositiveNumber(char ch)
|
static boolean |
isWhitespace(String str)
Checks if a string contains only whitespace, including all Unicode whitespace. |
static String |
listToString(Collection<String> l,
String delimiter)
|
static String |
lowercaseFirstChar(String str)
Return str modified so that its first character is now an
lowercase character. |
static String |
readerToString(Reader reader)
|
static String |
readFile(InputStream file)
Read a file's content. |
static String |
readFile(InputStream file,
String encoding)
Read the text file using the given encoding. |
static String |
ruleMatchesToXML(List<RuleMatch> ruleMatches,
String text,
int contextSize)
Deprecated. Use #ruleMatchesToXML(List instead |
static String |
ruleMatchesToXML(List<RuleMatch> ruleMatches,
String text,
int contextSize,
StringTools.XmlPrintMode xmlMode)
Get an XML representation of the given rule matches. |
static boolean |
startsWithUppercase(String str)
Whether the first character of str is an uppercase character. |
static String |
streamToString(InputStream is)
|
static String |
trimWhitespace(String str)
Filters any whitespace characters. |
static String |
uppercaseFirstChar(String str)
Return str modified so that its first character is now an
uppercase character. |
| Methods inherited from class Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void assureSet(String s,
String varName)
public static String readFile(InputStream file)
throws IOException
IOException
public static String readFile(InputStream file,
String encoding)
throws IOException
file - InputStream to a file to be readencoding - the file's character encoding (e.g. iso-8859-1)
\n
IOExceptionpublic static boolean isAllUppercase(String str)
str is made up of all-uppercase characters
(ignoring characters for which no upper-/lowercase distinction exists).
public static boolean isMixedCase(String str)
str - - input str
Returns true if str is MixedCase.public static boolean isCapitalizedWord(String str)
str - - input stringpublic static boolean startsWithUppercase(String str)
str is an uppercase character.
public static String uppercaseFirstChar(String str)
str modified so that its first character is now an
uppercase character. If str starts with non-alphabetic
characters, such as quotes or parentheses, the first character is
determined as the first alphabetic character.
public static String lowercaseFirstChar(String str)
str modified so that its first character is now an
lowercase character. If str starts with non-alphabetic
characters, such as quotes or parentheses, the first character is
determined as the first alphabetic character.
public static String readerToString(Reader reader)
throws IOException
IOException
public static String streamToString(InputStream is)
throws IOException
IOExceptionpublic static String escapeXML(String s)
public static String escapeHTML(String s)
public static String ruleMatchesToXML(List<RuleMatch> ruleMatches,
String text,
int contextSize)
#ruleMatchesToXML(List,String,int,XmlPrintMode) instead
text - the original text that was checked, used to get the context of the
matchescontextSize - the desired context size in characters
public static String ruleMatchesToXML(List<RuleMatch> ruleMatches,
String text,
int contextSize,
StringTools.XmlPrintMode xmlMode)
text - the original text that was checked, used to get the context of the
matchescontextSize - the desired context size in charactersxmlMode - TODO
public static String listToString(Collection<String> l,
String delimiter)
public static String getContext(int fromPos,
int toPos,
String fileContents)
public static String getContext(int fromPos,
int toPos,
String contents,
int contextSize)
public static String trimWhitespace(String str)
str - String to be filtered.
public static String addSpace(String word,
Language language)
word - Word to add the preceding space.language - Language of the word (to check typography conventions). Currently
French convention of not adding spaces only before '.' and ',' is
implemented; other languages assume that before ,.;:!? no spaces
should be added.
public static String getLabel(String label)
label - Label to convert.
public static String getOOoLabel(String label)
label - Label to convert
public static char getMnemonic(String label)
label - String Label of the UI element
public static boolean isWhitespace(String str)
str - String to check
public static boolean isPositiveNumber(char ch)
ch - Character to check
public static boolean isEmpty(String str)
str - String to check
public static String filterXML(String str)
str - XML string to be filtered.
public static String asString(CharSequence s)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||