com.legstar.codegen
Class CodeGenHelper

java.lang.Object
  extended by com.legstar.codegen.CodeGenHelper

public class CodeGenHelper
extends Object

Provides the generator with convenience methods. The class can be passed as an instance to the velocity engine and used by templates.


Constructor Summary
CodeGenHelper()
           
 
Method Summary
 String getClassName(String qualClassName)
          Get the simple class name from a fully qualified class name.
 String getPackageName(String qualClassName, String defaultPackageName)
          Determines the package name of a fully qualified class name.
 String getQualClassName(String packageName, String className)
          Get a fully qualified class name.
 boolean isEmpty(String str)
          Checks a string for emptiness.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeGenHelper

public CodeGenHelper()
Method Detail

isEmpty

public boolean isEmpty(String str)
Checks a string for emptiness. This is needed because velocity cannot check for nulls.

Parameters:
str - the string to check
Returns:
true if the string has a content (not empty)

getPackageName

public String getPackageName(String qualClassName,
                             String defaultPackageName)
Determines the package name of a fully qualified class name.

Parameters:
qualClassName - class name including package
defaultPackageName - a default to return if class is not qualified
Returns:
the package name or default if class not qualified

getClassName

public String getClassName(String qualClassName)
Get the simple class name from a fully qualified class name.

Parameters:
qualClassName - class name including package
Returns:
the last part of the fully qualified name

getQualClassName

public String getQualClassName(String packageName,
                               String className)
Get a fully qualified class name.

Parameters:
packageName - the package or null if none
className - the class name
Returns:
the class name prefixed with the package name unless there is no package in which case, the class name is returned.


Copyright © 2015 LegSem. All Rights Reserved.