Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.openjpa.persistence.util
Class SourceCode

    java.lang.Object
      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.
`(package private) class` | `SourceCode.Comment`
`class` | `SourceCode.Constructor`
`(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.
`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)`
`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

### 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 SourceCode.Package getPackage()

### setTabSize

    public SourceCode setTabSize(int t)

  Sets the tab size. Tabs are always written as spaces.

### getOrCreateImport

    public org.apache.openjpa.persistence.util.SourceCode.ClassName getOrCreateImport(String name)

  Get the class name instance for the given fully-qualified class name. If the given class name is already imported, then use the existing instance. Otherwise, creates a new instance and adds it to list of imports.

  Parameters:
    `name` - fully-qualified name of a class
  Returns:
    an existing class name instance or a new one.
  See Also:
    `addImport(ClassName)`, `ClassName`

### addComment

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

### write

    public void write(PrintWriter out)

  Prints the class to the given Writer.

  Parameters:
    `out` -

### tab

    static void tab(PrintWriter out,
                    int tab)

  Outputs `tab` number of spaces.

### wrap

    public static String[] wrap(String longLine,
                                int width)

  Wraps the given string into lines of max length width at word boundaries

### writeList

    static void writeList(PrintWriter out,
                          String header,
                          List<?> list)

### writeList

    static void writeList(PrintWriter out,
                          String header,
                          List<?> list,
                          SourceCode.Delimiter bracket,
                          boolean writeEmpty)

### capitalize

    static String capitalize(String s)

### isValidToken

    static boolean isValidToken(String s)

### isKnownType

    public static boolean isKnownType(String s)

### isEmpty

    static boolean isEmpty(String s)

### tokenize

    static LinkedList<String> tokenize(String s,
                                       String delim)

### isJavaIdentifier

    public static boolean isJavaIdentifier(String s)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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