public class JJavaName
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
JJavaName.Entry |
Modifier and Type | Field and Description |
---|---|
private static java.util.HashSet<java.lang.String> |
reservedKeywords
All reserved keywords of Java.
|
private static JJavaName.Entry[] |
TABLE |
Constructor and Description |
---|
JJavaName() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getPluralForm(java.lang.String word)
Experimental API: converts an English word into a plural form.
|
static boolean |
isFullyQualifiedClassName(java.lang.String s)
Checks if the given string is a valid fully qualified name.
|
static boolean |
isJavaIdentifier(java.lang.String s)
Checks if a given string is usable as a Java identifier.
|
static boolean |
isJavaPackageName(java.lang.String s)
Checks if the given string is a valid Java package name.
|
private static java.util.HashSet<java.lang.String> reservedKeywords
private static final JJavaName.Entry[] TABLE
public static boolean isJavaIdentifier(java.lang.String s)
public static boolean isFullyQualifiedClassName(java.lang.String s)
public static boolean isJavaPackageName(java.lang.String s)
public static java.lang.String getPluralForm(java.lang.String word)
word
- a word, such as "child", "apple". Must not be null.
It accepts word concatanation forms
that are common in programming languages, such as "my_child", "MyChild",
"myChild", "MY-CHILD", "CODE003-child", etc, and mostly tries to do the right thing.
("my_children","MyChildren","myChildren", and "MY-CHILDREN", "CODE003-children" respectively)
Although this method only works for English words, it handles non-English words gracefully (by just returning it as-is.) For example, 日本語 will be returned as-is without modified, not "日本語s"
This method doesn't handle suffixes very well. For example, passing "person56" will return "person56s", not "people56".