Package: org.codehaus.groovy.tools.groovydoc

## [Java] Class MockOutputTool

- org.codehaus.groovy.tools.groovydoc.MockOutputTool

- All Implemented Interfaces and Traits:
    OutputTool

      public class MockOutputTool
      extends Object
      implements OutputTool

  In-memory OutputTool used by tests. Nothing is written to disk by default, so test runs leave no filesystem artifacts.

  Debugging: pass the `groovydoc.mockOutputTool.dumpDir` system property to also mirror every output call to that directory. Example (from the groovy-groovydoc module):

       ./gradlew :groovy-groovydoc:test -Dgroovydoc.mockOutputTool.dumpDir=build/mock-dump

  When the property is unset, all calls are captured only in the in-memory output and outputAreas maps; inspect them via getText(String) or via a debugger breakpoint.

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `copyResource(String srcPath, String dstPath)` * Copy a resource file (doc-files/, snippet-files/ content) from * `srcPath` to `dstPath`. Routed through the tool rather * than calling `Files.copy` directly so that alternative tools * (notably MockOutputTool) can intercept the side-effect. * * Since: 6.0.0
    `` | `public String` | `getText(String fileName)` Returns the content written to the given filename by writeToOutput, or `null` if no content has been written.
    `` | `public boolean` | `isValidOutputArea(String fileName)` Returns `true` if makeOutputArea was previously called with the given filename.
    `` | `public void` | `makeOutputArea(String filename)` * Ensures that the supplied output location exists. * * Parameters: `filename` - the output directory or root path to prepare
      > `` | `public String` | `toString()` Returns a string representation of the object. API Note: In general, the `toString` method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The string output is not necessarily stable over time or across JVM invocations. Implementation Requirements: The `toString` method for class `Object` returns a string consisting of the name of the class of which the object is an instance, the at-sign character ``@`', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
      >     getClass().getName() + '@' + Integer.toHexString(hashCode())
    Returns: a string representation of the object.
    `` | `public void` | `writeToOutput(String fileName, String text, String charset)` * Writes rendered text to the supplied output file. * * throws: Exception if the output cannot be written Parameters: `fileName` - the file to write * `text` - the rendered content * `charset` - the character set to use when writing *

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public void copyResource(String srcPath, String dstPath)

      * Copy a resource file (doc-files/, snippet-files/ content) from * `srcPath` to `dstPath`. Routed through the tool rather * than calling `Files.copy` directly so that alternative tools * (notably MockOutputTool) can intercept the side-effect. * *

      Since:
        6.0.0

    - #### public String getText(String fileName)

      Returns the content written to the given filename by writeToOutput, or `null` if no content has been written.

    - #### public boolean isValidOutputArea(String fileName)

      Returns `true` if makeOutputArea was previously called with the given filename.

    - #### public void makeOutputArea(String filename)

      * Ensures that the supplied output location exists. * *

      Parameters:
        `filename` - the output directory or root path to prepare

    - #### public String toString()

      Returns a string representation of the object.

      API Note:
        In general, the `toString` method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The string output is not necessarily stable over time or across JVM invocations.
      Implementation Requirements:
        The `toString` method for class `Object` returns a string consisting of the name of the class of which the object is an instance, the at-sign character ``@`', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

        >     getClass().getName() + '@' + Integer.toHexString(hashCode())

      Returns:
        a string representation of the object.

    - #### public void writeToOutput(String fileName, String text, String charset)

      * Writes rendered text to the supplied output file. * *

      throws:
        Exception if the output cannot be written
      Parameters:
        `fileName` - the file to write *
        `text` - the rendered content *
        `charset` - the character set to use when writing *