org.eclipse.birt.report.model.api.util
Class ElementExportUtil

java.lang.Object
  extended by org.eclipse.birt.report.model.api.util.ElementExportUtil

public class ElementExportUtil
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:

Any violation will throw IllegalArgumentException.


Constructor Summary
ElementExportUtil()
           
 
Method Summary
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 void exportDesign(ReportDesignHandle designToExport, LibraryHandle targetLibraryHandle, boolean canOverride, boolean genDefaultName)
          Exports one design to library.
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 exportElement(DesignElementHandle elementToExport, LibraryHandle targetLibraryHandle, boolean canOverride)
          Exports the given element into one library.
static void exportElement(DesignElementHandle elementToExport, java.lang.String libraryFileName, boolean canOverride)
          Exports the given element into one library file.
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, LibraryHandle targetLibraryHandle, boolean canOverride)
          Exports the given structure into one library.
static void exportStructure(StructureHandle structToExport, java.lang.String libraryFileName, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementExportUtil

public ElementExportUtil()
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 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.
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 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.
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 library
canOverride - indicates whether the element with the same name in target library will be overriden.
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.

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 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.
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 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.
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 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,
                                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 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.
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 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.

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.


Copyright © 2008 Actuate Corp. All rights reserved.