|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.blackperl.Perl.Lcfirst
Static-method implementation of the Perl lcfirst keyword.
The class provides several static methods to emulate Perl's
lcfirst. In keeping with the philosophy of not directly
replicating Java functionality, there is no implementation of
lc. Rather, the developer should use the
toLowerCase method of the String class.
The methods actually use the toLowerCase method
to do the needed conversions. Thus, each version
of lcfirst also has a form that takes a Locale
object as an additional parameter, to dictate the rules for converting the
characters to lower-case.
Some simple examples:
import com.blackperl.Perl.Lcfirst;
String name = "PmOdE";
String bettername = Lcfirst.lcfirst(name.toUpperCase());
// bettername is now "pMODE".
name = "name";
name = Lcfirst.lcfirst(name); // Effectively unchanged
This implementation departs slightly from the Perl model in the following
way: if the parameter given is a StringBuffer rather than a
String, it will modify the parameter itself, directly. The
return value will still be a String object, but the
StringBuffer will also have the same stringified value as the
returned string:
import com.blackperl.Perl.Lcfirst;
StringBuffer name = new StringBuffer("PMODE");
String bettername = Lcfirst.lcfirst(name);
// bettername == name.toString() == "pMODE"
All components in this package provide an instance method to
retrieve a singleton object which may be used to call the static methods,
if the programmer prefers using an object to static invocation.
If this is the JDK 1.5 ("Tiger") edition of the package, this class is suitable for use via static import:
import com.blackperl.Perl.Lcfirst.lcfirst;
String name = "PmOdE";
String bettername = lcfirst(name.toUpperCase());
// bettername is now "pMODE".
| Method Summary | |
static com.blackperl.Perl.Lcfirst |
instance()
The instance method is used to retrieve the
Lcfirst singleton that applications can use in lieu of
invoking the methods statically. |
static java.lang.String |
lcfirst(java.lang.String string)
Take the String parameter and return a new
String whose first character has been made lower-case, if
the character is in fact alphabetic. |
static java.lang.String |
lcfirst(java.lang.StringBuffer buffer)
This form is a slight departure from the Perl equivalent, in that it actually modifies the argument in-place. |
static java.lang.String |
lcfirst(java.lang.StringBuffer buffer,
java.util.Locale locale)
This form is a slight departure from the Perl equivalent, in that it actually modifies the argument in-place. |
static java.lang.String |
lcfirst(java.lang.String string,
java.util.Locale locale)
Take the String parameter and return a new
String whose first character has been made lower-case, if
the character is in fact alphabetic. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static com.blackperl.Perl.Lcfirst instance()
instance method is used to retrieve the
Lcfirst singleton that applications can use in lieu of
invoking the methods statically.
public static java.lang.String lcfirst(java.lang.String string)
String parameter and return a new
String whose first character has been made lower-case, if
the character is in fact alphabetic. This uses the default locale to
determine the correct way to convert to lower-case. Since the argument
is immutable, it itself is not changed.
string - The String to convert (not changed)
public static java.lang.String lcfirst(java.lang.StringBuffer buffer)
String copy
of the converted value.
buffer - The StringBuffer to operate on
String copy of the converted value
public static java.lang.String lcfirst(java.lang.StringBuffer buffer,
java.util.Locale locale)
Locale parameter (if the character is not alphabetic, it
is unchanged). Returns a String copy of the converted
value.
buffer - The StringBuffer to operate onlocale - A Locale object for lower-case rules
String copy of the converted value
public static java.lang.String lcfirst(java.lang.String string,
java.util.Locale locale)
String parameter and return a new
String whose first character has been made lower-case, if
the character is in fact alphabetic. The Locale parameter
determines the correct way to convert to lower-case. Since the argument
is immutable, it itself is not changed.
string - The String to convert (not changed)locale - A Locale object for lower-case rules
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||