Class ReportFileTool

java.lang.Object
java.util.Observable
com.nomagic.magicreport.engine.Tool
com.nomagic.magicreport.engine.ConcurrentTool
com.nomagic.magicreport.engine.tools.FileTool
com.nomagic.magicdraw.magicreport.tools.ReportFileTool
All Implemented Interfaces:
com.nomagic.magicreport.engine.ITool, com.nomagic.magicreport.IVariable, Serializable, Cloneable

@OpenApiAll public class ReportFileTool extends com.nomagic.magicreport.engine.tools.FileTool
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.nomagic.magicreport.engine.ConcurrentTool

    com.nomagic.magicreport.engine.ConcurrentTool.ConsumeObject

    Nested classes/interfaces inherited from interface com.nomagic.magicreport.engine.ITool

    com.nomagic.magicreport.engine.ITool.HTMLString, com.nomagic.magicreport.engine.ITool.RetainedString, com.nomagic.magicreport.engine.ITool.Void
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class com.nomagic.magicreport.engine.Tool

    context, properties

    Fields inherited from interface com.nomagic.magicreport.engine.ITool

    VOID
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReportFileTool(com.nomagic.magicreport.engine.ITemplateEngine engine)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    copy(Element element)
    Copy the file that is extracted from attached file element to output file in binary format.
    copy(Element element, String outputFileName)
    Copy the file that is extracted from attached file element to output file in binary format.
    create(Element element)
    A shortcut to create file from specific element.
    The output filename is same the extracted file name from attached element.
    No import context object
    create(Element element, Object importObject)
    A shortcut to create file from specific element.
    The output filename is same the extracted file name from attached element.
    create(Element element, String outputFileName, Object importObject)
    Generate the report output from given attached file element.
    Invoke a new template engine to generate a report and return the path to output file.
    createAndWait(Element element, Object contextValue)
    Invoke a new template engine to generate a report and return the path to output file.
    createAndWait(Element element, String outputFileName, Object contextValue)
    Invoke a new template engine to generate a report and return the path to output file.
    createAndWait(Element element, String outputFileName, String contextName, Object contextValue)
    Invoke a new template engine to generate a report and return the path to output file.
    createAndWait(Element element, String outputFileName, Map<String,Object> context)
    Invoke a new template engine to generate a report and return the path to output file.
    createAndWait(Element element, Map<String,Object> context)
    Invoke a new template engine to generate a report and return the path to output file.
    com.nomagic.magicreport.engine.ITool.Void
    A shortcut to create file from specific element.
    The output filename is same the extracted file name from attached element.
    com.nomagic.magicreport.engine.ITool.Void
    silentCreate(Element element, Object importObject)
    A shortcut to create file from specific element.
    The output filename is same the extracted file name from attached element.
    com.nomagic.magicreport.engine.ITool.Void
    silentCreate(Element element, String outputFileName, Object importObject)
    Generate the report output from given attached file element.

    Methods inherited from class com.nomagic.magicreport.engine.tools.FileTool

    computeName, computeName, consume, copy, copy, copy, copy, copy, copy, create, create, create, create, create, create, create, create, create, create, createAndWait, createAndWait, createAndWait, createAndWait, createAndWait, createAndWait, createAndWait, createAndWait, createAndWait, createAndWait, createAndWait, createAndWait, createAndWait, createDir, exists, getResultPath, isEmpty, resolveOutputFileName, silentCreate, silentCreate, silentCreate, silentCreate, silentCreate, silentCreate, silentCreate

    Methods inherited from class com.nomagic.magicreport.engine.ConcurrentTool

    destroy, getCustomPoolSize, isNoSpaceException, isRunning, offer

    Methods inherited from class com.nomagic.magicreport.engine.Tool

    clone, getContext, getProperties, getProperty, getProperty, notifyObservers, setContext, setProperties

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface com.nomagic.magicreport.engine.ITool

    clearTool
  • Field Details

  • Constructor Details

    • ReportFileTool

      public ReportFileTool(com.nomagic.magicreport.engine.ITemplateEngine engine)
      Constructor
      Parameters:
      engine - template engine
  • Method Details

    • silentCreate

      public com.nomagic.magicreport.engine.ITool.Void silentCreate(Element element) throws com.nomagic.magicreport.ParseErrorException
      A shortcut to create file from specific element.
      The output filename is same the extracted file name from attached element.

      For example:

          $file.silentCreate($anAttachedFileElement)
       
      Parameters:
      element - an AttachedFile element
      Returns:
      void
      Throws:
      com.nomagic.magicreport.ParseErrorException - when template has a syntax or other error which prevents it from being parsed.
    • silentCreate

      public com.nomagic.magicreport.engine.ITool.Void silentCreate(Element element, Object importObject) throws com.nomagic.magicreport.ParseErrorException
      A shortcut to create file from specific element.
      The output filename is same the extracted file name from attached element.

      For example:

          $file.silentCreate($anAttachedFileElement,'')
       

      If importObject is an instance of java.util.Map, key-value of Map will be used as name-value of context.

      Parameters:
      element - an AttachedFile element
      importObject - the object reference, which will be DefaultElement in the template file. You can use DefaultElement variable in the template file for getting the data.
      Returns:
      void
      Throws:
      com.nomagic.magicreport.ParseErrorException - when template has a syntax or other error which prevents it from being parsed.
    • silentCreate

      public com.nomagic.magicreport.engine.ITool.Void silentCreate(Element element, String outputFileName, Object importObject) throws com.nomagic.magicreport.ParseErrorException
      Generate the report output from given attached file element.

      For example:

          $file.silentCreate($anAttachedFileElement,'overview.html','')
       

      If importObject is an instance of java.util.Map, key-value of Map will be used as name-value of context.

      Parameters:
      element - an AttachedFile element
      outputFileName - the output file name
      importObject - the object reference, which will be DefaultElement in the template file. You can use DefaultElement variable in the template file for getting the data.
      Returns:
      void
      Throws:
      com.nomagic.magicreport.ParseErrorException - when template has a syntax or other error which prevents it from being parsed.
    • create

      public String create(Element element) throws com.nomagic.magicreport.ParseErrorException
      A shortcut to create file from specific element.
      The output filename is same the extracted file name from attached element.
      No import context object

      For example:

          <a href="$file.create($anAttachedFileElement)">attachedFile.html</a>
       
      Parameters:
      element - an AttachedFile element
      Returns:
      the output pathname. It will return empty string, if there is any error.
      Throws:
      com.nomagic.magicreport.ParseErrorException - when template has a syntax or other error which prevents it from being parsed.
    • create

      public String create(Element element, Object importObject) throws com.nomagic.magicreport.ParseErrorException
      A shortcut to create file from specific element.
      The output filename is same the extracted file name from attached element.

      For example:

          <a href="$file.create($anAttachedFileElement,'')">attachedFile.html</a>
       

      If importObject is an instance of java.util.Map, key-value of Map will be used as name-value of context.

      Parameters:
      element - an AttachedFile element
      importObject - the object reference, which will be DefaultElement in the template file. You can use DefaultElement variable in the template file for getting the data.
      Returns:
      the output pathname. It will return empty string, if there is any error.
      Throws:
      com.nomagic.magicreport.ParseErrorException - when template has a syntax or other error which prevents it from being parsed.
    • create

      public String create(Element element, String outputFileName, Object importObject) throws com.nomagic.magicreport.ParseErrorException
      Generate the report output from given attached file element.

      For example:

          <a href="$file.create($anAttachedFileElement,'attachedFile.html','')">attachedFile.html</a>
       

      If importObject is an instance of java.util.Map, key-value of Map will be used as name-value of context.

      Parameters:
      element - an AttachedFile element
      outputFileName - the output file name
      importObject - the object reference, which will be DefaultElement in the template file. You can use DefaultElement variable in the template file for getting the data.
      Returns:
      the output pathname. It will return empty string, if there is any error.
      Throws:
      com.nomagic.magicreport.ParseErrorException - when template has a syntax or other error which prevents it from being parsed.
    • copy

      public String copy(Element element)
      Copy the file that is extracted from attached file element to output file in binary format.

      For example:

         <img src="$file.copy($anAttachedFileElement)">
       
      Parameters:
      element - an AttachedFile element
      Returns:
      the output pathname. It will return empty string, if there is any error.
    • copy

      public String copy(Element element, String outputFileName)
      Copy the file that is extracted from attached file element to output file in binary format.

      For example:

         <img src="$file.copy($anAttachedFileElement,'icon.gif')">
       
      Parameters:
      element - an AttachedFile element
      outputFileName - the output filename
      Returns:
      the output pathname. It will return empty string, if there is any error.
    • createAndWait

      public String createAndWait(Element element)
      Invoke a new template engine to generate a report and return the path to output file. The output report will be named by the extracted file from attached element.
      Parameters:
      element - an AttachedFile element
      Returns:
      an absolute path to output file.
    • createAndWait

      public String createAndWait(Element element, Object contextValue)
      Invoke a new template engine to generate a report and return the path to output file. The output report will be named by the extracted file from attached element.
      Parameters:
      element - an AttachedFile element
      contextValue - additional object adding to new template context with default $importer name.
      Returns:
      an absolute path to output file.
    • createAndWait

      public String createAndWait(Element element, String outputFileName, Object contextValue)
      Invoke a new template engine to generate a report and return the path to output file.

      "importer" will be used as a name of context value.

      Parameters:
      element - an AttachedFile element
      outputFileName - an output report file name.
      contextValue - additional object adding to new template context with default $importer name.
      Returns:
      an absolute path to output file.
    • createAndWait

      public String createAndWait(Element element, String outputFileName, String contextName, Object contextValue)
      Invoke a new template engine to generate a report and return the path to output file.
      Parameters:
      element - an AttachedFile element
      outputFileName - an output report file name.
      contextName - adding object context's name.
      contextValue - additional object adding to new template context.
      Returns:
      an absolute path to output file.
    • createAndWait

      public String createAndWait(Element element, Map<String,Object> context)
      Invoke a new template engine to generate a report and return the path to output file. The output report will be named by template file name.
      Parameters:
      templateFile - an input template file.
      context - additional context adding to new template.
      Returns:
      an absolute path to output file.
    • createAndWait

      public String createAndWait(Element element, String outputFileName, Map<String,Object> context)
      Invoke a new template engine to generate a report and return the path to output file.
      Parameters:
      element - an AttachedFile element
      outputFileName - an output report file name.
      context - additional context adding to new template.
      Returns:
      an absolute path to output file.