PulpCore

pulpcore.util
Class StringUtil

java.lang.Object
  extended by pulpcore.util.StringUtil

public final class StringUtil
extends Object

Provides utilities for manipulating and formatting text strings.


Method Summary
static boolean equals(String arg1, String arg2)
          Safe equality check for two strings.
static String format(String message, Object arg)
          Calls StringUtil.format(message, new Object[] { arg });
static String format(String message, Object[] args)
          Formats a text string converting codes with string arguments.
static String ltrim(String s)
           
static String replace(String str, String target, String replacement)
          Replace all instances of target in string str with the replacement string.
static String rtrim(String s)
           
static String[] split(String line, char delimiter)
          Splits a string into an array of strings seperated by the specified delimiter.
static String[] wordWrap(String text, CoreFont font, int maxWidth)
          Word-wraps a line of text to multiple lines.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

rtrim

public static String rtrim(String s)

ltrim

public static String ltrim(String s)

format

public static String format(String message,
                            Object arg)
Calls StringUtil.format(message, new Object[] { arg });


format

public static String format(String message,
                            Object[] args)
Formats a text string converting codes with string arguments.

Conversion Description
%s Any object converted to a string. ("Hello World")
%d An integer - Integer, Int, or Fixed (rounded). ("1000")
%,d An integer with a grouping seperator. ("1,000")
%f Fixed-point number. ("1000.12345")
%,f Fixed-point number with a grouping seperator. ("1,000.12345")
%.2f Fixed-point number with a specific number of digits after the decimal ("1000.12")
%,.2f Fixed-point number with a grouping seperator and a specific number of digits ("1,000.12")
%% The percent character.

Example: format("Name: %s Score: %,d", new Object[] {"Fred", new Integer(1000)}); returns "Name: Fred Score: 1,000"


replace

public static String replace(String str,
                             String target,
                             String replacement)
Replace all instances of target in string str with the replacement string.


wordWrap

public static String[] wordWrap(String text,
                                CoreFont font,
                                int maxWidth)
Word-wraps a line of text to multiple lines. Newline characters ('\n') can be used for explicit line breaks.


split

public static String[] split(String line,
                             char delimiter)
Splits a string into an array of strings seperated by the specified delimiter. The delimiter is not included in the returned string. If the line is null or has a length of zero, an array of length zero is returned.


equals

public static boolean equals(String arg1,
                             String arg2)
Safe equality check for two strings. Returns true if two strings are null or if two non-null strings are equal. Returns false if only one string is null or if two non-null strings are not equal.


PulpCore

Copyright © 2007-2009 Interactive Pulp, LLC.