Package org.eclipse.birt.report.model.api.util

# Class ElementExportUtilImpl

java.lang.Object
org.eclipse.birt.report.model.api.util.ElementExportUtilImpl

Direct Known Subclasses:
  `ElementExportUtil`

public class ElementExportUtilImpl extends 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.

Any violation will throw `IllegalArgumentException`.

## Constructor Summary

Constructors
Constructor
Description
`ElementExportUtilImpl()`

## Method Summary

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 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.
`static void`
`exportDesign(ReportDesignHandle designToExport, 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, 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(List elementsToExport, String libraryFileName, boolean canOverride)`
Exports the given element list into one library file.
`static void`
`exportStructure(StructureHandle structToExport, 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(List structsToExport, 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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ElementExportUtilImpl

public ElementExportUtilImpl()

## Method Details

### exportElement

public static void exportElement(DesignElementHandle elementToExport, String libraryFileName, boolean canOverride) throws DesignFileException, SemanticException, 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 library
  `canOverride` - 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.
  `IOException` - if error encountered when writing file.
  `IllegalArgumentException` - if the element to export is not in design file, or the element doesn't has name.

### exportElements

public static void exportElements(List elementsToExport, String libraryFileName, boolean canOverride) throws DesignFileException, SemanticException, 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 of `DesignElementHandle`.
  `libraryFileName` - file name of the target library
  `canOverride` - 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.
  `IOException` - if error encountered when writing file.
  `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 library
  `canOverride` - 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.
  `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, String libraryFileName, boolean canOverride) throws DesignFileException, SemanticException, IOException
Exports the given structure into one library. The allowed structures are `EmbeddedImage`,`CustomColor` and `ConfigVariable`. 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 library
  `canOverride` - 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.
  `IOException` - if error encountered when writing file.
  `IllegalArgumentException` - if the element to export is not in design file.

### exportStructures

public static void exportStructures(List structsToExport, String libraryFileName, boolean canOverride) throws DesignFileException, SemanticException, IOException
Exports the given structure into one library. The allowed structures are `EmbeddedImage`,`CustomColor` and `ConfigVariable`. 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 of `StructureHandle`.
  `libraryFileName` - file name of the target library
  `canOverride` - 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.
  `IOException` - if error encountered when writing file.
  `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 are `EmbeddedImage`,`CustomColor` and `ConfigVariable`.

Parameters:
  `structToExport` - handle of the structure to export.
  `targetLibraryHandle` - handle of target library
  `canOverride` - 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, String libraryFileName, boolean canOverride, boolean genDefaultName) throws DesignFileException, SemanticException, 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 exported
  `libraryFileName` - target library file name
  `canOverride` - 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.
  `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 export
  `targetLibraryHandle` - handle of target library
  `canOverride` - 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 library
  `canOverride` - indicates whether the element with the same name in target library will be overridden.
Returns:
  `true` if the element can be exported successfully. Otherwise `false`.

### 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:
  <true> if extendedItem and cube's content element has the same name as the exported element and its content elements, otherwise return <false>.

### 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. Otherwise `false`.

### 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 as `EmbeddedImage`, `CustomColor` and `ConfigVariable`.

Parameters:
  `structToExport` - the handle of the structure to export.
  `targetLibraryHandle` - the handle of target library
  `canOverride` - indicates whether the element with the same name in target library will be overridden.
Returns:
  `true` if the element can be exported successfully. Otherwise `false`.

### canExport

public static boolean canExport(DesignElementHandle elementToExport)
Checks whether the given element can be exported into one library. Different from another `canExport`, 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. Otherwise `false`.

### canExport

public static boolean canExport(StructureHandle structToExport)
Checks whether the given structure can be exported into one library. Currently, only allows structures such as `EmbeddedImage`, `CustomColor` and `ConfigVariable`.

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. Otherwise `false`.

### canExport

public static boolean canExport(DesignElementHandle elementToExport, boolean ignoreName)
Checks whether the given element can be exported into one library. Different from another `canExport`, 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
  `ignoreName` - 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. Otherwise `false`.

### 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 as `EmbeddedImage`, `CustomColor` and `ConfigVariable`.

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
  `ignoreName` - 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. Otherwise `false`.

### 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. Otherwise `false`.