org.apache.openjpa.persistence.util
Class SourceCode

java.lang.Object
  extended by org.apache.openjpa.persistence.util.SourceCode

public class SourceCode
extends Object

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.

Since:
2.0.0
Author:
Pinaki Poddar

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.
 class SourceCode.Element<T>
          Abstract element has a name, optional list of modifiers, annotations and arguments.
 class SourceCode.Field
          Represents field declaration.
 
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)
           
 org.apache.openjpa.persistence.util.SourceCode.Package getPackage()
           
 SourceCode.Class getTopLevelClass()
          Gets the top level class represented by this receiver.
static boolean isJavaIdentifier(String s)
           
static boolean isKnownType(String s)
           
 SourceCode setTabSize(int t)
          Sets the tab size.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMA

public static final String COMMA
See Also:
Constant Field Values

DOT

public static final String DOT
See Also:
Constant Field Values

EQUAL

public static final String EQUAL
See Also:
Constant Field Values

QUOTE

public static final String QUOTE
See Also:
Constant Field Values
Constructor Detail

SourceCode

public SourceCode(String c)
Create source code for a top-level class with given fully-qualified class name.

Method Detail

getTopLevelClass

public SourceCode.Class getTopLevelClass()
Gets the top level class represented by this receiver.


getPackage

public org.apache.openjpa.persistence.util.SourceCode.Package getPackage()

setTabSize

public SourceCode setTabSize(int t)
Sets the tab size. Tabs are always written as spaces.


addComment

public SourceCode addComment(boolean inline,
                             String... lines)

write

public void write(PrintWriter out)
Prints the class to the given Writer.

Parameters:
out -

wrap

public static String[] wrap(String longLine,
                            int width)
Wraps the given string into lines of max length width at word boundaries


isKnownType

public static boolean isKnownType(String s)

isJavaIdentifier

public static boolean isJavaIdentifier(String s)


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.