Class Text
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default format pattern used in strftime() if no pattern parameter has been supplied.static final char[]used for the md5static final StringNon-valid handle characters: / \ : * ? " invalid input: '<' > | and carriage return.
(That's slash, backslash, colon, asterisk, question mark, quotation mark, less than symbol, greater than symbol, pipe, and carriage return.)static final TimeZoneThe local timezonestatic final TimeZoneThe UTC timezonestatic BitSetThe list of characters that are not encoded by theescape()andunescape()methods.static BitSetSame asURISavebut also contains the '/' -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompareHandles(String h1, String h2) compares to handles lexigographically with one exception: the '/' character is always considered smaller than all other chars.static StringcreateValidLabel(String labelhint) Create a valid label out of an arbitrary string.static StringdateToRfc1123String(Date date) Returns a stringified date accoring to the date format specified in RTF1123.static StringDigest the plain string using the given algorithm.static StringDeprecated.static StringDigest the plain string using the given algorithm.static StringDoes a URL encoding of thestring.static StringDoes an URL encoding of thestringusing theescapecharacter.static StringDoes an URL encoding of thestringusing theescapecharacter.static StringescapePath(String path) Does a URL encoding of thepath.static StringEscapes all character that have specific meaning in XMl/HTML, namely '<', '>', '"', '&' by their isolating encoding aequivalents "<", ">", """, "&"static String[]returns an array of strings decomposed of the original string, split at every occurance of 'ch'.static String[]returns an array of strings decomposed of the original string, split at every occurance of 'ch'.static StringformatISO8601(Calendar cal) Formats aCalendarvalue into an ISO8601-compliant date/time string.static StringfullFilePath(String parent, String path) this method does the similar than thefullPath(String, String)but it considers the parent as parent directory rather than a base handle.static Stringreturns a full path.static StringgetAbsoluteParent(String handle, int level) Returns the nth absolute parent of the handle, where n=level.static StringDeprecated.usegetName(String)static StringDeprecated.static StringgetLocalName(String qname) Returns the local name of the givenqname.static StringReturns the name part of the pathstatic StringSame asgetName(String)but adding the possibility to pass paths that end with a trailing '/'static StringReturns the name part of the path, delimited by the givendelimstatic StringgetNamespacePrefix(String qname) Returns the namespace prefix of the givenqname.static StringgetRelativeParent(String handle, int level) Returns the nth relative parent of the handle, where n=level.static StringConcatenates all strings in the string array using the specified delimiter.static booleanisDescendant(String handle, String descendant) Determines if thedescendanthandle is hierarchical a descendant ofhandle.static booleanisDescendantOrEqual(String handle, String descendant) Determines if thedescendanthandle is hierarchical a descendant ofhandleor equal to it.static booleanDetermines, if two handles are sister-pages, that meens, if they represent the same hierarchic level and share the same parent page.static StringjoinFixSlash(String first, String second) Deprecated.static StringmakeCanonicalPath(char[] source) make a cannonical path.static StringmakeCanonicalPath(String path) Make a path canonical.static StringmakeCanonicalPath(StringBuffer source) Deprecated.usemakeCanonicalPath(char[])insteadstatic StringDeprecated.static StringCalculate an MD5 hash of the string given.static DateParses the date string based on the format pattern which is in the default formatdd.MM.yyyy HH:mm:ss.static DateParses the date string based on the format pattern which is in the default formatdd.MM.yyyy HH:mm:ss.static DateParses the date string based on the format pattern which is in the format used by the Java platfrom SimpleDateFormat class.static DateParses the date string based on the format pattern which is in the format used by the Java platfrom SimpleDateFormat class.static CalendarparseISO8601(String text) Parses an ISO8601-compliant date/time string.static StringReplaces all occurences ofoldStringintextwithnewString.static StringreplaceVariables(Properties variables, String value, boolean ignoreMissing) Performs variable replacement on the given string value.static String[]Deprecated.static String[]Deprecated.static StringFormats a string according to format and argument.static StringThis method implements the famous and ubiquituoussprintfformatter in Java.static StringFormats a string according to format and argument.static StringFormats a string according to format and argument.static StringFormats a string according to format and argument.static StringFormats a string according to format and argument.static StringImplements a date formatting routine supporting (a subset) of the POSIXstrftime()function.static StringImplements a date formatting routine supporting (a subset) of the POSIXstrftime()function.static StringImplements a date formatting routine supporting (a subset) of the POSIXstrftime()function.static StringImplements a date formatting routine supporting (a subset) of the POSIXstrftime()function.static StringDoes a URL decoding of thestring.static StringDoes a URL decoding of thestringusing theescapecharacter.static voidvalidateLabel(String labelhint) Checks if the label is not empty and contains all valid label chars.
-
Field Details
-
DEFAULT_DATE_FORMAT_PATTERN
The default format pattern used in strftime() if no pattern parameter has been supplied. This is the default format used to format dates in Communiqué 2- See Also:
-
TIMEZONE_UTC
The UTC timezone -
TIMEZONE_LOCAL
The local timezone -
hexTable
public static final char[] hexTableused for the md5 -
URISave
The list of characters that are not encoded by theescape()andunescape()methods. They contains the characters as defined 'unreserved' in section 2.3 of the RFC 2396 'URI genric syntax':unreserved = alphanum | mark mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" -
URISaveEx
Same asURISavebut also contains the '/' -
NON_VALID_CHARS
Non-valid handle characters: / \ : * ? " invalid input: '<' > | and carriage return.
(That's slash, backslash, colon, asterisk, question mark, quotation mark, less than symbol, greater than symbol, pipe, and carriage return.)- See Also:
-
-
Method Details
-
split
Deprecated.returns an array of strings decomposed of the original string, split at every occurance of 'ch'. if 2 'ch' follow each other with no intermediate characters, empty "" entries are avoided.- Parameters:
str- the string to decomposech- the character to use a split pattern- Returns:
- an array of strings
-
split
Deprecated.returns an array of strings decomposed of the original string, split at every occurance of 'ch'.- Parameters:
str- the string to decomposech- the character to use a split patternrespectEmpty- iftrue, empty elements are generated- Returns:
- an array of strings
-
explode
returns an array of strings decomposed of the original string, split at every occurance of 'ch'. if 2 'ch' follow each other with no intermediate characters, empty "" entries are avoided.- Parameters:
str- the string to decomposech- the character to use a split pattern- Returns:
- an array of strings
-
explode
returns an array of strings decomposed of the original string, split at every occurance of 'ch'.- Parameters:
str- the string to decomposech- the character to use a split patternrespectEmpty- iftrue, empty elements are generated- Returns:
- an array of strings
-
implode
Concatenates all strings in the string array using the specified delimiter.- Parameters:
arr-delim-- Returns:
- the concatenated string
-
replace
Replaces all occurences ofoldStringintextwithnewString.- Parameters:
text-oldString- old substring to be replaced withnewStringnewString- new substring to replace occurences ofoldString- Returns:
- a string
-
getName
Returns the name part of the path- Parameters:
path- the path- Returns:
- the name part
-
getName
Returns the name part of the path, delimited by the givendelim- Parameters:
path- the pathdelim- the delimiter- Returns:
- the name part
-
getName
Same asgetName(String)but adding the possibility to pass paths that end with a trailing '/'- Parameters:
path- the pathignoreTrailingSlash- iftruea trailing slash is ignored- Returns:
- the name part
- See Also:
-
getNamespacePrefix
Returns the namespace prefix of the givenqname. If the prefix is missing, an empty string is returned. Please note, that this method does not validate the name or prefix. the qname has the format: qname := [prefix ':'] local;- Parameters:
qname- a qualified name- Returns:
- the prefix of the name or "".
- Throws:
NullPointerException- ifqnameisnull- See Also:
-
getLocalName
Returns the local name of the givenqname. Please note, that this method does not validate the name. the qname has the format: qname := [prefix ':'] local;- Parameters:
qname- a qualified name- Returns:
- the localname
- Throws:
NullPointerException- ifqnameisnull- See Also:
-
compareHandles
compares to handles lexigographically with one exception: the '/' character is always considered smaller than all other chars. this results in a ordering, in which the parent pages come first (it's about 6 times slower than the string impl. of compareTo).- example (normal string compare):
- /foo
- /foo-bar
- /foo/bar
- example (this handle compare):
- /foo
- /foo/bar
- /foo-bar
- Parameters:
h1- the first handleh2- the second handle- Returns:
- the return is positive, if the first handle is bigger than the second; negative, if the first handle is smaller than the second; and zero, if the two handles are equal.
-
fullFilePath
this method does the similar than thefullPath(String, String)but it considers the parent as parent directory rather than a base handle. if further respects full qualified uri's.
examples:parent | path | result ----------+----------+------------ "" | "" | / /foo | "" | /foo "" | /foo | /foo "." | foo | foo /foo/bar | bla | /foo/bar/bla /foo/bar | /bla | /bla /foo/bar | ../bla | /foo/bla /foo/bar | ./bla | /foo/bar/bla foo | bar | foo/bar c:/bla | gurk | c:/bla/gurk /foo | c:/bar | c:/bar - Parameters:
parent- the base handlepath- the path
-
fullPath
returns a full path. if base is empty, '/' is assumed if base and path are relative, a relative path will be generated.
examples:base | path | result ----------+----------+------------ "" | "" | / /foo | "" | /foo "" | /foo | /foo "." | foo | foo /foo/bar | bla | /foo/bla /foo/bar | /bla | /bla /foo/bar | ../bla | /bla /foo/bar | ./bla | /foo/bla foo | bar | bar
- Parameters:
base- the base handlepath- the path
-
makeCanonicalPath
Make a path canonical. This is a shortcut forText.makeCanonicalPath(new StringBuffer(path));- Parameters:
path- path to make canonical
-
makeCanonicalPath
Deprecated.usemakeCanonicalPath(char[])insteadmake a cannonical path. removes all /./ and /../ and multiple slashes.- Parameters:
source- the input source- Returns:
- a string containing the cannonical path
-
makeCanonicalPath
make a cannonical path. removes all /./ and /../ and multiple slashes.- Parameters:
source- the input source- Returns:
- a string containing the cannonical path
-
isSibling
Determines, if two handles are sister-pages, that meens, if they represent the same hierarchic level and share the same parent page.- Parameters:
h1- first handleh2- second handle- Returns:
- true if on same level, false otherwise
-
isDescendant
Determines if thedescendanthandle is hierarchical a descendant ofhandle./content/playground/en isDescendantOf /content/playground /content/playground/en isDescendantOf /content /content/playground/en isNOTDescendantOf /content/designground /content/playground/en isNOTDescendantOf /content/playground/en - Parameters:
handle- the current handledescendant- the potential descendant- Returns:
trueif thedescendantis a descendant;falseotherwise.- Since:
- gumbear
-
isDescendantOrEqual
Determines if thedescendanthandle is hierarchical a descendant ofhandleor equal to it./content/playground/en isDescendantOrEqualOf /content/playground /content/playground/en isDescendantOrEqualOf /content /content/playground/en isDescendantOrEqualOf /content/playground/en /content/playground/en isNOTDescendantOrEqualOf /content/designground - Parameters:
handle- the current handledescendant- the potential descendant- Returns:
trueif thedescendantis a descendant or equal;falseotherwise.- Since:
- gumbear
-
getLabel
Deprecated.usegetName(String)Returns the label of a handle- Parameters:
handle- the handle- Returns:
- the label
-
getLabel
Deprecated.Returns the label of a string- Parameters:
handle- the stringdelim- the delimiter- Returns:
- the label
-
md5
Calculate an MD5 hash of the string given.- Parameters:
data- the data to encodeenc- the character encoding to use- Returns:
- a hex encoded string of the md5 digested input
- Throws:
UnsupportedEncodingException- if the given encoding is not supported
-
md5
Deprecated.Calculate an MD5 hash of the string given.- Parameters:
data- the data to encode- Returns:
- a hex encoded string of the md5 digested input
-
digest
public static String digest(String algorithm, String data, String enc) throws NoSuchAlgorithmException, UnsupportedEncodingException Digest the plain string using the given algorithm.- Parameters:
algorithm- The alogrithm for the digest. This algorithm must be supported by the MessageDigest class.data- The plain text String to be digested.enc- The character encoding to use- Returns:
- The digested plain text String represented as Hex digits.
- Throws:
NoSuchAlgorithmException- if the desired algorithm is not supported by the MessageDigest class.UnsupportedEncodingException- if the encoding is not supported
-
digest
Deprecated.Digest the plain string using the given algorithm.- Parameters:
algorithm- The alogrithm for the digest. This algorithm must be supported by the MessageDigest class.data- The plain text String to be digested.- Returns:
- The digested plain text String represented as Hex digits.
- Throws:
NoSuchAlgorithmException- if the desired algorithm is not supported by the MessageDigest class.
-
digest
Digest the plain string using the given algorithm.- Parameters:
algorithm- The alogrithm for the digest. This algorithm must be supported by the MessageDigest class.data- the data to digest with the given algorithm- Returns:
- The digested plain text String represented as Hex digits.
- Throws:
NoSuchAlgorithmException- if the desired algorithm is not supported by the MessageDigest class.
-
getRelativeParent
Returns the nth relative parent of the handle, where n=level.Example:
Text.getRelativeParent("/en/home/index/about", 1) == "/en/home/index"- Parameters:
handle- the handle of the pagelevel- the level of the parent
-
getAbsoluteParent
Returns the nth absolute parent of the handle, where n=level.Example:
Text.getAbsoluteParent("/en/home/index/about", 1) == "/en/home"- Parameters:
handle- the handle of the pagelevel- the level of the parent
-
escape
Does an URL encoding of thestringusing theescapecharacter. The characters that don't need encoding are those defined 'unreserved' in section 2.3 of the 'URI genric syntax' RFC 2396, but without the escape character.- Parameters:
string- the string to encode.escape- the escape character.- Returns:
- the escaped string
- Throws:
NullPointerException- ifstringisnull.
-
escape
Does an URL encoding of thestringusing theescapecharacter. The characters that don't need encoding are those defined 'unreserved' in section 2.3 of the 'URI genric syntax' RFC 2396, but without the escape character. IfisPathistrue, additionally the slash '/' is ignored, too.- Parameters:
string- the string to encode.escape- the escape character.isPath- iftrue, the string is treated as path- Returns:
- the escaped string
- Throws:
NullPointerException- ifstringisnull.
-
escapeXml
Escapes all character that have specific meaning in XMl/HTML, namely '<', '>', '"', '&' by their isolating encoding aequivalents "<", ">", """, "&"- Parameters:
string- the string to escape- Returns:
- the escaped string or
nullif the input string wasnull
-
escape
Does a URL encoding of thestring. The characters that don't need encoding are those defined 'unreserved' in section 2.3 of the 'URI genric syntax' RFC 2396.- Parameters:
string- the string to encode- Returns:
- the escaped string
- Throws:
NullPointerException- ifstringisnull.
-
escapePath
Does a URL encoding of thepath. The characters that don't need encoding are those defined 'unreserved' in section 2.3 of the 'URI genric syntax' RFC 2396. In contrast to theescape(String)method, not the entire path string is escaped, but every individual part (i.e. the slashes are not escaped).- Parameters:
path- the path to encode- Returns:
- the escaped path
- Throws:
NullPointerException- ifpathisnull.
-
unescape
Does a URL decoding of thestringusing theescapecharacter. Please note that in opposite to theURLDecoderit does not transform the + into spaces.- Parameters:
string- the string to decodeescape- the escape character- Returns:
- the decoded string
- Throws:
NullPointerException- ifstringisnull.ArrayIndexOutOfBoundsException- if not enough character follow an escape characterIllegalArgumentException- if the 2 characters following the escape character do not represent a hex-number.
-
unescape
Does a URL decoding of thestring. Please note that in opposite to theURLDecoderit does not transform the + into spaces.- Parameters:
string- the string to decode- Returns:
- the decoded string
- Throws:
NullPointerException- ifstringisnull.ArrayIndexOutOfBoundsException- if not enough character follow an escape characterIllegalArgumentException- if the 2 characters following the escape character do not represent a hex-number.
-
dateToRfc1123String
Returns a stringified date accoring to the date format specified in RTF1123. this is of the form: "Sun, 06 Nov 1994 08:49:37 GMT" -
strftime
Implements a date formatting routine supporting (a subset) of the POSIXstrftime()function.- Parameters:
date- The date value to be formattedformatPattern- The pattern used to format the date. This pattern supports a subset of the pattern characters of the POSIXstrftime()function. If this pattern is empty ornullthe default patterndd.MM.yyyy HH:mm:ssis used.zone- Defines for which time zone the date should be outputted. If this parameter isnull, then the local time zone is taken.- Returns:
- the formatted date as a String.
-
strftime
Implements a date formatting routine supporting (a subset) of the POSIXstrftime()function.- Parameters:
date- The date value to be formattedformatPattern- The pattern used to format the date. This pattern supports a subset of the pattern characters of the POSIXstrftime()function. If this pattern is empty ornullthe default patterndd.MM.yyyy HH:mm:ssis used.asUTC- Defines whether to interpret the date as belong to the UTC time zone or the local time zone.
-
strftime
Implements a date formatting routine supporting (a subset) of the POSIXstrftime()function. The default patterndd.MM.yyyy HH:mm:ssis used to format the date.- Parameters:
date- The date value to be formattedasUTC- Defines whether to interpret the date as belong to the UTC time zone or the local time zone.
-
strftime
Implements a date formatting routine supporting (a subset) of the POSIXstrftime()function. The default patterndd.MM.yyyy HH:mm:ssis used to format the date, which is interpreted to be in the local time zone.- Parameters:
date- The date value to be formatted
-
parseDate
Parses the date string based on the format pattern which is in the format used by the Java platfrom SimpleDateFormat class.- Parameters:
dateString- The date string to be parsedformatPattern- the pattern to use for parsing. Ifnullor empty, the same default pattern is used as withstrftime(Date, String, boolean), namelydd.MM.yyyy HH:mm:ss.- Throws:
ParseException- if the date string cannot be parsed accordinung to the format pattern.
-
parseDate
public static Date parseDate(String dateString, String formatPattern, boolean isUTC) throws ParseException Parses the date string based on the format pattern which is in the format used by the Java platfrom SimpleDateFormat class.- Parameters:
dateString- The date string to be parsedformatPattern- the pattern to use for parsing. Ifnullor empty, the same default pattern is used as withstrftime(Date, String, boolean), namelydd.MM.yyyy HH:mm:ss.isUTC- iftruethe date string is considered in UTC, otherwise the default timezone of the host is used.- Throws:
ParseException- if the date string cannot be parsed accordinung to the format pattern.
-
parseDate
Parses the date string based on the format pattern which is in the default formatdd.MM.yyyy HH:mm:ss.- Parameters:
dateString- The date string to be parsed- Throws:
ParseException- if the date string cannot be parsed accordinung to the format pattern.
-
parseDate
Parses the date string based on the format pattern which is in the default formatdd.MM.yyyy HH:mm:ss.- Parameters:
dateString- The date string to be parsedisUTC- iftruethe date string is considered in UTC, otherwise the default timezone of the host is used.- Throws:
ParseException- if the date string cannot be parsed accordinung to the format pattern.
-
sprintf
This method implements the famous and ubiquituoussprintfformatter in Java. The arguments to the method are the formatting string and the list of arguments defined by the formatting instructions contained in the formatting string.Each element in the argument array is either a
Numberobject or any otherObjecttype. Whenever the formatting string stipulates the corresponding argument to be numeric, it is assumed this array element to be aNumber. If this is not the case anIllegalArgumentExceptionis thrown. If aStringargument is stipulated by the formatting string, a simple call to thetoString()method of the object yields theStringrequired.SPECIFICATION
sprintfaccepts a series of arguments, applies to each a format specifier fromformat, and stores the formatted data to the resultStrint. The method throws anIllegalArgumentExceptionif either theformatis incorrect, there are not enough arguments for theformator if any of the argument's type is wrong.sprintfreturns when it reaches the end of the format string. If there are more arguments than the format requires, excess arguments are ignored.formatis aStringcontaining two types of objects: ordinary characters (other than%), which are copied unchanged to the output, and conversion specifications, each of which is introduced by%. (To include%in the output, use%%in the format string.) A conversion specification has the following form:[ flags ] [ width ] [ "." prec ] [ size ] typeThe fields of the conversion specification have the following meanings:
- flags
- an optional sequence of characters which control output
justification, numeric signs, decimal points, trailing zeroes, and
octal and hex prefixes. The flag characters are minus (
-), plus (+), space (""), zero (0), and sharp (#). They can appear in any combination.-The result of the conversion is left justified, and the right is padded with blanks. If you do not use this flag, the result is right justified, and padded on the left. +The result of a signed conversion (as determined by type) will always begin with a plus or minus sign. (If you do not use this flag, positive values do not begin with a plus sign.) " " (space)If the first character of a signed conversion specification is not a sign, or if a signed conversion results in no characters, the result will begin with a space. If the space ( ) flag and the plus (+) flag both appear, the space flag is ignored.0If the type is d,i,o,u,x,X,e,E,f,g, orG: leading zeroes, are used to pad the field width (following any indication of sign or base); no spaces are used for padding. If the zero (0) and minus (-) flags both appear, the zero (0) flag will be ignored. Ford,i,o,u,x,Xconversions, if a precision prec is specified, the zero (0) flag is ignored.
Note that 0 is interpreted as a flag, not as the beginning of a field width.#The result is to be converted to an alternative form, according to the type character: o- Increases precision to force the first digit of the result to be a zero.
xXe,E, orfgorG- all others
- Undefined.
- A non-zero result will have a
0xprefix.- A non-zero result will have a
0Xprefix.- The result will always contain a decimal point even if no
digits follow the point. (Normally, a decimal point appears
only if a digit follows it.) Trailing zeroes are removed.
- Same as
eorE, but trailing zeroes arenot removed. - width
- width is an optional minimum field width. You can either
specify it directly as a decimal integer, or indirectly by using instead
an asterisk (
*), in which case an integral numeric argument is used as the field width. Negative field widths are not supported; if you attempt to specify a negative field width, it is interpreted as a minus (i) flag followed by a positive field width. - prec
- an optional field; if present, it is introduced with
`
.' (a period). This field gives the maximum number of characters to print in a conversion; the minimum number of digits of an integer to print, for conversions with typed,i,o,u,x, andX; the maximum number of significant digits, for thegandGconversions; or the number of digits to print after the decimal point, fore,E, andfconversions. You can specify the precision either directly as a decimal integer or indirectly by using an asterisk (*), in which case an integral numeric argument is used as the precision. Supplying a negative precision is equivalent to omitting the precision. If only a period is specified the precision is zero. If a precision appears with any other conversion type than those listed here, the behavior is undefined. - size
h,l, andLare optional size characters which override the default way thatsprintfinterprets the data type of the corresponding argument.hforces the followingd,i,o,u,x, orXconversion type to apply to ashortorunsigned short. Similarily, anlforces the followingd,i,o,u,x, orXconversion type to apply to alongorunsigned long. If anhor anlappears with another conversion specifier, the behavior is undefined.Lforces a followinge,E,f,g, orGconversion type to apply to along doubleargument. IfLappears with any other conversion type, the behavior is undefined.- type
- type specifies what kind of conversion
sprintfperforms. Here is a table of these:%- prints the percent character (
%) c- prints arg as single character. That is the argument is
converted to a
Stringof which only the first character is printed. s- Prints characters until precision is reached or the
Stringends; takes anyObjectwhosetoString()method is called to get theStringto print. d- prints a signed decimal integer; takes a
Number(same asi) d- prints a signed decimal integer; takes a
Number(same asd) d- prints a signed octal integer; takes a
Number u- prints a unsigned decimal integer; takes a
Number. This conversion is not supported correctly by the Java implementation and is really the same asi. x- prints an unsigned hexadecimal integer (using abcdef as
digits beyond 9; takes a
Number X- prints an unsigned hexadecimal integer (using ABCDEF as
digits beyond 9; takes a
Number f- prints a signed value of the form [-]9999.9999; takes a
Number e- prints a signed value of the form [-]9.9999e[+|-]999; takes
a
Number E- prints the same way as
e, but using E to introduce the exponent; takes aNumber g- prints a signed value in either
foreform, based on given value and precision &emdash; trailing zeros and the decimal point are printed only if necessary; takes aNumber G- prints the same way as
g, but usingEfor the exponent if an exponent is needed; takes aNumber n- Not supported in the Java implementation, throws an
IllegalArgumentExceptionif used. p- Not supported in the Java implementation, throws an
IllegalArgumentExceptionif used.
IMPLEMENTATION NOTES
Due to the nature of the Java programming language, neither pointer conversions, nor
unsignedandlong doubleconversions are supported.Also the Java implementation only distinguishes between
Numberand otherObjectarguments. If a numeric argument is expected as per theformatString, the current argument must be aNumberobject that is converted to a basic type as expected. If aStringorcharargument is expected, any Object is valid, whosetoString()method is used to convert to aString.- Parameters:
format- The format string as known from the POSIX sprintf() C function.args- The list of arguments to accomodate the format string. This argument list is supposed to contain at least as much entries as there are formatting options in the format string. If for a numeric option, the entry is not a number anIllegalArgumentExceptionis thrown.- Returns:
- The formatted
String. An emptyStringis only returned if theformatStringis empty. Anullvalue is never returned. - Throws:
NullPointerException- if the formatting string or any of the argument values isnull.IllegalArgumentException- if the formatting string has wrong format tags, if the formatting string has an incomplete formatting pattern at the end of the string, if the argument vector has not enough values to satisfy the formatting string or if an argument's type does not match the requirements of the format string.
-
sprintf
Formats a string according to format and argument. This method only supports string formats. Seesprintf(String, Object[])for details.- Parameters:
format- The format stringa0- The single parameter- Returns:
- the result from
sprintf(format, new Object[]{ a0 }). - Throws:
IllegalArgumentException- fromsprintf(String, Object[]).
-
sprintf
Formats a string according to format and argument. This method only supports string formats. Seesprintf(String, Object[])for details.- Parameters:
format- The format stringa0- The first parametera1- The second parameter- Returns:
- the result from
sprintf(format, new Object[]{ ... }). - Throws:
IllegalArgumentException- fromsprintf(String, Object[]).
-
sprintf
Formats a string according to format and argument. This method only supports string formats. Seesprintf(String, Object[])for details.- Parameters:
format- The format stringa0- The first parametera1- The second parametera2- The thrid parameter- Returns:
- the result from
sprintf(format, new Object[]{ ... }). - Throws:
IllegalArgumentException- fromsprintf(String, Object[]).
-
sprintf
Formats a string according to format and argument. This method only supports string formats. Seesprintf(String, Object[])for details.- Parameters:
format- The format stringa0- The first parametera1- The second parametera2- The thrid parametera3- The fourth parameter- Returns:
- the result from
sprintf(format, new Object[]{ ... }). - Throws:
IllegalArgumentException- fromsprintf(String, Object[]).
-
sprintf
Formats a string according to format and argument. This method only supports string formats. Seesprintf(String, Object[])for details.- Parameters:
format- The format stringa0- The first parametera1- The second parametera2- The thrid parametera3- The fourth parametera4- The fifth parameter- Returns:
- the result from
sprintf(format, new Object[]{ ... }). - Throws:
IllegalArgumentException- fromsprintf(String, Object[]).
-
createValidLabel
Create a valid label out of an arbitrary string.- Parameters:
labelhint- the given label string that we will examine and convert any illegal character if necessary- Returns:
- a valid label string
-
validateLabel
Checks if the label is not empty and contains all valid label chars.- Parameters:
labelhint- the labelhint to check- Throws:
IllegalArgumentException- if the label does not contain all valid chars.
-
joinFixSlash
Deprecated.Join two paths or handles, fixing the slashes. All these will go to "/a/b": /a/ + /b/ (trailing slashes are removed) /a + /b /a/ + b /a/ + b/ /a// + /////b (i am paranoid) Note that leading slashes are untouched, so variations on the above without the leading slash on 'a' would go to "a/b". -
replaceVariables
public static String replaceVariables(Properties variables, String value, boolean ignoreMissing) throws IllegalArgumentException Performs variable replacement on the given string value. Each${...}sequence within the given value is replaced with the value of the named parser variable. If a variable is not found in the properties an IllegalArgumentException is thrown unlessignoreMissingistrue. In the later case, the missing variable is replaced by the empty string.- Parameters:
value- the original valueignoreMissing- iftrue, missing variables are replaced by the empty string.- Returns:
- value after variable replacements
- Throws:
IllegalArgumentException- if the replacement of a referenced variable is not found
-
parseISO8601
Parses an ISO8601-compliant date/time string. (see ISO 8601). The currently supported format is:±YYYY-MM-DDThh:mm:ss.SSSTZD
where:±YYYY = four-digit year with optional sign where values invalid input: '<'= 0 are denoting years BCE and values > 0 are denoting years CE, e.g. -0001 denotes the year 2 BCE, 0000 denotes the year 1 BCE, 0001 denotes the year 1 CE, and so on... MM = two-digit month (01=January, etc.) DD = two-digit day of month (01 through 31) hh = two digits of hour (00 through 23) (am/pm NOT allowed) mm = two digits of minute (00 through 59) ss = two digits of second (00 through 59) SSS = three digits of milliseconds (000 through 999) TZD = time zone designator, Z for Zulu (i.e. UTC) or an offset from UTC in the form of +hh:mm or -hh:mm- Parameters:
text- the date/time string to be parsed- Returns:
- a
Calendar, ornullif the input could not be parsed - Throws:
IllegalArgumentException- if anullargument is passed
-
formatISO8601
Formats aCalendarvalue into an ISO8601-compliant date/time string.- Parameters:
cal- the time value to be formatted into a date/time string.- Returns:
- the formatted date/time string.
- Throws:
IllegalArgumentException- if anullargument is passed
-
digest(String, String, String)