org.sbml.jsbml.util
public class StringTools extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DECIMAL_FORMAT |
private static java.lang.String |
newLine
New line separator of this operating system
|
static java.lang.String |
REAL_FORMAT |
static java.lang.String |
SCIENTIFIC_FORMAT |
static java.lang.String |
underscore
The
Character '_' as a String . |
Constructor and Description |
---|
StringTools() |
Modifier and Type | Method and Description |
---|---|
static java.lang.StringBuffer |
append(java.lang.StringBuffer k,
java.lang.Object... things)
Takes the given StringBuffer as input and appends every further Object to
it.
|
static void |
append(java.lang.StringBuilder sb,
java.lang.Object... elems) |
static java.lang.StringBuffer |
concat(java.lang.Object... things)
This method concatenates two or more
Object String s
(obtained by calling Object.toString() if the current
Object is not null ) into a new StringBuffer . |
static java.lang.StringBuilder |
concatStringBuilder(java.lang.Object... things)
This method concatenates two or more
Object String s
(obtained by calling Object.toString() if the current
Object is not null ) into a new StringBuilder . |
static java.lang.String |
encodeForHTML(java.lang.String string) |
static java.lang.String |
fill(int length,
char symbol) |
static java.lang.String |
fill(int length,
char symbol,
java.lang.String initialString) |
private static java.lang.String |
fill(int length,
char symbol,
java.lang.StringBuilder sb)
Ensures a minimum size of
length for the given
stringBuilder . |
static java.lang.String |
firstLetterLowerCase(java.lang.String name)
Returns a String whose first letter is now in lower case.
|
static java.lang.String |
firstLetterUpperCase(java.lang.String name)
Returns a String who's first letter is now in upper case.
|
static java.lang.String |
getWordForNumber(long number)
Returns the number as an English word.
|
static java.lang.String |
leadingZeros(int length,
int number)
This method creates a
String representation of the given number and
inserts as many zero characters as the prefix of this String as
needed
to result in a String of the given length. |
static java.lang.String |
newLine() |
static boolean |
parseSBMLBoolean(java.lang.String valueAsStr)
Parses a String into a boolean following the rules of the SBML
specifications, section 3.1.2.
|
static double |
parseSBMLDouble(java.lang.String valueAsStr)
Parses a String into a double number following the rules of the SBML
specifications, section 3.1.5.
|
static int |
parseSBMLInt(java.lang.String valueAsStr)
Parses a
String into an int number following the rules of the SBML
specifications, section 3.1.3. |
static short |
parseSBMLShort(java.lang.String value)
Parses a
String into an short number following the rules of the
SBML specifications, section 3.1.3. |
static java.lang.String |
toHTML(java.lang.String string)
Returns a HTML formated String, in which each line is at most lineBreak
symbols long.
|
static java.lang.String |
toHTML(java.lang.String string,
int lineBreak)
Returns a HTML formated String, in which each line is at most lineBreak
symbols long.
|
static java.lang.String |
toString(double value)
Returns a
String from the given value that does not contain a
point zero at the end if the given value represents an integer number. |
static java.lang.String |
toString(java.util.Locale locale,
double value)
Allows for
Locale -dependent number formatting. |
static java.lang.String |
toXMLAnnotationString(java.lang.String annotation)
Checks whether a given
String fits into the definition of the XML
annotation String in SBML. |
static java.lang.String |
toXMLMessageString(java.lang.String message)
Checks whether a given
String fits into the definition of the XML
message String in SBML. |
static java.lang.String |
toXMLNotesString(java.lang.String notes)
Checks whether a given
String fits into the definition of the XML
notes String in SBML. |
private static java.lang.String |
toXMLString(java.lang.String notes,
java.lang.String surroundingTagName)
Checks whether a given
String contain the given surrounding tag. |
public static final java.lang.String DECIMAL_FORMAT
private static final java.lang.String newLine
public static final java.lang.String REAL_FORMAT
public static final java.lang.String SCIENTIFIC_FORMAT
public static final java.lang.String underscore
Character
'_'
as a String
.public static final java.lang.StringBuffer append(java.lang.StringBuffer k, java.lang.Object... things)
k
- things
- public static void append(java.lang.StringBuilder sb, java.lang.Object... elems)
sb
- elems
- public static final java.lang.StringBuffer concat(java.lang.Object... things)
Object
String
s
(obtained by calling Object.toString()
if the current
Object
is not null
) into a new StringBuffer
.things
- to be concatenatedStringBuffer
containing all the
string-representations of all given Object
s.public static final java.lang.StringBuilder concatStringBuilder(java.lang.Object... things)
Object
String
s
(obtained by calling Object.toString()
if the current
Object
is not null
) into a new StringBuilder
.things
- to be concatenatedStringBuilder
containing all the
string-representations of all given Object
s.public static final java.lang.String encodeForHTML(java.lang.String string)
string
- public static final java.lang.String firstLetterLowerCase(java.lang.String name)
name
- public static final java.lang.String firstLetterUpperCase(java.lang.String name)
name
- public static java.lang.String getWordForNumber(long number)
number
- public static java.lang.String leadingZeros(int length, int number)
String
representation of the given number and
inserts as many zero characters as the prefix of this String
as
needed
to result in a String
of the given length.length
- the total desired length of the given number String
.number
- String
of the given length consisting of a suffix defined
by the given number and as many leading zeros as necessary to reach
the desired length.public static java.lang.String fill(int length, char symbol, java.lang.String initialString)
length
- the desired length of the resulting String
symbol
- the symbol to be inserted at the beginning of the initial String
multiple times.initialString
- can be null or empty.public static java.lang.String fill(int length, char symbol)
length
- symbol
- private static java.lang.String fill(int length, char symbol, java.lang.StringBuilder sb)
length
for the given
stringBuilder
. Therefore, the given
symbol
will be put at the beginning of the
string, until it reaches the given length
.length
- symbol
- stringBuilder
- public static final java.lang.String newLine()
public static boolean parseSBMLBoolean(java.lang.String valueAsStr)
valueAsStr
- a boolean as a Stringpublic static double parseSBMLDouble(java.lang.String valueAsStr)
valueAsStr
- a double as a StringDouble.NaN
is returned.public static int parseSBMLInt(java.lang.String valueAsStr)
String
into an int number following the rules of the SBML
specifications, section 3.1.3.valueAsStr
- an int as a String
String
as an int. If the String
is not a valid int number, 0
is returned.public static short parseSBMLShort(java.lang.String value)
String
into an short number following the rules of the
SBML specifications, section 3.1.3.value
- an int as a StringString
as an short. If the String
is not a
valid short number, 0 is returned.public static java.lang.String toHTML(java.lang.String string)
string
- public static java.lang.String toHTML(java.lang.String string, int lineBreak)
string
- lineBreak
- public static final java.lang.String toString(double value)
String
from the given value that does not contain a
point zero at the end if the given value represents an integer number.
The returned String
displays the number in a Locale
-dependent way, i.e., the decimal separator and the symbols to represent
the digits are chosen from the system's configuration. Furthermore, a
scientific style including 'E' will be used if the value is smaller than
1E-5 or greater than 1E5.value
- public static final java.lang.String toString(java.util.Locale locale, double value)
Locale
-dependent number formatting.locale
- value
- public static java.lang.String toXMLNotesString(java.lang.String notes)
String
fits into the definition of the XML
notes String
in SBML. If not, this method will surround the given
String
with the minimal definition of a valid notes
String
.notes
- the String
to be checked and possibly modified.String
that will be surrounded by the XML definition of
a notes String
in SBML, i.e.,
<notes> <body xmlns="http://www.w3.org/1999/xhtml"> <p>the original notes</p> </body> </notes>If the given argument already suffices the definition of XML
String
s in SBML, nothing will be changed.public static java.lang.String toXMLMessageString(java.lang.String message)
String
fits into the definition of the XML
message String
in SBML. If not, this method will surround the given
String
with the minimal definition of a valid message
String
.message
- the String
to be checked and possibly modified.String
that will be surrounded by the XML definition of
a notes String
in SBML, i.e.,
<message> <body xmlns="http://www.w3.org/1999/xhtml"> <p>the original message</p> </body> </message>If the given argument already suffices the definition of XML
String
s in SBML, nothing will be changed.private static java.lang.String toXMLString(java.lang.String notes, java.lang.String surroundingTagName)
String
contain the given surrounding tag.
If not, this method will surround the given
String
with the minimal definition of a valid XML
String
.notes
- the String
to be checked and possibly modified.String
that will be surrounded by the XML definition of
a notes String
in SBML, i.e.,
<tag> <body xmlns="http://www.w3.org/1999/xhtml"> <p>the original notes</p> </body> </tag>If the given argument already suffices the definition of XML
String
s in SBML, nothing will be changed.public static java.lang.String toXMLAnnotationString(java.lang.String annotation)
String
fits into the definition of the XML
annotation String
in SBML. If not, this method will surround the given
String
with the minimal definition of a valid annotation
String
.annotation
- - the String
to be checked and possibly modified.java.lang.IllegalArgumentException
- if the String
passed as argument is not XML