|
Novell exteNd Director 5.2 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sssw.fw.util.EboStringMisc
Provides miscellaneous routines that manipulate Strings.
Field Summary | |
static String |
DOT
A constant for "." (the 'dot' character as a String). |
static String |
m_emptyStr
An empty String. |
static String[] |
m_emptyStrArray
An empty String array. |
static String |
NULL
A constant for "null". |
Constructor Summary | |
EboStringMisc()
|
Method Summary | |
static String[] |
clone(String[] strArray)
Fully clones a String array. |
static String |
collectionToString(Collection coll,
String delim)
Converts the passed in Collection of objects to a delimited String. |
static int |
containsAnyChar(String s,
String characters)
The index of the first occurrance of any character of one string in another. |
static boolean |
containsIgnoreCase(String[] sa,
String string)
Returns true if the string array contains the specified string, ignoring case. |
static String |
createPath(String base,
String relative,
String separator)
Creates a path, given the base and the relative path. |
static String |
createPath(String base,
String relative,
String ext,
String separator,
boolean useExtInRelative)
Creates a path, given a base path, a relative path, and an extension. |
static boolean |
endsWithIgnoreCase(String s,
String suffix)
Checks whether the specified String ends with the specified suffix, in a case-insensitive manner. |
static boolean |
equalsIgnoreCase(String[] sa1,
String[] sa2)
Compares two String arrays and returns true if the two arrays have the same length and contain the same String values. |
static String |
escape(String in,
String escapeCharacters)
Escapes special characters with backslashes in the specified String. |
static String |
filePathToPackageName(String filePath)
Converts a java file path string with either '\' or '/' to a package syntax ('.') |
static int |
findMatchingChar(String str,
int offset,
int ch)
Finds a matching character in the specified String. |
static int[] |
findNextJavaToken(String str,
int offset)
A helper routine to find the next Java token in a String. |
static int[] |
findNextJavaWord(String str,
int offset)
A helper routine to find the next Java ID in a String. |
static int[] |
findPrevJavaToken(String str,
int offset)
Finds the previous Java token in a String. |
static int[] |
findPrevJavaWord(String str,
int offset)
A helper routine to find the previous Java ID in a String. |
static int |
findWhitespace(String str,
int offset)
Searches for the next character in the specified string that is whitespace, starting with the given offset. |
static int |
findWord(String in,
int offset,
String word,
String wordChars)
Finds whole words in a String. |
static String |
firstPart(String string,
char c)
Returns the part of the string before the first occurrence of the specified character. |
static String |
getBaseName(String fullyQualifiedName)
Returns a new string with the extension (last .*) chopped off. |
static String |
getEncoding(String val)
Return a character string representing the encoding of the characters in this buffer. |
static String |
getEncodingName(String name)
The names of the encodings used in java are not well defined The current ones in use are, worse still, not named with the correct IANA name (see http://www.iana.org/ or specifically http://www.isi.edu/in-notes/iana/assignments/character-sets) This routine will take a name of an encoding and return a string that can be used in various java APIs (like String.getBytes(String enc)). |
static String |
getExtension(String fullyQualifiedName)
Returns the extension of the name or null if no extension was found |
static boolean |
isAsciiChar(char c)
Checks if the specified character is an ASCII one. |
static boolean |
isAsciiString(String s)
Checks for non-ASCII characters in the specified String. |
static boolean |
isEmpty(String s)
Checks to see whether the specified String is null or empty. |
static boolean |
isWhitespace(String str)
Check to see if the specified String contains nothing but whitespace characters. |
static boolean |
isWideChar(char c)
Checks for characters with the high byte set. |
static boolean |
isWideCharIncluded(String s)
Checks if the specified String includes characters with the high byte set. |
static String |
javaEscape(String in)
Escapes a string for inclusion in generated Java code. |
static String |
lastPart(String string,
char c)
Returns the part of the string after the last occurrence of the specified character. |
static String |
packageNameToFilePath(String packageName,
char separatorChar)
Converts a java package name string with '.'s to a file path syntax using the given directory separator char. |
static int |
prevSkipWhite(String str,
int offset)
Returns the index of the previous character in the string that is not whitespace or -1 if no more whitespace |
static String |
readLongString(com.sssw.fw.util.DataInput in)
No information available |
static String |
removeBadCharacters(String s,
String okCharacters)
Removes "bad" characters from a String. |
static String |
removeExtension(String string)
Returns the part of the string before the last occurrence of '.'. |
static String |
removeTrailingFileSeparator(String str)
Returns a new string with a trailing "/" or "\" removed or the original string if no trailing "/" or "\" exists. |
static String |
removeTrailingSlash(String str)
Returns a new string with a trailing "/" removed or the original string if no trailing "/" exists. |
static String |
replaceString(String in,
String find,
String replace)
Replaces all occurrences of one String with another String in the specified master String. |
static String |
replaceStringIgnoreCase(String in,
String find,
String replace)
Finds occurrences of one String in another and replaces them with the specified replacement String. |
static String |
replaceWord(String in,
String word,
String replace,
String wordChars)
Finds/replaces whole words. |
static int |
safeCompare(String s1,
String s2)
Safely compares two strings. |
static boolean |
safeEquals(String s1,
String s2,
boolean ignoreCase)
Safely tests two strings for equality. |
static String |
safeToString(Object obj)
Return a non-null String representation of the passed-in object. |
static int |
skipWhite(String str,
int offset)
Skips the whitespace characters, if any, in the given string, starting from the specified offset. |
static String[] |
split(String str,
String seps)
Breaks up the specified String into tokens, given a delimiter String. |
static String[] |
splitPath(String path)
Splits the passed in path into a filename and an extension. |
static boolean |
startsWithIgnoreCase(String string,
String start)
Checks in a case-insensitive manner whether the string begins with the text of 'start' |
static String |
stringArrayToString(String[] ar,
String delim)
Converts a string array into a single string. |
static Vector |
stringArrayToVector(String[] ar)
Converts a String array to Vector. |
static Collection |
stringToCollection(String s,
String delim)
Given a String and a delimiter sequence, parses the String out into a Collection of tokens that are separated by the delimiter within the String. |
static Vector |
stringToVector(String s)
Parses the passed in String (containing newline characters) into a Vector of Strings. |
static Vector |
stringToVector(String s,
String delim)
Tokenizes the specified String using the passed in delimiter. |
static String |
stripChars(String s,
String strippedChars)
Returns a new string with the given characters stripped from the orginal string. |
static String[] |
toStringArray(String str)
Wraps a given String in an array. |
static String |
toUnicodeEscapeString(String str)
Gets a unicode-escape String. |
static String |
translateString(String in,
String[] args)
Translates the specified String. |
static String |
translateStringEx(String in,
Object[] args)
Translates a String. |
static String |
unescape(String in,
String escapeCharacters)
Undoes the effects of the escape method. |
static String |
unsignedHexString(int value)
Returns an unsigned Hex String corresponding to the passed in integer value. |
static void |
writeLongString(String str,
com.sssw.fw.util.DataOutput out)
No information available |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static String[] m_emptyStrArray
public static String m_emptyStr
public static String DOT
public static String NULL
Constructor Detail |
public EboStringMisc()
Method Detail |
public static String firstPart(String string, char c)
firstPart("com.sssw.fw.util.EboStringMisc", '.')
returns "com".string
- the string to search inc
- the character to search forc
public static String lastPart(String string, char c)
lastPart("com.sssw.fw.util.EboStringMisc", '.')
returns
"EboStringMisc".string
- the string to search inc
- the character to search forpublic static String removeExtension(String string)
removeExtension("image.gif")
returns "image".
E.g. removeExtension("xxx")
returns "xxx".string
- the string to processpublic static boolean startsWithIgnoreCase(String string, String start)
string
- the string to teststart
- the string to test forpublic static boolean containsIgnoreCase(String[] sa, String string)
sa
- the string arraystring
- the string to search forpublic static boolean equalsIgnoreCase(String[] sa1, String[] sa2)
sa1
- the first String arraysa2
- the second String arraypublic static boolean endsWithIgnoreCase(String s, String suffix)
s
- the stringsuffix
- the suffixpublic static String removeTrailingSlash(String str)
str
- the string to processpublic static String removeTrailingFileSeparator(String str)
str
- the string to processpublic static String[] clone(String[] strArray)
strArray
- the String array to copypublic static boolean isEmpty(String s)
s
- the String to checkpublic static String replaceString(String in, String find, String replace)
in
- the String to replace occurrences infind
- the String to find in the master Stringreplace
- the String to replace the occurrences of 'find' withpublic static String replaceStringIgnoreCase(String in, String find, String replace)
in
- the String to replace infind
- the String to findreplace
- the String to replace withpublic static String replaceWord(String in, String word, String replace, String wordChars)
in
- the input string.word
- the word to find and replace in the input string.replace
- the string to replace each occurrance of "word" with.wordChars
- the characters (outside of alphabetic range) that
can be considered part of a word. For example for replacing words
in Java source one might pass "_0123456789"EboEditBuffer
,
replaceString
public static int findWord(String in, int offset, String word, String wordChars)
in
- the input string.offset
- the offset to start the search from.word
- the word to find in the input string.wordChars
- the characters (outside of alphabetic range) that
can be considered part of a word. For example for replacing words
in Java source one might pass "_0123456789"EboEditBuffer
,
replaceString
,
replaceWord
public static int[] findPrevJavaToken(String str, int offset)
str
- the input string.offset
- the offset to start the search from.EboEditBuffer
,
findWord
,
replaceString
,
replaceWord
,
findNextJavaToken
,
findPrevJavaWord
,
findNextJavaWord
public static int[] findPrevJavaWord(String str, int offset)
str
- the input string.offset
- the offset to start the search from.EboEditBuffer
,
findWord
,
replaceString
,
replaceWord
public static int[] findNextJavaToken(String str, int offset)
str
- the input string.offset
- the offset to start the search from.EboEditBuffer
,
findWord
,
replaceString
,
replaceWord
,
findPrevJavaToken
,
findPrevJavaWord
,
findNextJavaToken
,
findNextJavaWord
public static int[] findNextJavaWord(String str, int offset)
str
- the input string.offset
- the offset to start the search from.EboEditBuffer
,
findWord
,
replaceString
,
replaceWord
public static int skipWhite(String str, int offset)
str
- the string to searchoffset
- the offset to start the search frompublic static int findWhitespace(String str, int offset)
str
- - the string to searchoffset
- - the offset to start the search frompublic static boolean isWhitespace(String str)
str
- the string to testpublic static int prevSkipWhite(String str, int offset)
str
- the string to searchoffset
- the offset to start the search frompublic static int findMatchingChar(String str, int offset, int ch)
str
- the string to searchoffset
- the offset to start the search fromch
- the character to whose match should be search for, can be
one of the following:
public static String translateString(String in, String[] args)
EboEditBuffer
public static String translateStringEx(String in, Object[] args)
translateString
. There are two
differences. 1. args is an Object[] rather than a String[]
2. replacement tokens in the string must be in the for of
%xxx% rather than %x.public static String escape(String in, String escapeCharacters)
in
- The string to be modifiedescapeCharacters
- The list of escape characterspublic static String unescape(String in, String escapeCharacters)
escape
method.in
- the string to be modifiedescapeCharacters
- the list of escape characterspublic static String javaEscape(String in)
public static String unsignedHexString(int value)
value
- the integer valuepublic static int containsAnyChar(String s, String characters)
s
- the string to search.characters
- the characters to search for in 's'.public static String removeBadCharacters(String s, String okCharacters)
removeBadCharacters("ab$*^ab#%##ab", "%.,")
yields
"ab_ab_%_ab". Note: all letters, digits, and underscores are always
assumed to be "OK" characters.s
- the String to processokCharacters
- the "OK" characterspublic static String stripChars(String s, String strippedChars)
s
- the String to processstrippedChars
- the characters that are to be stripped from the
specified Stringpublic static String getEncoding(String val)
public static String getEncodingName(String name)
public static Vector stringToVector(String s)
s
- the String to processpublic static Vector stringToVector(String s, String delim)
s
- the String to tokenizedelim
- the delimiter to usepublic static Collection stringToCollection(String s, String delim)
s
- the String to parsedelim
- the delimiter Stringpublic static Vector stringArrayToVector(String[] ar)
ar
- the array to convertpublic static String stringArrayToString(String[] ar, String delim)
ar
- the array to convertdelim
- the delimiter to usepublic static String collectionToString(Collection coll, String delim)
toString
methods of the Collection member objects are
used to get the String representation of the objects.coll
- the Collection to convertdelim
- the delimiter to usepublic static String[] toStringArray(String str)
str
- the String to wrap as a String arraypublic static String[] split(String str, String seps)
str
- the String to splitseps
- the delimiter Stringpublic static String filePathToPackageName(String filePath)
filePath
- the file path to convert.public static String packageNameToFilePath(String packageName, char separatorChar)
packageName
- the string to convert to file path syntaxseparatorChar
- the separator character to use when replacing
'.'s in the package namepublic static String getBaseName(String fullyQualifiedName)
public static String getExtension(String fullyQualifiedName)
fullyQualifiedName
- the filename to get extension frompublic static String[] splitPath(String path)
path
- the path to splitpublic static String createPath(String base, String relative, String ext, String separator, boolean useExtInRelative)
base
- the base path, if any (null may be passed in)relative
- the relative path, if any (null may be passed in)ext
- extension, if anyseparator
- the path separator; if null, the system-dependent
default name-separator character (java.io.File.separator
)
is useduseExtInRelative
- if true, any extension found in the relative
path, is used as the extension in the returned path, otherwise the
value of the ext
parameter is usedpublic static String createPath(String base, String relative, String separator)
base
- the base pathrelative
- the relative pathseparator
- separator, if any (defaults to
java.io.File.separator
)public static String readLongString(com.sssw.fw.util.DataInput in) throws com.sssw.fw.util.IOException
public static void writeLongString(String str, com.sssw.fw.util.DataOutput out) throws com.sssw.fw.util.IOException
public static boolean isAsciiChar(char c)
c
- the character to checkpublic static boolean isAsciiString(String s)
s
- the String to checkpublic static boolean isWideChar(char c)
c
- the character to checkpublic static boolean isWideCharIncluded(String s)
s
- the String to checkpublic static boolean safeEquals(String s1, String s2, boolean ignoreCase)
s1
- the first strings2
- the second stringignoreCase
- if true, ignore case, otherwise, compare in
the case-sensitive mannerpublic static int safeCompare(String s1, String s2)
s1
- the first strings2
- the second stringpublic static String toUnicodeEscapeString(String str)
public static String safeToString(Object obj)
obj
- the objectEboStringMisc.NULL
if the object is null
|
Novell exteNd Director 5.2 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |