Class ElementExportUtilImpl
- java.lang.Object
-
- org.eclipse.birt.report.model.api.util.ElementExportUtilImpl
-
- Direct Known Subclasses:
ElementExportUtil
public class ElementExportUtilImpl extends java.lang.Object
Represents the utility class to help export element and structure to library file. The element or structure to export must comply with the following rule:- Element must have name defined.
- The name property of structure must have value.
- The element or structure must be contained in design file.
IllegalArgumentException
.
-
-
Constructor Summary
Constructors Constructor Description ElementExportUtilImpl()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
canExport(DesignElementHandle elementToExport)
Checks whether the given element can be exported into one library.static boolean
canExport(DesignElementHandle elementToExport, boolean ignoreName)
Checks whether the given element can be exported into one library.static boolean
canExport(DesignElementHandle elementToExport, LibraryHandle targetLibraryHandle, boolean canOverride)
Checks whether the given element can be exported into one library.static boolean
canExport(StructureHandle structToExport)
Checks whether the given structure can be exported into one library.static boolean
canExport(StructureHandle structToExport, boolean ignoreName)
Checks whether the given structure can be exported into one library.static boolean
canExport(StructureHandle structToExport, LibraryHandle targetLibraryHandle, boolean canOverride)
Checks whether the given structure can be exported into one library.static boolean
canExport(StyleHandle styleHandle, ThemeHandle themeHandle, boolean canOverride)
Checks whether the given element can be exported into the selected theme.protected static boolean
checkExportedExtendedItem(ExtendedItemHandle elementToExport)
Checks extended item can be exported or not.protected static boolean
checkExportElementByContext(DesignElementHandle handle, ModuleHandle targetLibraryHandle, boolean canOverride)
Checks if extendedItem and cube's content element has the same name as the exported element and its content elements.static void
exportDesign(ReportDesignHandle designToExport, java.lang.String libraryFileName, boolean canOverride, boolean genDefaultName)
Export the report design to a library file specified by the file name.static void
exportDesign(ReportDesignHandle designToExport, LibraryHandle targetLibraryHandle, boolean canOverride, boolean genDefaultName)
Exports one design to library.static void
exportElement(DesignElementHandle elementToExport, java.lang.String libraryFileName, boolean canOverride)
Exports the given element into one library file.static void
exportElement(DesignElementHandle elementToExport, LibraryHandle targetLibraryHandle, boolean canOverride)
Exports the given element into one library.static void
exportElements(java.util.List elementsToExport, java.lang.String libraryFileName, boolean canOverride)
Exports the given element list into one library file.static void
exportStructure(StructureHandle structToExport, java.lang.String libraryFileName, boolean canOverride)
Exports the given structure into one library.static void
exportStructure(StructureHandle structToExport, LibraryHandle targetLibraryHandle, boolean canOverride)
Exports the given structure into one library.static void
exportStructures(java.util.List structsToExport, java.lang.String libraryFileName, boolean canOverride)
Exports the given structure into one library.static void
exportStyle(StyleHandle styleToExport, ThemeHandle themeHandle, boolean canOverride)
Exports the given style into selected theme.
-
-
-
Method Detail
-
exportElement
public static void exportElement(DesignElementHandle elementToExport, java.lang.String libraryFileName, boolean canOverride) throws DesignFileException, SemanticException, java.io.IOException
Exports the given element into one library file. If the library file is not found, new library file will be created and saved as the given file name.- Parameters:
elementToExport
- handle of the element to export.libraryFileName
- file name of the target librarycanOverride
- indicates whether the element with the same name in target library will be overriden.- Throws:
DesignFileException
- if error encountered when open library file with the given file name.SemanticException
- if error encountered when element name is duplicate in the target library.java.io.IOException
- if error encountered when writing file.java.lang.IllegalArgumentException
- if the element to export is not in design file, or the element doesn't has name.
-
exportElements
public static void exportElements(java.util.List elementsToExport, java.lang.String libraryFileName, boolean canOverride) throws DesignFileException, SemanticException, java.io.IOException
Exports the given element list into one library file. If the library file is not found, new library file will be created and saved as the given file name.- Parameters:
elementsToExport
- list of the element to export, each of which is the instance ofDesignElementHandle
.libraryFileName
- file name of the target librarycanOverride
- indicates whether the element with the same name in target library will be overridden.- Throws:
DesignFileException
- if error encountered when open library file with the given file name.SemanticException
- if error encountered when element name is duplicate in the target library.java.io.IOException
- if error encountered when writing file.java.lang.IllegalArgumentException
- if the element to export is not in design file.
-
exportElement
public static void exportElement(DesignElementHandle elementToExport, LibraryHandle targetLibraryHandle, boolean canOverride) throws SemanticException
Exports the given element into one library.- Parameters:
elementToExport
- handle of the element to export.targetLibraryHandle
- handle of target librarycanOverride
- indicates whether the element with the same name in target library will be overridden.- Throws:
SemanticException
- if error encountered when element name is duplicate in the target library.java.lang.IllegalArgumentException
- if the element to export is not in design file.
-
exportStyle
public static void exportStyle(StyleHandle styleToExport, ThemeHandle themeHandle, boolean canOverride) throws SemanticException
Exports the given style into selected theme.- Parameters:
styleToExport
- the style to be exported.themeHandle
- the theme handle.canOverride
- indicates whether the element with the same name in target library will be overriden.- Throws:
SemanticException
-
exportStructure
public static void exportStructure(StructureHandle structToExport, java.lang.String libraryFileName, boolean canOverride) throws DesignFileException, SemanticException, java.io.IOException
Exports the given structure into one library. The allowed structures areEmbeddedImage
,CustomColor
andConfigVariable
. If the library file is not found, new library file will be created and saved as the given file name.- Parameters:
structToExport
- handle of the structure to export.libraryFileName
- file name of the target librarycanOverride
- indicates whether the structure with the same name in target library will be overriden.- Throws:
DesignFileException
- if error encountered when open library file with the given file name.SemanticException
- if error encountered when adding new structure to library or value setting.java.io.IOException
- if error encountered when writing file.java.lang.IllegalArgumentException
- if the element to export is not in design file.
-
exportStructures
public static void exportStructures(java.util.List structsToExport, java.lang.String libraryFileName, boolean canOverride) throws DesignFileException, SemanticException, java.io.IOException
Exports the given structure into one library. The allowed structures areEmbeddedImage
,CustomColor
andConfigVariable
. If the library file is not found, new library file will be created and saved as the given file name.- Parameters:
structsToExport
- list of the structure to export, each of which is the instance ofStructureHandle
.libraryFileName
- file name of the target librarycanOverride
- indicates whether the structure with the same name in target library will be overridden.- Throws:
DesignFileException
- if error encountered when open library file with the given file name.SemanticException
- if error encountered when adding new structure to library or value setting.java.io.IOException
- if error encountered when writing file.java.lang.IllegalArgumentException
- if the element to export is not in design file.
-
exportStructure
public static void exportStructure(StructureHandle structToExport, LibraryHandle targetLibraryHandle, boolean canOverride) throws SemanticException
Exports the given structure into one library. The allowed structures areEmbeddedImage
,CustomColor
andConfigVariable
.- Parameters:
structToExport
- handle of the structure to export.targetLibraryHandle
- handle of target librarycanOverride
- indicates whether the structure with the same name in target library will be overriden.- Throws:
SemanticException
- if error encountered when adding new structure to library or value setting.
-
exportDesign
public static void exportDesign(ReportDesignHandle designToExport, java.lang.String libraryFileName, boolean canOverride, boolean genDefaultName) throws DesignFileException, SemanticException, java.io.IOException
Export the report design to a library file specified by the file name. If the library file is not found, new library file will be created and saved as the given name.- Parameters:
designToExport
- the design which need to be exportedlibraryFileName
- target library file namecanOverride
- indicates whether the element with the same name in target library will be overriden.genDefaultName
- if true, a default name will be generated if an element doesn't has a name. if false, an exception will be throwed indicate that the element to export must has a name- Throws:
DesignFileException
- if the library file has fatal errors which can not be opened.SemanticException
- if error encountered when element name is duplicated in the target library.java.io.IOException
- if error encountered when writing file.
-
exportDesign
public static void exportDesign(ReportDesignHandle designToExport, LibraryHandle targetLibraryHandle, boolean canOverride, boolean genDefaultName) throws SemanticException
Exports one design to library.- Parameters:
designToExport
- handle of the report design to exporttargetLibraryHandle
- handle of target librarycanOverride
- indicates whether the element with the same name in target library will be overridden.genDefaultName
- if true, a default name will be generated if an element doesn't has a name. if false, an exception will be thrown indicate that the element to export must has a name- Throws:
SemanticException
- if error encountered when element name is duplicate in the target library.
-
canExport
public static boolean canExport(DesignElementHandle elementToExport, LibraryHandle targetLibraryHandle, boolean canOverride)
Checks whether the given element can be exported into one library.- Parameters:
elementToExport
- handle of the element to export.targetLibraryHandle
- handle of target librarycanOverride
- indicates whether the element with the same name in target library will be overridden.- Returns:
true
if the element can be exported successfully. Otherwisefalse
.
-
checkExportElementByContext
protected static final boolean checkExportElementByContext(DesignElementHandle handle, ModuleHandle targetLibraryHandle, boolean canOverride)
Checks if extendedItem and cube's content element has the same name as the exported element and its content elements.- Parameters:
handle
- the element handle.targetLibraryHandle
- the target library handle.canOverride
- indicates whether the element with the same name in target library will be overridden.- Returns:
if extendedItem and cube's content element has the same name as the exported element and its content elements, otherwise return .
-
canExport
public static boolean canExport(StyleHandle styleHandle, ThemeHandle themeHandle, boolean canOverride)
Checks whether the given element can be exported into the selected theme.- Parameters:
styleHandle
- handle of the style.themeHandle
- the theme handle.canOverride
- indicates whether the element with the same name in target library will be overridden.- Returns:
true
if the style can be exported successfully. Otherwisefalse
.
-
canExport
public static boolean canExport(StructureHandle structToExport, LibraryHandle targetLibraryHandle, boolean canOverride)
Checks whether the given structure can be exported into one library. Currently, only allows structures such asEmbeddedImage
,CustomColor
andConfigVariable
.- Parameters:
structToExport
- the handle of the structure to export.targetLibraryHandle
- the handle of target librarycanOverride
- indicates whether the element with the same name in target library will be overridden.- Returns:
true
if the element can be exported successfully. Otherwisefalse
.
-
canExport
public static boolean canExport(DesignElementHandle elementToExport)
Checks whether the given element can be exported into one library. Different from anothercanExport
, this method only concerns meta-data level. That is, based on element definition and regardless of the design context.- Parameters:
elementToExport
- handle of the element to export.- Returns:
true
if the element can be exported successfully. Otherwisefalse
.
-
canExport
public static boolean canExport(StructureHandle structToExport)
Checks whether the given structure can be exported into one library. Currently, only allows structures such asEmbeddedImage
,CustomColor
andConfigVariable
.Different from another
canExport
, this method only concerns meta-data level. That is, based on structure definition and regardless of the design context.- Parameters:
structToExport
- the handle of the structure to export.- Returns:
true
if the structure can be exported successfully. Otherwisefalse
.
-
canExport
public static boolean canExport(DesignElementHandle elementToExport, boolean ignoreName)
Checks whether the given element can be exported into one library. Different from anothercanExport
, this method only concerns meta-data level. That is, based on element definition and regardless of the design context.- Parameters:
elementToExport
- handle of the element to exportignoreName
- true if not consider the name of the element when determines whether the element can be export or not, false if must consider the element name to determine- Returns:
true
if the element can be exported successfully. Otherwisefalse
.
-
canExport
public static boolean canExport(StructureHandle structToExport, boolean ignoreName)
Checks whether the given structure can be exported into one library. Currently, only allows structures such asEmbeddedImage
,CustomColor
andConfigVariable
.Different from another
canExport
, this method only concerns meta-data level. That is, based on structure definition and regardless of the design context.- Parameters:
structToExport
- the handle of the structure to exportignoreName
- true if not consider the key name of the structure when determines whether the structure can be export or not, false if must consider the name to determine- Returns:
true
if the structure can be exported successfully. Otherwisefalse
.
-
checkExportedExtendedItem
protected static boolean checkExportedExtendedItem(ExtendedItemHandle elementToExport)
Checks extended item can be exported or not.- Parameters:
elementToExport
- the extended item to export- Returns:
true
if the element can be exported successfully. Otherwisefalse
.
-
-