Class TypeProcessor

java.lang.Object
com.jalios.jcms.TypeProcessor
All Implemented Interfaces:
JcmsConstants, TypeConstants, JaliosConstants

public class TypeProcessor extends Object implements TypeConstants, JcmsConstants
This class generates all the resources (Java classes and JSPs) used by the Custom Publication Types and Custom Extension Types.

This class replaces TypeGenerator class. It uses now a template mechanism to produces all the source code (Java and JSP)

Since:
jcms-3.0
Author:
Olivier Dedieu
  • Field Details

    • EMPTY_TYPEFIELDENTRY_ARRAY

      public static final TypeFieldEntry[] EMPTY_TYPEFIELDENTRY_ARRAY
    • compilerCmdLineTemplate

      protected List<String> compilerCmdLineTemplate
    • compileSet

      protected Set<String> compileSet
    • hbmList

      protected List<Class<?>> hbmList
  • Method Details

    • getInstance

      public static TypeProcessor getInstance()
      Returns the TypeProcessor singleton instance.
      Initialize it if it was not already done. Channel must be available!
      Returns:
      the TypeProcessor singleton instance
    • getCurrentTypeDocument

      public org.jdom.Document getCurrentTypeDocument()
      Returns:
      the jdom Document instance of the current type
      Since:
      jcms-3.0
    • getTypeDocument

      public org.jdom.Document getTypeDocument()
      Returns:
      the jdom Document containing all Types Element
      Since:
      jcms-3.0
    • getNewTypeDocument

      public org.jdom.Document getNewTypeDocument(boolean create)
      Parameters:
      create - whether a new one should be created if it has not been created yet
      Returns:
      the Document (copy of getTypeDocument() being edited)
      Since:
      jcms-3.0
    • revertTypeDocument

      public void revertTypeDocument()
      Revert the currently edited TypeDocument.
      Since:
      jcms-3.0
    • getCustomTypeList

      public List<Class<?>> getCustomTypeList()
      Returns:
      a list of Class
      Since:
      jcms-3.0
    • getHbmList

      public List<Class<?>> getHbmList()
      Returns the list of class an HBM has been generated.
      Returns:
      the list of class an HBM has been generated.
      Since:
      jcms-6.0.0
    • processTypes

      public void processTypes() throws Exception
      Generate all type's resources from the types/ directory (for old JCMS data, convert types.xml file, to the new types organization and extensions.xml file to the new extensions organization)
      Throws:
      Exception - if an error occurs
      Since:
      jcms-3.0
    • isInGeneratedDir

      public boolean isInGeneratedDir(File file)
      Looks if the file is under a generation files (classes/generated and types).
      Parameters:
      file - A possibly generated file
      Returns:
      true if the file is in under generated directory
      Since:
      JCMS-6.0.2
    • saveNewTypeDocument

      public void saveNewTypeDocument() throws IOException
      Saves the currently edited TypeDocument. Once saved, the newTypeDocument object is reset to null.
      Throws:
      IOException - if an error occurs during saving
    • applyTypeChange

      public void applyTypeChange() throws Exception
      Throws:
      Exception - if an error occurs
      Since:
      jcms-3.0
    • getTypeChangeLevel

      public int getTypeChangeLevel()
      Returns:
      the kind of type changed occured (none/jsp/class)
      Since:
      jcms-3.0
    • getTypeEntry

      public TypeEntry getTypeEntry(Class<?> clazz)
      Return the TypeEntry class associated to the given Class. Return null if no TypeEntry is bound to clazz.
      Parameters:
      clazz - the Class of which to find the TypeEntry
      Returns:
      the TypeEntry associated to the given class or null if not available.
    • getTypeEntry

      public TypeEntry getTypeEntry(String clazzName)
      Return the TypeEntry class associated to the given Class name. Return null if no TypeEntry is bound to clazzName.
      Parameters:
      clazzName - the String representing the name the Class of which to find the TypeEntry
      Returns:
      the TypeEntry associated to the given class or null if not available.
    • getTypeFieldEntries

      public TypeFieldEntry[] getTypeFieldEntries(Class<?> clazz)
      Return an array of TypeFieldEntry bound to given Class.
      This array does not contain inherited TypeFieldEntry from super classes of given Class.
      Parameters:
      clazz - the Class of which to find the TypeFieldEntry.
      Returns:
      an array of TypeFieldEntry containing all Field used by Class or an empty array (never return null)
      Since:
      jcms-5.5
    • getTypeFieldEntries

      public TypeFieldEntry[] getTypeFieldEntries(String clazzName)
      Return an array of TypeFieldEntry bound to given Class represented by its class name.
      This array does not contain inherited TypeFieldEntry from super classes of given Class.
      Parameters:
      clazzName - the String representing the name the Class of which to find the TypeFieldEntry
      Returns:
      an array of TypeFieldEntry containing all Field used by Class or an empty array (never return null)
      Since:
      jcms-5.5
    • getAllTypeFieldEntries

      public TypeFieldEntry[] getAllTypeFieldEntries(Class<?> clazz)
      Return an array of TypeFieldEntry bound to given Class.
      This array does contain inherited TypeFieldEntry from super classes of given Class.
      Parameters:
      clazz - the Class of which to find the TypeFieldEntry.
      Returns:
      an array of TypeFieldEntry containing all Field used by Class or an empty array (never return null)
      Since:
      jcms-5.5
    • getAllTypeFieldEntries

      public TypeFieldEntry[] getAllTypeFieldEntries(String clazzName)
      Return an array of TypeFieldEntry bound to given Class represented by its class name.
      This array does contain inherited TypeFieldEntry from super classes of given Class.
      Parameters:
      clazzName - the String representing the name the Class of which to find the TypeFieldEntry
      Returns:
      an array of TypeFieldEntry containing all Field used by Class or an empty array (never return null)
      Since:
      jcms-5.5
    • getTypeLabel

      @Deprecated public String getTypeLabel(Class<?> clazz)
      Deprecated.
      since jcms-5.7.0
      Returns the label of a given type (if TypeEntry is not null use it, otherwise return the short class name)
      Parameters:
      clazz - the class to get the label
      Returns:
      the type label
      Since:
      jcms-5.0.0
      See Also:
    • getTypeLabel

      public String getTypeLabel(Class<?> clazz, String lang)
      Returns the label of a given type (class) localized for the given language.
      Parameters:
      clazz - the class
      lang - the language
      Returns:
      the type label
      Since:
      jcms-5.7.0
    • getTypeDescription

      public String getTypeDescription(Class<?> clazz, String lang)
      Returns the description of a given type (class) localized for the given language.
      Parameters:
      clazz - the class
      lang - the language
      Returns:
      the Type description
      Since:
      jcms-5.0.0
    • markTypeAsUpdated

      public static void markTypeAsUpdated(org.jdom.Element typeElt, boolean markSubTypes, boolean forceUpdate)
      Mark the given type as updated and also its sub-types (and their "super" field)
      Parameters:
      typeElt - the type to mark as updated
      markSubTypes - if true, marks all its sub-types as updated
      forceUpdate - if true, the type (and sub-types if 'markSubTypes' is true) will be force to be updated (i.e. regenerated)
      Since:
      jcms-4.0
    • isCompilationDone

      public boolean isCompilationDone()