Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

burst.Text Class Reference

List of all members.

Detailed Description

Scoping class to hold static utilities for String.


Static Public Member Functions

String doubleEscape (String s)
 replace all backslashes with two backslashes

String quote (String str, Boolean escapeEOL, Boolean notIfIdent)
 produce a valid quoted string.

Boolean endsWith (String s, String s2)
 Return true if s ends with s2.

Boolean startsWith (String s, String s2)
 Return true if s starts with s2.

String ltrim (String s)
 Trim any leading white space.

String trim (String s)
 Trim leading and trailing white space TODO: compare speed of bu_trim* alternatives.

Boolean isWhite (String s)
 Return true if s is false, empty, or entirely white space.

Array splitTerms (String s, String tokenre)
 Split the string into an Array of terms.

String unquote (String s)
 Remote any surrounding quotes (single or double).

String ellipsis (String s, Number maxlen)
 If string length is less than or equal maxlen, return it.

Boolean isDigit (String s)
 True if the given string is a digit char ([0-9]).

Boolean isLetter (String s)
 True if the given string is a letter char ([a-zA-Z]).

String zeroPad (Object s, Number len)
 Returns a String with enough leading zeros to make it a total length len.

String spacePad (Object s, Number len, Boolean is_lj)
 space pad to length len.

Number fprintf (Writer writer, String fmt,...)
 Formatted output to the Writer writer.

String sprintf (String fmt,...)
 Return the sprintf result as a String.


Member Function Documentation

String burst.Text.ellipsis String  s,
Number  maxlen
[static]
 

If string length is less than or equal maxlen, return it.

Otherwise truncate string to maxlen and append '...' (so total length is maxlen + 3).

Number burst.Text.fprintf Writer  writer,
String  fmt,
... 
[static]
 

Formatted output to the Writer writer.

Supported flags: "0" zero padding right justify, such as "%0d" "-" left justify, such as "%-10s" " " blank for positive signed conversion, such as "% d" "+" sign for positive signed conversion, such as "%+d" "#" alternative form ("%#x") prepend '0' if necessary for 'o' prepend '0x' for 'x' and '0X' for 'X' ensure a decimal point for aAeEfgG do not remove trailing zeros for gG

Unsupported flags: "'" use a thousands grouping character, if the locale says so (SUSv2 standard)

Supported widths: "10" minimum field width (left justified if "%-10s") ".5" precision = for 'diouxX', minimum number of digits for zero padding, rest is space on left or right according to "-" flag for 'eEf', number of digits after decimal for 'gG', number of sig digits for either decimal or exponential notation for 's', maximum number of characters to truncate at

Unsupported length modifiers (any of these): "h" short, "l" long "ll" long long "L" long double

Supported conversion specifiers: s string c unsigned char bdiouxX int, various bases (b is non-standard, for base 2) eE double, exponential notation f double, decimal notation gG f or e according to exponent (f or E if "G") an escaped '%'

Unsupported conversion specifiers: DOU long int aA double exponential hex notation p pointer n number of characters written so far stored in the argument

Supported arguments: non-positional arguments ("%*s" or "%.*s" for width or precision) negative width value means lj; negative precision means unspecified

Unsupported arguments: positional arguments ("%3$s" or "%*1$s" or "%.*2$s" for arg or width or precision)

Returns number of characters written for fprintf, and the string for sprintf.

CAVEATS: for 'uboxX' specifiers, we convert negative args to 32-bit unsigned by (0xffffffff + i + 1) we currently format double NaN and +-infinity as if they were 0 (pre-C99 convention)

BUGS: the known unsupported items that are meaningful in JavaScript are positional arguments and thousands grouping

TODO: would toLocaleString help with implementing SUSv2 ' radic?

See also: Mavi Gozler (mavigozler@yahoo.com ) http://groups.google.com/groups?threadm=5446f761.0211181406.4a0388b0%40posting.google.com&rnum=8

Note that ECMAScript 262-3 has Number.toFixed(), Number.toExponential(), Number.toPrecision() These are not available in IE 5.0 PC or Safari1, but are implemented in fix_ecma.js.

The implementation here relies on String.replace(searchValue, replaceValue) with replaceValue being a function. Many ECMAScript environments do not support this properly, despite it being standard. An implementation is available in fix_ecma.js.

String burst.Text.ltrim String  s  )  [static]
 

Trim any leading white space.

Here "white space" means matching , which in EcmaScript means any white space or line terminator:

TB 0x09 9 VT 0x0B 11 FF 0x0C 12 SP 0x20 32 (any unicode "space separator") LF 0x0A 10 CR 0x0D 15 LS 0x2028 PS 0x2029
Note that java.lang.String.trim will remove all characters <32. This is more aggressive than .

String burst.Text.quote String  str,
Boolean  escapeEOL,
Boolean  notIfIdent
[static]
 

produce a valid quoted string.

Internal quotes and backslashes are escaped with backslash. If escapeEOL is true, single character "\n" is converted to two characters.

Remember that eval("\"\\\"").length == 1

Parameters:
str The input string.
escapeEOL optional. If true, "\n" as single character becomes two.
notIfIdent optional. if true, just return the argument if it is a legal JS identifier.

String burst.Text.spacePad Object  s,
Number  len,
Boolean  is_lj
[static]
 

space pad to length len.

Parameters:
s The input string; if not a string it is converted.
len The intended output length.
is_lj Optional, defaults to false, whether to left-justify in the field.

Array burst.Text.splitTerms String  s,
String  tokenre
[static]
 

Split the string into an Array of terms.

A term is either an unquoted single-word token, or is a quoted string (single or double quotes). No white space is preserved except within quoted strings. The surrounding quotes on quoted terms are preserved.

String burst.Text.zeroPad Object  s,
Number  len
[static]
 

Returns a String with enough leading zeros to make it a total length len.

If the input s is not a string it is made into one.


The documentation for this class was generated from the following file:
Generated on Tue Nov 30 04:03:08 2004 for BurstProject by doxygen 1.3.4