|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.openjpa.persistence.util.SourceCode
public class SourceCode
A utility to help writing Java Source code dynamically. Provides basic elements of Java Source Code e.g. Package, Class, Field, Method, Import, Annotation, Argument. Mutator methods return the operating element for easy chaining.
Nested Class Summary | |
---|---|
static class |
SourceCode.ACCESS
|
class |
SourceCode.Annotation
Represents annotation. |
class |
SourceCode.Argument<K,V>
Represents method argument. |
class |
SourceCode.Class
Represent class declaration. |
(package private) class |
SourceCode.Comment
|
(package private) static class |
SourceCode.Delimiter
|
class |
SourceCode.Element<T>
Abstract element has a name, optional list of modifiers, annotations and arguments. |
class |
SourceCode.Field
Represents field declaration. |
(package private) class |
SourceCode.Import
Represents import statement. |
(package private) class |
SourceCode.Method
Represents Method declaration. |
(package private) static class |
SourceCode.Package
|
Field Summary | |
---|---|
static String |
COMMA
|
static String |
DOT
|
static String |
EQUAL
|
static String |
QUOTE
|
Constructor Summary | |
---|---|
SourceCode(String c)
Create source code for a top-level class with given fully-qualified class name. |
Method Summary | |
---|---|
SourceCode |
addComment(boolean inline,
String... lines)
|
(package private) static String |
capitalize(String s)
|
(package private) org.apache.openjpa.persistence.util.SourceCode.ClassName |
getOrCreateImport(String name)
Get the class name instance for the given fully-qualified class name. |
SourceCode.Package |
getPackage()
|
SourceCode.Class |
getTopLevelClass()
Gets the top level class represented by this receiver. |
(package private) static boolean |
isEmpty(String s)
|
static boolean |
isJavaIdentifier(String s)
|
static boolean |
isKnownType(String s)
|
(package private) static boolean |
isValidToken(String s)
|
SourceCode |
setTabSize(int t)
Sets the tab size. |
(package private) static void |
tab(PrintWriter out,
int tab)
Outputs tab number of spaces. |
(package private) static LinkedList<String> |
tokenize(String s,
String delim)
|
static String[] |
wrap(String longLine,
int width)
Wraps the given string into lines of max length width at word boundaries |
void |
write(PrintWriter out)
Prints the class to the given Writer. |
(package private) static void |
writeList(PrintWriter out,
String header,
List<?> list)
|
(package private) static void |
writeList(PrintWriter out,
String header,
List<?> list,
SourceCode.Delimiter bracket,
boolean writeEmpty)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String COMMA
public static final String DOT
public static final String EQUAL
public static final String QUOTE
Constructor Detail |
---|
public SourceCode(String c)
Method Detail |
---|
public SourceCode.Class getTopLevelClass()
public SourceCode.Package getPackage()
public SourceCode setTabSize(int t)
org.apache.openjpa.persistence.util.SourceCode.ClassName getOrCreateImport(String name)
name
- fully-qualified name of a class
addImport(ClassName)
,
ClassName
public SourceCode addComment(boolean inline, String... lines)
public void write(PrintWriter out)
out
- static void tab(PrintWriter out, int tab)
tab
number of spaces.
public static String[] wrap(String longLine, int width)
static void writeList(PrintWriter out, String header, List<?> list)
static void writeList(PrintWriter out, String header, List<?> list, SourceCode.Delimiter bracket, boolean writeEmpty)
static String capitalize(String s)
static boolean isValidToken(String s)
public static boolean isKnownType(String s)
static boolean isEmpty(String s)
static LinkedList<String> tokenize(String s, String delim)
public static boolean isJavaIdentifier(String s)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |