public class Util
extends java.lang.Object
Various static utility methods.
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
asJavaIdentifier(java.lang.String pIdentifier)
Takes as input an arbitrary String and maps it to a String,
which is a valid Java identifier.
|
static void |
checkJavaIdentifier(java.lang.String pName)
Returns whether the given name is a valid Java identifier.
|
static JavaSource |
newJavaSource(JavaSourceFactory pFactory,
java.lang.Class pClass)
Converts the given class into an instance of
JavaSource . |
public static void checkJavaIdentifier(java.lang.String pName)
Returns whether the given name is a valid Java identifier.
Works by using Character.isJavaIdentifierStart(char)
and
Character.isJavaIdentifierPart(char)
.
java.lang.IllegalArgumentException
- The name is not valid. An explanation
why is given in the detail message.public static java.lang.String asJavaIdentifier(java.lang.String pIdentifier)
Takes as input an arbitrary String and maps it to a String, which is a valid Java identifier. Mapping works as follows:
Character.isJavaIdentifierStart(char)
.
If that method returns false, replaces the character with an
underscore ('_').Character.isJavaIdentifierPart(char)
.
If that method returns false, replaces the character with an
underscore ('_').pIdentifier
- The identifier being mappedjava.lang.IllegalArgumentException
- The parameter pIdentifier
cannot be converted into a Java identifier, because it is null or
empty.public static JavaSource newJavaSource(JavaSourceFactory pFactory, java.lang.Class pClass)
JavaSource
.