org.jmol.util

Class TextFormat

public class TextFormat extends Object

Field Summary
static DecimalFormat[]formatters
static String[]formattingStrings
static Boolean[]useNumberLocalization
Method Summary
static Stringformat(float value, int width, int precision, boolean alignLeft, boolean zeroPad)
static Stringformat(String value, int width, int precision, boolean alignLeft, boolean zeroPad)
static StringformatDecimal(float value, int decimalDigits)
static StringformatString(String strFormat, String key, String strT)
static StringformatString(String strFormat, String key, float floatT)
static StringformatString(String strFormat, String key, int intT)
static StringformatString(String strFormat, String key, String strT, float floatT)
static StringformatString(String strFormat, String key, String strT, float floatT, boolean doOne)
generic string formatter based on formatLabel in Atom
static booleanisMatch(String s, String strWildcard, boolean checkStar, boolean allowInitialStar)
static booleanisWild(String s)
static voidlFill(StringBuffer s, String s1, String s2)
static StringreplaceAllCharacters(String str, String strFrom, String strTo)
Does a clean replace of any of the characters in str with strTo If strTo contains strFrom, then only a single pass is done.
static StringreplaceAllCharacters(String str, String strFrom, char chTo)
Does a clean replace of any of the characters in str with chrTo If strTo contains strFrom, then only a single pass is done.
static voidrFill(StringBuffer s, String s1, String s2)
static StringsafeTruncate(float f, int n)
static voidsetUseNumberLocalization(boolean TF)
static StringsimpleReplace(String str, String strFrom, String strTo)
Does a clean replace of strFrom in str with strTo If strTo contains strFrom, then only a single pass is done.
static String[]split(String text, String run)
proper splitting, even for Java 1.3 -- if the text ends in the run, no new line is appended.
static String[]split(String text, char ch)
static Stringsprintf(String strFormat, Object[] values)
static Stringsprintf(String strFormat, String[] sVal, float[] fVal)
static Stringsprintf(String strFormat, String[] sVal, float[] fVal, int[] iVal)
static Stringtrim(String str, String chars)

Field Detail

formatters

private static final DecimalFormat[] formatters

formattingStrings

private static final String[] formattingStrings

useNumberLocalization

private static final Boolean[] useNumberLocalization

Method Detail

format

public static String format(float value, int width, int precision, boolean alignLeft, boolean zeroPad)

format

public static String format(String value, int width, int precision, boolean alignLeft, boolean zeroPad)

formatDecimal

public static String formatDecimal(float value, int decimalDigits)

formatString

public static String formatString(String strFormat, String key, String strT)

formatString

public static String formatString(String strFormat, String key, float floatT)

formatString

public static String formatString(String strFormat, String key, int intT)

formatString

public static String formatString(String strFormat, String key, String strT, float floatT)

formatString

private static String formatString(String strFormat, String key, String strT, float floatT, boolean doOne)
generic string formatter based on formatLabel in Atom

Parameters: strFormat .... %width.precisionKEY.... key any string to match strT replacement string or null floatT replacement float or Float.NaN doOne mimic sprintf

Returns: formatted string

isMatch

public static boolean isMatch(String s, String strWildcard, boolean checkStar, boolean allowInitialStar)

isWild

public static boolean isWild(String s)

lFill

public static void lFill(StringBuffer s, String s1, String s2)

replaceAllCharacters

public static String replaceAllCharacters(String str, String strFrom, String strTo)
Does a clean replace of any of the characters in str with strTo If strTo contains strFrom, then only a single pass is done. Otherwise, multiple passes are made until no more replacements can be made.

Parameters: str strFrom strTo

Returns: replaced string

replaceAllCharacters

public static String replaceAllCharacters(String str, String strFrom, char chTo)
Does a clean replace of any of the characters in str with chrTo If strTo contains strFrom, then only a single pass is done. Otherwise, multiple passes are made until no more replacements can be made.

Parameters: str strFrom chTo

Returns: replaced string

rFill

public static void rFill(StringBuffer s, String s1, String s2)

safeTruncate

public static String safeTruncate(float f, int n)

setUseNumberLocalization

public static void setUseNumberLocalization(boolean TF)

simpleReplace

public static String simpleReplace(String str, String strFrom, String strTo)
Does a clean replace of strFrom in str with strTo If strTo contains strFrom, then only a single pass is done. Otherwise, multiple passes are made until no more replacements can be made.

Parameters: str strFrom strTo

Returns: replaced string

split

public static String[] split(String text, String run)
proper splitting, even for Java 1.3 -- if the text ends in the run, no new line is appended.

Parameters: text run

Returns: String array

split

public static String[] split(String text, char ch)

sprintf

public static String sprintf(String strFormat, Object[] values)

sprintf

public static String sprintf(String strFormat, String[] sVal, float[] fVal)

sprintf

public static String sprintf(String strFormat, String[] sVal, float[] fVal, int[] iVal)

trim

public static String trim(String str, String chars)