org.hibernate.tool.hbm2x
Class Cfg2JavaTool

java.lang.Object
  extended by org.hibernate.tool.hbm2x.Cfg2JavaTool

public class Cfg2JavaTool
extends Object

Helper methods for javacode generation.

Author:
max

Constructor Summary
Cfg2JavaTool()
           
 
Method Summary
 String asArgumentList(Iterator fields)
           
 String asArgumentList(List fields)
           
 String asFinderArgumentList(Map parameterTypes, ImportContext ctx)
           
 String asNaturalIdParameterList(org.hibernate.mapping.PersistentClass clazz)
           
 String asParameterList(Iterator fields, boolean useGenerics, ImportContext ic)
           
 String asParameterList(List fields, boolean useGenerics, ImportContext ic)
           
 String getClassModifiers(org.hibernate.mapping.MetaAttributable pc)
           
 String getGenericCollectionDeclaration(org.hibernate.mapping.Collection collection, boolean preferRawTypeNames, ImportContext importContext)
           
 String getJavaTypeName(org.hibernate.mapping.Property p, boolean useGenerics)
          Returns the typename for a property, using generics if this is a Set type and useGenerics is set to true.
 String getJavaTypeName(org.hibernate.mapping.Property p, boolean useGenerics, ImportContext importContext)
           
 boolean getMetaAsBool(org.hibernate.mapping.MetaAttributable ma, String attribute)
           
 boolean getMetaAsBool(org.hibernate.mapping.MetaAttributable pc, String attribute, boolean defaultValue)
           
 String getMetaAsString(org.hibernate.mapping.MetaAttributable pc, String attribute)
          Returns all meta items as one large string.
 String getMetaAsString(org.hibernate.mapping.MetaAttributable pc, String attribute, String seperator)
           
 POJOClass getPOJOClass(org.hibernate.mapping.Component comp)
           
 POJOClass getPOJOClass(org.hibernate.mapping.PersistentClass comp)
           
 Iterator getPOJOIterator(Iterator persistentClasses)
           
 boolean hasMetaAttribute(org.hibernate.mapping.MetaAttributable pc, String attribute)
           
 boolean isArray(String typeName)
           
 boolean isComponent(org.hibernate.mapping.Property property)
           
static boolean isNonPrimitiveTypeName(String typeName)
           
 boolean isPrimitive(String typeName)
           
 String simplePluralize(String str)
           
 String toJavaDoc(String string, int indent)
          Convert string into something that can be rendered nicely into a javadoc comment.
 String unqualify(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cfg2JavaTool

public Cfg2JavaTool()
Method Detail

getPOJOClass

public POJOClass getPOJOClass(org.hibernate.mapping.Component comp)

getPOJOClass

public POJOClass getPOJOClass(org.hibernate.mapping.PersistentClass comp)

unqualify

public String unqualify(String name)

getMetaAsString

public String getMetaAsString(org.hibernate.mapping.MetaAttributable pc,
                              String attribute)
Returns all meta items as one large string.


hasMetaAttribute

public boolean hasMetaAttribute(org.hibernate.mapping.MetaAttributable pc,
                                String attribute)

getMetaAsString

public String getMetaAsString(org.hibernate.mapping.MetaAttributable pc,
                              String attribute,
                              String seperator)

getMetaAsBool

public boolean getMetaAsBool(org.hibernate.mapping.MetaAttributable ma,
                             String attribute)

getMetaAsBool

public boolean getMetaAsBool(org.hibernate.mapping.MetaAttributable pc,
                             String attribute,
                             boolean defaultValue)

toJavaDoc

public String toJavaDoc(String string,
                        int indent)
Convert string into something that can be rendered nicely into a javadoc comment. Prefix each line with a star ('*').

Parameters:
string -

getClassModifiers

public String getClassModifiers(org.hibernate.mapping.MetaAttributable pc)

getJavaTypeName

public String getJavaTypeName(org.hibernate.mapping.Property p,
                              boolean useGenerics)
Returns the typename for a property, using generics if this is a Set type and useGenerics is set to true.


getJavaTypeName

public String getJavaTypeName(org.hibernate.mapping.Property p,
                              boolean useGenerics,
                              ImportContext importContext)

isNonPrimitiveTypeName

public static boolean isNonPrimitiveTypeName(String typeName)

getGenericCollectionDeclaration

public String getGenericCollectionDeclaration(org.hibernate.mapping.Collection collection,
                                              boolean preferRawTypeNames,
                                              ImportContext importContext)

asParameterList

public String asParameterList(Iterator fields,
                              boolean useGenerics,
                              ImportContext ic)

asArgumentList

public String asArgumentList(Iterator fields)
Parameters:
fields - iterator on Property elements.
Returns:
"name, number, ..." for a property list, usable for method calls.

TODO: handle this in a template ?


asNaturalIdParameterList

public String asNaturalIdParameterList(org.hibernate.mapping.PersistentClass clazz)
Parameters:
clazz - persistent class.
Returns:
"String name, int number, ..." for a property list, usable for method declarations.

TODO: handle this in a template ?


asParameterList

public String asParameterList(List fields,
                              boolean useGenerics,
                              ImportContext ic)

asArgumentList

public String asArgumentList(List fields)

asFinderArgumentList

public String asFinderArgumentList(Map parameterTypes,
                                   ImportContext ctx)

isPrimitive

public boolean isPrimitive(String typeName)

isComponent

public boolean isComponent(org.hibernate.mapping.Property property)

getPOJOIterator

public Iterator getPOJOIterator(Iterator persistentClasses)

simplePluralize

public String simplePluralize(String str)

isArray

public boolean isArray(String typeName)