com.threerings.presents.tools
Class GenUtil

java.lang.Object
  extended by com.samskivert.util.GenUtil
      extended by com.threerings.presents.tools.GenUtil

public class GenUtil
extends GenUtil

Utility methods used by our various source code generating tasks.


Field Summary
static Pattern NAME_PATTERN
          A regular expression for matching the class or interface declaration.
static Pattern PACKAGE_PATTERN
          A regular expression for matching the package declaration.
 
Constructor Summary
GenUtil()
           
 
Method Summary
static String boxArgument(Class<?> clazz, String name)
          "Boxes" the supplied argument, ie.
static String boxASArgument(Class<?> clazz, String name)
          "Boxes" the supplied argument, ie.
static String cloneArgument(Class<?> dsclazz, Field field, String name)
          Potentially clones the supplied argument if it is the type that needs such treatment.
static String getGeneratedAnnotation(Class<?> clazz, int indent, boolean includeDate, String... comments)
          Return an "@Generated" annotation.
static String readClassName(File source)
          Reads in the supplied source file and locates the package and class or interface name and returns a fully qualified class name.
static String simpleASName(Class<?> clazz)
          Returns the name of the supplied class as it would appear in ActionScript code using the class (no package prefix, arrays specified as ArrayArray).
static String unboxArgument(Type type, String name)
          "Unboxes" the supplied argument, ie.
static String unboxASArgument(Class<?> clazz, String name)
          "Unboxes" the supplied argument, ie.
 
Methods inherited from class com.samskivert.util.GenUtil
simpleName, simpleName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PACKAGE_PATTERN

public static final Pattern PACKAGE_PATTERN
A regular expression for matching the package declaration.


NAME_PATTERN

public static final Pattern NAME_PATTERN
A regular expression for matching the class or interface declaration.

Constructor Detail

GenUtil

public GenUtil()
Method Detail

simpleASName

public static String simpleASName(Class<?> clazz)
Returns the name of the supplied class as it would appear in ActionScript code using the class (no package prefix, arrays specified as ArrayArray).


boxArgument

public static String boxArgument(Class<?> clazz,
                                 String name)
"Boxes" the supplied argument, ie. turning an int into an Integer object.


unboxArgument

public static String unboxArgument(Type type,
                                   String name)
"Unboxes" the supplied argument, ie. turning an Integer object into an int.


boxASArgument

public static String boxASArgument(Class<?> clazz,
                                   String name)
"Boxes" the supplied argument, ie. turning an int into an Integer object.


unboxASArgument

public static String unboxASArgument(Class<?> clazz,
                                     String name)
"Unboxes" the supplied argument, ie. turning an Integer object into an int.


cloneArgument

public static String cloneArgument(Class<?> dsclazz,
                                   Field field,
                                   String name)
Potentially clones the supplied argument if it is the type that needs such treatment.


readClassName

public static String readClassName(File source)
                            throws IOException
Reads in the supplied source file and locates the package and class or interface name and returns a fully qualified class name.

Throws:
IOException

getGeneratedAnnotation

public static String getGeneratedAnnotation(Class<?> clazz,
                                            int indent,
                                            boolean includeDate,
                                            String... comments)
Return an "@Generated" annotation.

Parameters:
clazz - the class doing the code generation, NOT the generation target.
indent - the number of spaces that the annotation is indented.
includeDate - include the date?
comments - joined by a space and used as explanatory comments.


Copyright © 2011. All Rights Reserved.