Class ModuleUtil
- java.lang.Object
-
- org.eclipse.birt.report.model.api.ModuleUtil
-
public class ModuleUtil extends java.lang.ObjectProvides some tool methods about the modules.
-
-
Field Summary
Fields Modifier and Type Field Description static intINVALID_MODULEThe invalid module.static intLIBRARYThe library type.static intREPORT_DESIGNThe report design type.
-
Constructor Summary
Constructors Constructor Description ModuleUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcheckModule(SessionHandle sessionHandle, java.lang.String fileName, java.io.InputStream is)Checks the input stream with given file name.static java.util.ListcheckVersion(java.lang.String fileName)Checks whether the opening design file holds a version number before the some specific features is supported.static intcompareReportVersion(java.lang.String version1, java.lang.String version2)Compares two specifies report version.static java.lang.StringconvertColumnTypeToParamType(java.lang.String type)Convert column data type to param type.static java.lang.StringconvertParamTypeToColumnType(java.lang.String type)Convert param type to column data type.static ActionHandledeserializeAction(java.io.InputStream streamData)Deserialize an input stream into an Action.static ActionHandledeserializeAction(java.io.InputStream streamData, DesignElementHandle element)Deserialize an input stream into an Action.static ActionHandledeserializeAction(java.lang.String strData)Deserializes a string into an ActionHandle, notice that the handle is faked, the action is not in the design tree, the operation to the handle is not able to be undone.static ActionHandledeserializeAction(java.lang.String strData, DesignElementHandle element)Deserialize a string into an ActionHandle, notice that the handle is faked, the action is not in the design tree, the operation to the handle is not able to be undoned.static longgerSerializedID(DesignElementHandle element)Returns the serialized id for the given element.static java.util.List<DesignElementHandle>getElementsByType(ModuleHandle moduleHandle, java.lang.String elementType)Gets all the elements that is kind of the specified type.static java.lang.StringgetExternalizedValue(DesignElementHandle element, java.lang.String key, java.lang.String value, com.ibm.icu.util.ULocale locale)Returns externalized message for the given locale.static java.lang.StringgetReportVersion()Gets the current version of the report files when users want to save it calling Model's related APIs.static java.lang.StringgetScript(ModuleHandle module, java.lang.String uid)Gets the script value.static java.lang.ObjectgetScriptObject(ModuleHandle module, java.lang.String uid)Gets the script object .static java.lang.StringgetScriptUID(java.lang.Object instance)Gets the script id if instance has expression.static java.lang.StringgetScriptUID(java.lang.Object instance, int index)Gets the script id if instance has expression.static booleanisEqualHierarchiesForJointCondition(HierarchyHandle conditionHierarchy, HierarchyHandle cubeHierarchy)This API is only for helping GUI to draw the dimension joint condition editor pad.static booleanisInclude(ModuleHandle moduleHandle, java.lang.String fileName)Checks whether a library with the specified file name is directly or indirectly included by the module.static booleanisListFilterValue(FilterConditionElementHandle filter)Determine if the value1 of this filter condition is a list.static booleanisListFilterValue(FilterConditionHandle filter)Determine if the value1 of this filter condition is a list.static booleanisListStyleRuleValue(StyleRuleHandle rule)Determine if the value1 of this map rule condition is a list.static booleanisValidDesign(SessionHandle sessionHandle, java.lang.String fileName, java.io.InputStream is)Justifies whether a given input stream is a valid report design.static booleanisValidElementName(DesignElementHandle elementHandle)checks is the name value is valid for the design element.static booleanisValidElementName(DesignElementHandle elementHandle, java.lang.String propName, java.lang.String nameValue)checks if the name of the element is valid.static booleanisValidLibrary(SessionHandle sessionHandle, java.lang.String fileName, java.io.InputStream is)Justifies whether a library resource with the given file name is a valid library.static java.lang.StringserializeAction(ActionHandle action)Serialize an action into a stream, the stream is in UTF-8 encoding.static java.lang.StringvalidteGroupName(GroupHandle groupHandle, java.lang.String groupName)Validates the given group name.
-
-
-
Field Detail
-
LIBRARY
public static final int LIBRARY
The library type.- See Also:
- Constant Field Values
-
REPORT_DESIGN
public static final int REPORT_DESIGN
The report design type.- See Also:
- Constant Field Values
-
INVALID_MODULE
public static final int INVALID_MODULE
The invalid module.- See Also:
- Constant Field Values
-
-
Method Detail
-
deserializeAction
public static ActionHandle deserializeAction(java.io.InputStream streamData) throws DesignFileException
Deserialize an input stream into an Action.- Parameters:
streamData- a stream represent an action.- Returns:
- an internal Action structure
- Throws:
DesignFileException- if the exception occur when interpret the stream data.
-
deserializeAction
public static ActionHandle deserializeAction(java.io.InputStream streamData, DesignElementHandle element) throws DesignFileException
Deserialize an input stream into an Action.- Parameters:
streamData- a stream represent an action.element-- Returns:
- an internal Action structure
- Throws:
DesignFileException- if the exception occur when interpret the stream data.
-
deserializeAction
public static ActionHandle deserializeAction(java.lang.String strData) throws DesignFileException
Deserializes a string into an ActionHandle, notice that the handle is faked, the action is not in the design tree, the operation to the handle is not able to be undone.- Parameters:
strData- a string represent an action.- Returns:
- a handle to the action.
- Throws:
DesignFileException- if the exception occur when interpret the stream data.
-
deserializeAction
public static ActionHandle deserializeAction(java.lang.String strData, DesignElementHandle element) throws DesignFileException
Deserialize a string into an ActionHandle, notice that the handle is faked, the action is not in the design tree, the operation to the handle is not able to be undoned.- Parameters:
strData- a string represent an action.element-- Returns:
- a handle to the action.
- Throws:
DesignFileException- if the exception occur when interpret the stream data.
-
serializeAction
public static java.lang.String serializeAction(ActionHandle action) throws java.io.IOException
Serialize an action into a stream, the stream is in UTF-8 encoding.- Parameters:
action- a given action structure.- Returns:
- an output stream represent the action xml data.
- Throws:
java.io.IOException- if I/O exception occur when writing the stream.
-
isValidDesign
public static boolean isValidDesign(SessionHandle sessionHandle, java.lang.String fileName, java.io.InputStream is)
Justifies whether a given input stream is a valid report design.- Parameters:
sessionHandle- the current session of the report designfileName- the file name of the report designis- the input stream of the report design- Returns:
- true if the input stream is a valid report design, otherwise false
-
isValidLibrary
public static boolean isValidLibrary(SessionHandle sessionHandle, java.lang.String fileName, java.io.InputStream is)
Justifies whether a library resource with the given file name is a valid library.- Parameters:
sessionHandle- the current session of the libraryfileName- the file name of the libraryis- the input stream of the library- Returns:
- true if the library resource is a valid library, otherwise false
-
checkModule
public static int checkModule(SessionHandle sessionHandle, java.lang.String fileName, java.io.InputStream is)
Checks the input stream with given file name. If it is a valid design/library, returnModuleUtil.REPORT_DESIGN/ModuleUtil.LIBRARY, otherwise,ModuleUtil.INVALIDis return.- Parameters:
sessionHandle- the current session of the libraryfileName- the file name of the libraryis- the input stream of the library- Returns:
ModuleUtil.REPORT_DESIGNif the input stream is a report design,ModuleUtil.LIBRARYif the input stream is a library,ModuleUtil.INVALIDotherwise.
-
checkVersion
public static java.util.List checkVersion(java.lang.String fileName)
Checks whether the opening design file holds a version number before the some specific features is supported. This method is used to remind user that opening the file may need convert the original file automatically.- Parameters:
fileName- the file name with full path of the design file- Returns:
- a list whose entry is of
IVersionInfotype. Each kind of automatical conversion information is stored in one instance ofIVersionInfo. Note that if the design file does not exist, or it is an invalid design file, an instance ofIVersionInfowill also generate. If the size of the return list is 0, there is no auto-conversion.
-
getExternalizedValue
public static java.lang.String getExternalizedValue(DesignElementHandle element, java.lang.String key, java.lang.String value, com.ibm.icu.util.ULocale locale)
Returns externalized message for the given locale.- Parameters:
element- the report element.key- the display key property valuevalue- the property valuelocale- the locale- Returns:
- externalized message.
-
isEqualHierarchiesForJointCondition
public static boolean isEqualHierarchiesForJointCondition(HierarchyHandle conditionHierarchy, HierarchyHandle cubeHierarchy)
This API is only for helping GUI to draw the dimension joint condition editor pad. When user extends an library cube to design, the hierarchy handle from the joint condition should be same with the virtual hierarchy in the reprot design cube.- Parameters:
conditionHierarchy- the hierarchy handle from the dimension joint condition structure.cubeHierarchy- the hierarchy handle from the cube.- Returns:
-
isValidElementName
public static boolean isValidElementName(DesignElementHandle elementHandle, java.lang.String propName, java.lang.String nameValue)
checks if the name of the element is valid. The following case the name will be considered as invalid.- contains the following characters: "/","\\", ".", "!", ";",","
- Parameters:
elementHandle- the design element need to be checked the name property value.propName- the property name which is name property type of this design element.nameValue- the value of the name property.- Returns:
- true if the value of the name property is valid, false if it is not valid.
-
isValidElementName
public static boolean isValidElementName(DesignElementHandle elementHandle)
checks is the name value is valid for the design element.- Parameters:
elementHandle- element need to be checked for the name.nameValue- name of the element.- Returns:
- true if the name is valid, false if the name is not valid.
-
isListFilterValue
public static boolean isListFilterValue(FilterConditionHandle filter)
Determine if the value1 of this filter condition is a list.- Parameters:
filter- the filter need to check- Returns:
- true if the value1 value is a list, false if it is a single value.
-
isListStyleRuleValue
public static boolean isListStyleRuleValue(StyleRuleHandle rule)
Determine if the value1 of this map rule condition is a list.- Parameters:
rule- the map rule need to check- Returns:
- true if the value1 value is a list, false if it is a single value.
-
isListFilterValue
public static boolean isListFilterValue(FilterConditionElementHandle filter)
Determine if the value1 of this filter condition is a list.- Parameters:
filter- the filter need to check- Returns:
- true if the value1 value is a list, false if it is a single value.
-
convertParamTypeToColumnType
public static java.lang.String convertParamTypeToColumnType(java.lang.String type)
Convert param type to column data type.- Parameters:
type-- Returns:
-
convertColumnTypeToParamType
public static java.lang.String convertColumnTypeToParamType(java.lang.String type)
Convert column data type to param type.- Parameters:
type-- Returns:
-
getScriptUID
public static java.lang.String getScriptUID(java.lang.Object instance)
Gets the script id if instance has expression.- Parameters:
instance-PropertyHandlewhich type or sub type should be script or expression.- Returns:
- the script uid if type or sub type is script or expression, null if not or meet error.
-
getScriptUID
public static java.lang.String getScriptUID(java.lang.Object instance, int index)Gets the script id if instance has expression. Support list-value which sub type is expression.- Parameters:
instance-PropertyHandlewhich type or sub type should be script or expression.index- index should be in valid range, should be more than zero and less than list value size.- Returns:
- the script uid if type or sub type is script or expression, null if not or meet error.
-
getScript
public static java.lang.String getScript(ModuleHandle module, java.lang.String uid)
Gets the script value.- Parameters:
module- module handleuid- the script uid- Returns:
- the script value if script uid is valid;else return null.
-
getScriptObject
public static java.lang.Object getScriptObject(ModuleHandle module, java.lang.String uid)
Gets the script object .- Parameters:
module- module handleuid- the script uid- Returns:
- the script object if script uid is valid;else return null.
-
gerSerializedID
public static long gerSerializedID(DesignElementHandle element)
Returns the serialized id for the given element. The serialized id may or may not be equal to the element id. It is for the BIRT internal usage.- Parameters:
element- the element- Returns:
- the serialized id of the given element
-
getReportVersion
public static java.lang.String getReportVersion()
Gets the current version of the report files when users want to save it calling Model's related APIs.- Returns:
- the current version of the report files
-
compareReportVersion
public static int compareReportVersion(java.lang.String version1, java.lang.String version2) throws java.lang.IllegalArgumentExceptionCompares two specifies report version. 1 returned if the former of the two is greater than the latter, 0 if former equals to the latter and -1 if the former smaller than the latter.- Parameters:
version1-version2-- Returns:
- 1 returned if the former of the two is greater than the latter, 0 if former equals to the latter and -1 if the former smaller than the latter
- Throws:
java.lang.IllegalArgumentException- thrown if either of the two given version string is illegal
-
isInclude
public static boolean isInclude(ModuleHandle moduleHandle, java.lang.String fileName)
Checks whether a library with the specified file name is directly or indirectly included by the module. The given file name must be absolute. Method will not correctly handle the case if file name is relative.- Parameters:
moduleHandle- the module handle which to include the libraryfileName- the absolute file name of the library- Returns:
- true if a library is found to be directly or indirectly included by the module, otherwise false
-
getElementsByType
public static java.util.List<DesignElementHandle> getElementsByType(ModuleHandle moduleHandle, java.lang.String elementType)
Gets all the elements that is kind of the specified type. All the type should be the constants in {ReportDesignConstants.- Parameters:
moduleHandle- the module handle that the elements reside inelementType- the type of the elements to retrieve- Returns:
- the list of the elements that is kind of the specified type
-
validteGroupName
public static java.lang.String validteGroupName(GroupHandle groupHandle, java.lang.String groupName)
Validates the given group name. Returned value is a valid one.- Parameters:
groupHandle-groupName-- Returns:
-
-