de.esprit.appsuite.nio.ascii

## Class AsciiWriter<C extends ApplicationContext>

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<C>
    - - de.esprit.appsuite.task.AbstractAsyncExecutable<C>
      - - de.esprit.appsuite.nio.ascii.AsciiWriter<C>

- All Implemented Interfaces:
    ApplicationObject<C>, AsyncExecutable<C>, CancellableTask, TaskMonitorSupport, SimpleLogSupport, Dumpable, Executable, java.io.Closeable, java.lang.AutoCloseable

      public class AsciiWriter<C extends ApplicationContext>
      extends AbstractAsyncExecutable<C>
      implements java.io.Closeable

  This writer uses NIO for writing raw ASCII data with best possible performance.
  Author:
    Thomas Stecher, Rainer Buesch

- - ### Field Summary

    - ### Fields inherited from class de.esprit.appsuite.task.AbstractAsyncExecutable

      `childTaskRef, isTestMode, monitorController, resultRef, stateFlag`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AsciiWriter(C ctx, java.io.ByteArrayOutputStream stream)`
    `AsciiWriter(C ctx, java.io.ByteArrayOutputStream stream, boolean isAppendMode)`
    `AsciiWriter(C ctx, java.io.ByteArrayOutputStream stream, int buffSize)`
    `AsciiWriter(C ctx, java.io.ByteArrayOutputStream stream, int buffSize, boolean isAppendMode)`
    `AsciiWriter(C ctx, java.io.File file)`
    `AsciiWriter(C ctx, java.io.File file, boolean isAppendMode)`
    `AsciiWriter(C ctx, FileInfo fileInfo, java.io.OutputStream stream)`
    `AsciiWriter(C ctx, FileInfo fileInfo, java.io.OutputStream stream, boolean isAppendMode)`
    `AsciiWriter(C ctx, FileInfo fileInfo, java.io.OutputStream stream, int buffSize)`
    `AsciiWriter(C ctx, FileInfo fileInfo, java.io.OutputStream outStream, int buffSize, boolean isAppendMode)`
    `AsciiWriter(C ctx, java.io.File file, int buffSize)`
    `AsciiWriter(C ctx, java.io.File file, int buffSize, boolean isAppendMode)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `protected java.io.FileOutputStream` | `createFileOutputStream(java.io.File file)`
    `void` | `executeAsync()` Contains the code to be executed asynchronously.
    `void` | `flush()`
    `java.lang.String` | `getEncoding()` Returns the character encoding being used, null if not set.
    `FileInfo` | `getFileInfo()`
    `java.io.File` | `getOutputFile()`
    `long` | `getWrittenByteCount()`
    `int` | `getWrittenLineCount()`
    `int` | `getWrittenOperationCount()`
    `boolean` | `isAppendMode()` Tells whether the output file was opened in append-mode.
    `boolean` | `isOutputOpen()` Tells whether the output file was opened.
    `void` | `openOutput()` Opens the output channel for writing.
    `protected void` | `performWrite()`
    `void` | `setAppendMode(boolean isAppendMode)`
    `void` | `setEncoding(java.lang.String encoding)` Defines the character encoding to be used.
    `void` | `write(AsciiLine line)`
    `void` | `write(AsciiWord word)`
    `void` | `write(byte[] bytes)`
    `void` | `write(byte[] data, int start, int length)`
    `void` | `write(char value)`
    `void` | `write(double value)`
    `void` | `write(long value)`
    `void` | `write(java.lang.Object object)`
    `void` | `write(java.lang.String text)`
    `void` | `write(java.lang.String format, java.lang.Object... args)`
    `void` | `writeColon()` Write ', ' (valueSeparator and a space)
    `void` | `writeLine()` Writes a new-line character.
    `void` | `writeLine(java.lang.String line)` Writes a line of text without any indentation.
    `void` | `writeLine(java.lang.String format, java.lang.Object... args)`
    `void` | `writeQuoted(java.lang.String value)`
    `void` | `writeSpace()`

    - ### Methods inherited from class de.esprit.appsuite.task.AbstractAsyncExecutable

      `addMonitor, checkCancelled, checkForErrorAndRethrow, clearMonitors, createRunStateFlag, doOnCancel, doOnFailure, execute, executeSubTask, getError, getMaxProgressSteps, getMonitorCount, getMonitors, getName, getProgressStepCount, getResult, getRunStateFlag, getTaskId, getType, handleCancellation, handleFailure, handleFinish, handleStart, handleSuccess, hasError, hasMonitor, isCancellable, notifyProceeded, registerTaskStateChange, removeMonitor, resetProgress, setCancellable, setLogLevel, setMaxProgressSteps, setMonitor, setName, setName, setResult, setRunStateFlag, setTaskId, setType, shouldFireMonitor, sleepChecked, wasCancelled`

    - ### Methods inherited from class de.esprit.appsuite.launch.AbstractApplicationObject

      `getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString`

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

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

    - ### Methods inherited from interface de.esprit.appsuite.launch.ApplicationObject

      `getApplicationContext`

    - ### Methods inherited from interface de.esprit.common.log.SimpleLogSupport

      `getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

- - ### Constructor Detail

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     java.io.File file)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     java.io.File file,
                     int buffSize)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     java.io.File file,
                     boolean isAppendMode)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     java.io.File file,
                     int buffSize,
                     boolean isAppendMode)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     java.io.ByteArrayOutputStream stream)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     java.io.ByteArrayOutputStream stream,
                     int buffSize)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     FileInfo fileInfo,
                     java.io.OutputStream stream,
                     int buffSize)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     java.io.ByteArrayOutputStream stream,
                     boolean isAppendMode)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     java.io.ByteArrayOutputStream stream,
                     int buffSize,
                     boolean isAppendMode)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     FileInfo fileInfo,
                     java.io.OutputStream stream)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     FileInfo fileInfo,
                     java.io.OutputStream stream,
                     boolean isAppendMode)

    - #### AsciiWriter

          public AsciiWriter(C ctx,
                     FileInfo fileInfo,
                     java.io.OutputStream outStream,
                     int buffSize,
                     boolean isAppendMode)

  - ### Method Detail

    - #### setAppendMode

          public void setAppendMode(boolean isAppendMode)

    - #### setEncoding

          public void setEncoding(java.lang.String encoding)

      Defines the character encoding to be used. If not set, then the default platform encoding is used.

    - #### getEncoding

          public java.lang.String getEncoding()

      Returns the character encoding being used, null if not set. Note that if the encoding was not explicitly set, then the default platform encoding is used.

    - #### isAppendMode

          public final boolean isAppendMode()

      Tells whether the output file was opened in append-mode.

    - #### isOutputOpen

          public boolean isOutputOpen()

      Tells whether the output file was opened.
      See Also:
        `openOutput()`

    - #### openOutput

          public final void openOutput()
                                throws java.io.FileNotFoundException

      Opens the output channel for writing.
      Throws:
        `java.io.FileNotFoundException`

    - #### getFileInfo

          public final FileInfo getFileInfo()

    - #### getOutputFile

          public final java.io.File getOutputFile()

    - #### executeAsync

          public final void executeAsync()
                                  throws java.lang.Exception

      Description copied from interface: `AsyncExecutable`
      Contains the code to be executed asynchronously. WARNING: This method should never be called directly by the programmer. It rather must be called by `Runnable.run()` for async execution.
      Specified by:
        `executeAsync` in interface `AsyncExecutable<C extends ApplicationContext>`
      Specified by:
        `executeAsync` in class `AbstractAsyncExecutable<C extends ApplicationContext>`
      Throws:
        `java.lang.Exception`
      See Also:
        `for synchronous execution`

    - #### performWrite

          protected void performWrite()
                               throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### createFileOutputStream

          protected java.io.FileOutputStream createFileOutputStream(java.io.File file)
                                                             throws java.io.FileNotFoundException

      Throws:
        `java.io.FileNotFoundException`

    - #### getWrittenByteCount

          public final long getWrittenByteCount()

    - #### getWrittenLineCount

          public final int getWrittenLineCount()

    - #### getWrittenOperationCount

          public final int getWrittenOperationCount()

    - #### write

          public final void write(byte[] bytes)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public final void write(long value)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public final void write(double value)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public final void write(char value)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public final void write(java.lang.String text)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public final void write(java.lang.Object object)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public final void write(AsciiWord word)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public final void write(AsciiLine line)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeLine

          public final void writeLine(java.lang.String line)
                               throws java.io.IOException

      Writes a line of text without any indentation.
      Throws:
        `java.io.IOException`

    - #### writeLine

          public final void writeLine()
                               throws java.io.IOException

      Writes a new-line character.
      Throws:
        `java.io.IOException`

    - #### writeLine

          public final void writeLine(java.lang.String format,
                       java.lang.Object... args)
                               throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public final void write(java.lang.String format,
                   java.lang.Object... args)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public final void write(byte[] data,
                   int start,
                   int length)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### flush

          public final void flush()
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### close

          public void close()
                     throws java.io.IOException

      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Throws:
        `java.io.IOException`

    - #### writeSpace

          public final void writeSpace()
                                throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### writeColon

          public final void writeColon()
                                throws java.lang.Exception

      Write ', ' (valueSeparator and a space)
      Throws:
        `java.lang.Exception`

    - #### writeQuoted

          public final void writeQuoted(java.lang.String value)
                                 throws java.lang.Exception

      Throws:
        `java.lang.Exception`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.