Class ReportFileTool

  • All Implemented Interfaces:
    com.nomagic.magicreport.engine.ITool, com.nomagic.magicreport.IVariable, java.io.Serializable, java.lang.Cloneable

    @OpenApiAll
    public class ReportFileTool
    extends com.nomagic.magicreport.engine.tools.FileTool
    See Also:
    Serialized Form
    • 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 java.lang.String CONTEXT_NAME  
      • 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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String copy​(Element element)
      Copy the file that is extracted from attached file element to output file in binary format.
      java.lang.String copy​(Element element, java.lang.String outputFileName)
      Copy the file that is extracted from attached file element to output file in binary format.
      java.lang.String 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
      java.lang.String create​(Element element, java.lang.Object importObject)
      A shortcut to create file from specific element.
      The output filename is same the extracted file name from attached element.
      java.lang.String create​(Element element, java.lang.String outputFileName, java.lang.Object importObject)
      Generate the report output from given attached file element.
      java.lang.String createAndWait​(Element element)
      Invoke a new template engine to generate a report and return the path to output file.
      java.lang.String createAndWait​(Element element, java.lang.Object contextValue)
      Invoke a new template engine to generate a report and return the path to output file.
      java.lang.String createAndWait​(Element element, java.lang.String outputFileName, java.lang.Object contextValue)
      Invoke a new template engine to generate a report and return the path to output file.
      java.lang.String createAndWait​(Element element, java.lang.String outputFileName, java.lang.String contextName, java.lang.Object contextValue)
      Invoke a new template engine to generate a report and return the path to output file.
      java.lang.String createAndWait​(Element element, java.lang.String outputFileName, java.util.Map<java.lang.String,​java.lang.Object> context)
      Invoke a new template engine to generate a report and return the path to output file.
      java.lang.String createAndWait​(Element element, java.util.Map<java.lang.String,​java.lang.Object> context)
      Invoke a new template engine to generate a report and return the path to output file.
      com.nomagic.magicreport.engine.ITool.Void silentCreate​(Element element)
      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, java.lang.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, java.lang.String outputFileName, java.lang.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, 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.util.Observable

        addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
      • 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
    • Constructor Detail

      • ReportFileTool

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

      • 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,
                                                                      java.lang.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,
                                                                      java.lang.String outputFileName,
                                                                      java.lang.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 java.lang.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 java.lang.String create​(Element element,
                                       java.lang.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 java.lang.String create​(Element element,
                                       java.lang.String outputFileName,
                                       java.lang.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 java.lang.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 java.lang.String copy​(Element element,
                                     java.lang.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 java.lang.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 java.lang.String createAndWait​(Element element,
                                              java.lang.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 java.lang.String createAndWait​(Element element,
                                              java.lang.String outputFileName,
                                              java.lang.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 java.lang.String createAndWait​(Element element,
                                              java.lang.String outputFileName,
                                              java.lang.String contextName,
                                              java.lang.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 java.lang.String createAndWait​(Element element,
                                              java.util.Map<java.lang.String,​java.lang.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 java.lang.String createAndWait​(Element element,
                                              java.lang.String outputFileName,
                                              java.util.Map<java.lang.String,​java.lang.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.