Class TypeUtil
- All Implemented Interfaces:
TypeConstants
-
Field Summary
Fields inherited from interface com.jalios.jcms.TypeConstants
CHANGE_LEVEL_CLASS, CHANGE_LEVEL_JSP, CHANGE_LEVEL_NONE, DISPLAY_TPLT_TAG, EXTENSIONS_XML, FIELD_ELT, FIELD_NEW_MARK, FIELD_UPDATED_MARK, FIELDS_ELT, FILE_INDEX_LISTENER, LINK_INDEX_LISTENER, OLD_TYPES_DIR, PACKAGE_NAME, PACKAGE_NAME_SUFFIX, QUERY_TPLT_TAG, TAB_ELT, TABS_ELT, TEMPLATE_TAG, TEMPLATES_SUFFIX, TEMPLATES_TAG, TITLE_ELT, TYPE_ELT, TYPE_FORCE_UPDATE_MARK, TYPE_NEW_MARK, TYPE_UPDATED_MARK, TYPES_DIR, TYPES_XML -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendJavaSignature(File file) Compute and append the signature of the specified Java file at the end of the file.static voidappendJspSignature(File file) Compute and append the signature of the specified JSP file at the end of the file.static voidappendXmlSignature(File file) Compute and append the signature of the specified XML file at the end of the file.static voidbuildInheritedFieldList(org.jdom.Element elt, List<org.jdom.Element> list, boolean includeEltField) Fill the given list with the inherited fields of the given type Element.static StringgetGeneratedSuperclass(String className) static StringReturns the label of the given element in the given language.static List<org.jdom.Element> getLinkedEltList(org.jdom.Element typeElt) Returns the list of types linked to the given type.static List<org.jdom.Element> getSubEltList(List<org.jdom.Element> typeList, Class<?> clazz) Return all the types extending a given classstatic List<org.jdom.Element> getSubEltList(org.jdom.Element typeElt) Return the list of sub-types of the given typestatic org.jdom.ElementgetSuperElt(String superclass, org.jdom.Element parentElt) Return the super type of a type from its class namestatic org.jdom.ElementgetSuperElt(org.jdom.Element typeElt) Return the super type of a given typestatic List<org.jdom.Element> getSuperEltList(org.jdom.Element typeElt) Return the list of super types of the given type (from the closest to the farthest)static org.jdom.ElementgetTreeChildType(org.jdom.Element typeElt) Return the first sibling type with a field of type 'link' on the given type and with the 'parent' attribute to true.static StringgetTypeDescriptionProperty(String shortClassName) Retrieve the property's name used to read the I18Ned description of the specified type.static StringgetTypeFieldDefaultTextProperty(String shortClassName, String fieldName) Retrieve the property's name used to read the I18Ned default text of the specified type's field.static StringgetTypeFieldDescriptionProperty(String shortClassName, String fieldName) Retrieve the property's name used to read the I18Ned description of the specified type's field.static StringgetTypeFieldLabelProperty(String shortClassName, String fieldName) Retrieve the property's name used to read the I18Ned label of the specified type's field.static StringgetTypeFieldOffLabelProperty(String shortClassName, String fieldName) Retrieve the property's name used to read the I18Ned description of the specified type's boolean field.static StringgetTypeFieldOnLabelProperty(String shortClassName, String fieldName) Retrieve the property's name used to read the I18Ned on label of the specified type's boolean field.static StringgetTypeLabelProperty(String shortClassName) Retrieve the property's name used to read the I18Ned label of the specified type.static StringgetTypeTabLabelProperty(String shortClassName, String tabId) Retrieve the property's name used to read the I18Ned label of the specified type's tab.static StringgetTypeTemplateDescriptionProperty(String shortClassName, String templateName) Retrieve the property's name used to read the I18Ned description of the specified type's template entry.static StringgetTypeTemplateLabelProperty(String shortClassName, String templateName) Retrieve the property's name used to read the I18Ned label of the specified type's template entry.static StringgetTypeTitleDescriptionProperty(String shortClassName) Retrieve the property's name used to read the I18Ned description of the specified type's title.static StringgetTypeTitleLabelProperty(String shortClassName) Retrieve the property's name used to read the I18Ned label of the specified type's title.static booleanhasJavaSignatureChanged(File file) Checks if the specified java file has changed since its generationstatic booleanhasJspSignatureChanged(File file) Checks if the specified JSP file has changed since its generation.static booleanhasSignatureChanged(File file) Checks if a file (java, or jsp) has changed since its generation.static booleanhasSignatureChanged(File file, boolean excludeNonGenerated) Checks if a file (java, or jsp) has changed since its generation.static booleanhasXmlSignatureChanged(File file) Checks if the specified XML file has changed since its generation.static booleanReturns true if the given typeName is a DBData (or extends a DBData class).static booleanisSubTypeOf(org.jdom.Element typeElt, Class<?> clazz) Check if the given type extends a given classstatic voidunescapeJspDirective(File file)
-
Method Details
-
getSuperElt
public static org.jdom.Element getSuperElt(org.jdom.Element typeElt) Return the super type of a given type- Parameters:
typeElt- the type to get the super type- Returns:
- the super type
- Since:
- jcms-4.0
-
getSuperElt
Return the super type of a type from its class name- Parameters:
superclass- the name of the super classparentElt- the type list element.- Returns:
- the super type of a type from its class name
- Since:
- jcms-10.0.2
-
getGeneratedSuperclass
-
getSuperEltList
Return the list of super types of the given type (from the closest to the farthest)- Parameters:
typeElt- the type to get the super type- Returns:
- a list of type element
- Since:
- jcms-4.0
-
isSubTypeOf
Check if the given type extends a given class- Parameters:
typeElt- the type to checkclazz- the clazz to check- Returns:
- true is the super class of typeElt is a sub-class or the same class than the given class
- Since:
- jcms-4.0
-
getSubEltList
Return all the types extending a given class- Parameters:
typeList- the list of typeclazz- the clazz to check- Returns:
- a list of type element
- Since:
- jcms-4.0
-
getSubEltList
Return the list of sub-types of the given type- Parameters:
typeElt- the type to get the sub-types- Returns:
- a list of type element
- Since:
- jcms-4.0
-
getLinkedEltList
Returns the list of types linked to the given type.- Parameters:
typeElt- the type to get the linked types- Returns:
- the list of types linked to the given type.
- Since:
- jcms-5.5.0
-
getTreeChildType
public static org.jdom.Element getTreeChildType(org.jdom.Element typeElt) Return the first sibling type with a field of type 'link' on the given type and with the 'parent' attribute to true. Do not search in inherited fields of the type.- Parameters:
typeElt- the search type- Returns:
- The matching Element or null
- Since:
- jcms-4.0
-
getLabel
Returns the label of the given element in the given language.- Parameters:
elt- the elementlang- the language- Returns:
- the label of the given element in the given language.
- Since:
- jcms-5.7.0
-
buildInheritedFieldList
public static void buildInheritedFieldList(org.jdom.Element elt, List<org.jdom.Element> list, boolean includeEltField) Fill the given list with the inherited fields of the given type Element.- Parameters:
elt- the type elementlist- the list to fillincludeEltField- if true add fields of elt.- Since:
- jcms-4.0
-
unescapeJspDirective
- Throws:
IOException
-
hasJspSignatureChanged
Checks if the specified JSP file has changed since its generation.- Parameters:
file- a Java file (whatever.jsp)- Returns:
trueif signature has changed or no signature could be found,falseif signature has NOT been changed or if file does not exist or is empty.- Throws:
IOException- if an exception occurs
-
appendJspSignature
Compute and append the signature of the specified JSP file at the end of the file.- Parameters:
file- a Java file (whatever.jsp)- Throws:
IOException- if an exception occurs
-
hasXmlSignatureChanged
Checks if the specified XML file has changed since its generation.- Parameters:
file- a Java file (whatever.jsp)- Returns:
trueif signature has changed or no signature could be found,falseif signature has NOT been changed or if file does not exist or is empty.- Throws:
IOException- if an exception occurs- Since:
- jcms-6.0.0
-
appendXmlSignature
Compute and append the signature of the specified XML file at the end of the file.- Parameters:
file- a Java file (whatever.jsp)- Throws:
IOException- if an exception occurs- Since:
- jcms-6.0.0
-
hasJavaSignatureChanged
Checks if the specified java file has changed since its generation- Parameters:
file- a Java file (whatever.java)- Returns:
trueif signature has changed or no signature could be found,falseif signature has NOT been changed or if file does not exist or is empty.- Throws:
IOException- if an exception occurs
-
appendJavaSignature
Compute and append the signature of the specified Java file at the end of the file.- Parameters:
file- a Java file (whatever.java)- Throws:
IOException- if an exception occurs
-
hasSignatureChanged
Checks if a file (java, or jsp) has changed since its generation.
In order to perform this verification, checks if the actual/current signature of the specified file (java, or jsp) differs from the signature computed and appended in the file at the time of the generation.
- Parameters:
file- the file to check- Returns:
trueif signature has changed or no signature could be found,falseif signature has NOT been changed or if file does not exist or is empty or is not a generated file.- Throws:
IOException- if an exception occurs- Since:
- jcms-5.7.4
-
hasSignatureChanged
public static boolean hasSignatureChanged(File file, boolean excludeNonGenerated) throws IOException Checks if a file (java, or jsp) has changed since its generation.
In order to perform this verification, checks if the actual/current signature of the specified file (java, or jsp) differs from the signature computed and appended in the file at the time of the generation.
Warning: Be careful when invoking this method with boolean "excludeNonGenerated" as false : the signature check will be performed for ALL files which match extension of file generated by JCMS (.class, .java, .jsp and .xml), even though the file was not generated by JCMS (the file outside /WEB-INF/classes/generated or /types/).
Because the file content is loaded in memory to check the signature, it might require a lot of memory if a file size is important (eg : store.xml, XML statistics, ...)- Parameters:
file- the file to checkexcludeNonGenerated- If set to true, signature will not be verified for files which are not in a generated directory (and false will be returned). If set to false, signature will be check whatever the file is specified and corresponding value will be returned.
Warning, if set to true, this method will require Channel and TypeProcessor to be started.- Returns:
trueif signature has changed or no signature could be found,falseif signature has NOT been changed or if file does not exist or is empty.- Throws:
IOException- if an exception occurs- Since:
- jcms-6.0.2, jcms-6.1.1
-
isDBType
Returns true if the given typeName is a DBData (or extends a DBData class).- Parameters:
rootElt- the root element of typestypeName- the name of the type (only for non generated types)- Returns:
- true if the given typeName is a DBData (i.e. extends a class)
- Since:
- jcms-6.0.0
-
getTypeLabelProperty
Retrieve the property's name used to read the I18Ned label of the specified type.- Parameters:
shortClassName- the short classname of the type (egArticle)- Returns:
- a property name used to retrieve type's label (eg
types.Article.label) - Since:
- jcms-8.0.0
-
getTypeDescriptionProperty
Retrieve the property's name used to read the I18Ned description of the specified type.- Parameters:
shortClassName- the short classname of the type (egArticle)- Returns:
- a property name used to retrieve type's label (eg
types.Article.label) - Since:
- jcms-8.0.0
-
getTypeTitleLabelProperty
Retrieve the property's name used to read the I18Ned label of the specified type's title.- Parameters:
shortClassName- the short classname of the type (egArticle)- Returns:
- a property name used to retrieve type's title label (eg
types.Article.title.label) - Since:
- jcms-8.0.0
-
getTypeTitleDescriptionProperty
Retrieve the property's name used to read the I18Ned description of the specified type's title.- Parameters:
shortClassName- the short classname of the type (egArticle)- Returns:
- a property name used to retrieve type's title description (eg
types.Article.title.description) - Since:
- jcms-8.0.0
-
getTypeFieldLabelProperty
Retrieve the property's name used to read the I18Ned label of the specified type's field.- Parameters:
shortClassName- the short classname of the type (egArticle)fieldName- the name of the field, as declared in the xml file (egsummary)- Returns:
- a property name used to retrieve type's field label (eg
types.Article.fields.summary.label) - Since:
- jcms-8.0.0
-
getTypeFieldDescriptionProperty
Retrieve the property's name used to read the I18Ned description of the specified type's field.- Parameters:
shortClassName- the short classname of the type (egArticle)fieldName- the name of the field, as declared in the xml file (egsummary)- Returns:
- a property name used to retrieve type's field description (eg
types.Article.fields.summary.description) - Since:
- jcms-8.0.0
-
getTypeFieldOnLabelProperty
Retrieve the property's name used to read the I18Ned on label of the specified type's boolean field.- Parameters:
shortClassName- the short classname of the type (egPortletQueryForeach)fieldName- the name of the field, as declared in the xml file (egsearchInDB)- Returns:
- a property name used to retrieve type's boolean field 'on' label (eg
types.PortletQueryForeach.fields.searchInDB.onLabel) - Since:
- jcms-8.0.0
-
getTypeFieldOffLabelProperty
Retrieve the property's name used to read the I18Ned description of the specified type's boolean field.- Parameters:
shortClassName- the short classname of the type (egPortletQueryForeach)fieldName- the name of the field, as declared in the xml file (egsearchInDB)- Returns:
- a property name used to retrieve type's boolean field 'off' label (eg
types.PortletQueryForeach.fields.searchInDB.offLabel) - Since:
- jcms-8.0.0
-
getTypeFieldDefaultTextProperty
Retrieve the property's name used to read the I18Ned default text of the specified type's field.- Parameters:
shortClassName- the short classname of the type (egArticle)fieldName- the name of the field, as declared in the xml file (egsummary)- Returns:
- a property name used to retrieve type's field default text (eg
types.Article.fields.summary.defaultText) - Since:
- jcms-8.0.0
-
getTypeTabLabelProperty
Retrieve the property's name used to read the I18Ned label of the specified type's tab.- Parameters:
shortClassName- the short classname of the type (egPortletQueryForeach)tabId- the id of the tab, as declared in the xml file (egadvanced)- Returns:
- a property name used to retrieve type's tab label (eg
types.Article.tabs.advanced.label) - Since:
- jcms-8.0.0
-
getTypeTemplateLabelProperty
Retrieve the property's name used to read the I18Ned label of the specified type's template entry.- Parameters:
shortClassName- the short classname of the type (egPortletSearch)templateName- the name of the template (== usage + "." + internalName), as declared in the xml file (egbox.mixed)- Returns:
- a property name used to retrieve type's template label (eg
types.PortletSearch.templates.box.mixed.label) - Since:
- jcms-8.0.0
-
getTypeTemplateDescriptionProperty
Retrieve the property's name used to read the I18Ned description of the specified type's template entry.- Parameters:
shortClassName- the short classname of the type (egPortletSearch)templateName- the name of the field (== usage + "." + internalName), as declared in the xml file (egbox.mixed)- Returns:
- a property name used to retrieve type's template description (eg
types.PortletSearch.templates.box.mixed.description) - Since:
- jcms-8.0.0
-