Class TypeTemplateEntry

java.lang.Object
com.jalios.jcms.TypeTemplateEntry
All Implemented Interfaces:
TypeConstants, Comparable

public class TypeTemplateEntry extends Object implements TypeConstants, Comparable
This class contains info about Type's template.
Since:
jcms-6.0.0
Author:
Jean-Philippe Encausse
  • Field Details

  • Constructor Details

    • TypeTemplateEntry

      public TypeTemplateEntry()
      Default Constructor
  • Method Details

    • getName

      public String getName()
      Returns the name of the template (== usage + "." + internalName).

      This name must be unique for the type declaration.

      Returns:
      String the name of the template
    • getInternalName

      public String getInternalName()
      Returns the full name of the template that will be stored in the store.xml.

      This is the name attribute value of the template's XML.

      Returns:
      String the name of the template
    • setInternalName

      public void setInternalName(String name)
      Set the name of the template this name must be unique for the type declaration.
      Parameters:
      name - the name of the template, eg "carousel"
    • getPath

      public String getPath()
      Returns the path (e.g. jsp file) to the template. This path is not overrided by PluginPolicyFilter.
      Returns:
      String the path to the template file
    • setPath

      public void setPath(String path)
      Set the path of the template.
      Parameters:
      path - the path of the JSP used by this template, relative to the webapp root, eg "types/PortletQueryForeach/doPortletQueryForeachCarousel.jsp"
    • getUsage

      public String getUsage()
      Returns the usage of the template (e.g. full, query, pda, box, ...).
      Returns:
      String the usage of the template
    • setUsage

      public void setUsage(String usage)
      Set the usage of the template (e.g. full, query, pda, box, ...).
      Parameters:
      usage - a template usage, e.g. "box"
    • getLabel

      public String getLabel(String userLang)
      Returns the label of the template for given user language
      Parameters:
      userLang - the user language
      Returns:
      String the label
    • setLabel

      public void setLabel(String userLang, String value)
      Set the label for the given user language
      Parameters:
      userLang - the user language
      value - the label
    • getLabelMap

      public Map<String,String> getLabelMap()
      Returns the map of labels. Should only be used internally.
      Returns:
      Map of labels
    • setLabelMap

      public void setLabelMap(Map<String,String> labelMap)
      Set the labels for the given template. Should only be used internally.
      Parameters:
      labelMap - the Map of label
    • getDescription

      public String getDescription(String userLang)
      Returns the description of the template for given user language
      Parameters:
      userLang - the user language
      Returns:
      String the map description
    • setDescription

      public void setDescription(String userLang, String value)
      Set the description for the given user language
      Parameters:
      userLang - the user language
      value - the description
    • getDescriptionMap

      public Map<String,String> getDescriptionMap()
      Returns the map of descriptions. Should only be used internally.
      Returns:
      descriptions
    • setDescriptionMap

      public void setDescriptionMap(Map<String,String> descriptionMap)
      Set the descriptions for the given template. Should only be used internally.
      Parameters:
      descriptionMap - the map of description
    • isInternal

      public boolean isInternal()
      Returns true if the template entry has been generated by JCMS without parsing an existing TypeElement.
      Returns:
      true if it is generated.
    • isPlugged

      public boolean isPlugged()
      Returns true if the template entry has been added by pluggin mechanism.
      Returns:
      true if it has been plugged.
    • setPlugged

      public void setPlugged(boolean plugged)
      Returns true if the template entry has been added by pluggin mechanism.
      Parameters:
      plugged - set true if template was added through plugin, false othewise
    • getThumbnailPath

      public String getThumbnailPath()
      Returns the path to the thumbnail of this template or s.gif if it could not be found.
      Returns:
      String path to thumbnail or "s.gif"
    • getThumbnailPath

      public String getThumbnailPath(int width, int height, String defaultImagePath)
      Retrieve the path to the thumbnail of this template in the specified dimension.

      If the thumbnail could not be created (no preview available for this template), the defaultImagePath is returned instead.

      Warning : This method create a thumbnail when it does not exists, this process can be a little time consumming, make sure you do not need immediate response time when using it.

      Parameters:
      width - the width of the thumbnail to create/reuse
      height - the height of the thumbnail to create/reuse
      defaultImagePath - the default image path used if the thumbnail could not be created
      Returns:
      a path relative to the webapp root (e.g. "types/PortletRSS/th-60x45-doPortletRSSFullDisplay.jpg.jpg").
    • getClassName

      public String getClassName()
    • checkIntegrity

      public String[] checkIntegrity()
      Check the integrity of the template fields
      Returns:
      String list of errors or ""
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(Object obj)
      Specified by:
      compareTo in interface Comparable
    • resolveDefaultTemplateEntry

      public static TypeTemplateEntry resolveDefaultTemplateEntry(Set<TypeTemplateEntry> tmplSet, String defaultUsage, String defaultPath)
      Returns a default TypeTemplateEntry in the given Set otherwise return a dummy template with the defaultUsage. Warning ! do not check the usage of provided TypeTemplateEntry
      Parameters:
      tmplSet - a Set of TypeTemplateEntry (that may already refined on usage or null)
      defaultUsage - the template usage
      defaultPath - null or override the path of the dummy tte
      Returns:
      TypeTemplateEntry
      Since:
      jcms-6.0.1
    • decodeTemplate

      public static TypeTemplateEntry decodeTemplate(String className, org.jdom.Element xmlElt, String folderPath)
      Build a TypeTemplateEntry from the given JDom Element
       
       <template usage="PDA" name="lorem" file="doLoremDisplay.jsp">
          <label xml:lang="en">Lorem</label>  
          <label xml:lang="fr">Ipsum</label>  
          <description xml:lang="en">Lorem ipsum dolor sit amet</description>  
          <description xml:lang="fr">Lorem ipsum dolor sit amet</description>  
       </template> 
       
      Parameters:
      className - the short classname of the Type for which this template is decoded (eg Article, TestType, PortletSearch)
      xmlElt - a JDom Element
      folderPath - path to the template file
      Returns:
      a new instance of TypeTemplateEntry, never return null
    • encodeTemplate

      public static org.jdom.Element encodeTemplate(TypeTemplateEntry tte)
      Build a JDom Element from the given TypeTemplateEntry
       
       <template usage="PDA" name="lorem" file="doLoremDisplay.jsp">  
         <label xml:lang="en">Lorem</label>  
         <label xml:lang="fr">Ipsum</label>  
         <description xml:lang="en">Lorem ipsum dolor sit amet</description>  
         <description xml:lang="fr">Lorem ipsum dolor sit amet</description> 
       </template>
       
      Parameters:
      tte - TypeTemplateEntry
      Returns:
      return a new instance of JDOM "template" XML Element, never return null
    • reloadI18N

      public void reloadI18N()
      Reload all I18N informations for this type template entry. This includes : label and description.
      Since:
      jcms-8.0.2