|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ptolemy.util.StringUtilities
A collection of utilities for manipulating strings. These utilities do not depend on any other ptolemy.* packages.
Field Summary | |
static int |
ELLIPSIS_LENGTH_LONG
Maximum length in characters of a long string before #ellipse(String, int) truncates and add a
trailing . . . |
static int |
ELLIPSIS_LENGTH_SHORT
Maximum length in characters of a short string before #ellipse(String, int) truncates and add a
trailing . . . |
static java.lang.String |
PREFERENCES_DIRECTORY
Location of Application preferences such as the user library. |
Method Summary | |
static java.lang.String |
abbreviate(java.lang.String longName)
Abbreviate a string. |
static java.lang.String |
ellipsis(java.lang.String string,
int length)
Return a string with a maximum line length of length characters, limited to the given number of characters. |
static java.lang.String |
escapeForXML(java.lang.String string)
Given a string, replace all the instances of XML special characters with their corresponding XML entities. |
static java.lang.String |
getIndentPrefix(int level)
Return a number of spaces that is proportional to the argument. |
static java.lang.String |
getProperty(java.lang.String propertyName)
Get the specified property from the environment. |
static java.lang.String |
preferencesDirectory()
Return the preferences directory, creating it if necessary. |
static java.lang.String |
sanitizeName(java.lang.String name)
Sanitize a String so that it can be used as a Java identifier. |
static java.lang.String |
split(java.lang.String longName)
If the string is longer than 79 characters, split it up by displaying adding newlines in all newline delimited substrings that are longer than 79 characters. |
static java.lang.String |
substitute(java.lang.String string,
java.lang.String pattern,
java.lang.String replacement)
Replace all occurrences of pattern in the specified string with replacement. |
static java.lang.String[] |
tokenizeForExec(java.lang.String inputString)
Tokenize a String to an array of Strings for use with Runtime.exec(String []). |
static java.lang.String |
usageString(java.lang.String commandTemplate,
java.lang.String[][] commandOptions,
java.lang.String[] commandFlags)
Return a string that contains a description of how to use this class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ELLIPSIS_LENGTH_LONG
#ellipse(String, int)
truncates and add a
trailing . . .
public static final int ELLIPSIS_LENGTH_SHORT
#ellipse(String, int)
truncates and add a
trailing . . .
public static java.lang.String PREFERENCES_DIRECTORY
preferencesDirectory()
Method Detail |
public static java.lang.String abbreviate(java.lang.String longName)
split(String longName)
public static java.lang.String ellipsis(java.lang.String string, int length)
string
- The string to truncate.length
- The length to which to truncate the string.public static java.lang.String escapeForXML(java.lang.String string)
& becomes & " becomes " < becomes < > becomes > newline becomes
string
- The string to escape.
public static java.lang.String getIndentPrefix(int level)
level
- The level of indenting represented by the spaces.
public static java.lang.String preferencesDirectory() throws java.io.IOException
java.io.IOException
- If the directory could not be created.PREFERENCES_DIRECTORY
public static java.lang.String getProperty(java.lang.String propertyName)
The following properties are handled specially
c:/foo
whereas most of the other methods that operate
on path names return C:/foo
.
propertyName
- The name of property.
public static java.lang.String sanitizeName(java.lang.String name)
"An identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter. An identifier cannot have the same spelling (Unicode character sequence) as a keyword (3.9), boolean literal (3.10.3), or the null literal (3.10.7). "Java characters are A-Z, a-z, $ and _.
Characters that are not permitted in a Java identifier are changed to an underscores. This method does not check that the returned string is a keyword or literal. Note that two different strings can sanitize to the same string. This method is commonly used during code generation to map the name of a ptolemy object to a valid identifier name.
name
- A string with spaces and other characters that
cannot be in a Java name.
public static java.lang.String split(java.lang.String longName)
longName
- The string to optionally split up
abbreviate(String longName)
public static java.lang.String substitute(java.lang.String string, java.lang.String pattern, java.lang.String replacement)
string
- The string to edit.replacement
- The string to replace it with.
public static java.lang.String[] tokenizeForExec(java.lang.String inputString) throws java.io.IOException
Lines that begin with an octothorpe '#' are ignored. Substrings that start and end with a double quote are considered to be a single token and are returned as a single array element.
inputString
- The String to tokenize
java.io.IOException
- Thrown if StreamTokenizer.nextToken() throws it.public static java.lang.String usageString(java.lang.String commandTemplate, java.lang.String[][] commandOptions, java.lang.String[] commandFlags)
commandOptions
- A 2xN array of Strings that list command-line
options that take arguments where the first
element is a String naming the command line option, and the
second element is the argument, for example
{"-class", "")
commandFlags
- An array of Strings that list command-line
options that are either present or not.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |