de.vc.io

## Class ChunkCodec

- java.lang.Object
- - de.vc.io.ChunkCodec

- Direct Known Subclasses:
    CompressingChunkCodec

      public class ChunkCodec
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ChunkCodec()` Creates a new codecs for encoding and decoding chunks.
    `ChunkCodec(boolean optimize)` Creates a new codecs for encoding and decoding chunks and sets the optimize flag.
    `ChunkCodec(int minChunkSizeEnc)` Creates a new codecs for encoding and decoding chunks and sets the minimal size of chunks that are encoded.
    `ChunkCodec(int minChunkSizeEnc, boolean optimize)` Creates a new codex for encoding and decoding chunks, sets the minimal size of chunks that are encoded and optimize flag.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `decode(byte[] bytes, int len)` Do overwrite this methode for decoding a chunk.
    `protected void` | `encode(byte[] bytes, int len)` Do overwrite this methode for encoding a chunk.
    `protected void` | `writeDecoded(byte[] bytes)` Use this call back methode for decoding.
    `protected void` | `writeDecoded(byte[] bytes, int len)` Use this call back methode for decoding.
    `protected void` | `writeEncoded(byte[] bytes)` Use this call back methode for encoding.
    `protected void` | `writeEncoded(byte[] bytes, int len)` Use this call back methode for encoding.

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

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

- - ### Constructor Detail

    - #### ChunkCodec

          public ChunkCodec()

      Creates a new codecs for encoding and decoding chunks. The minimal chunk size for encoding is set to zero.

    - #### ChunkCodec

          public ChunkCodec(int minChunkSizeEnc)

      Creates a new codecs for encoding and decoding chunks and sets the minimal size of chunks that are encoded. Chunks with a length less than this minimum are not encoded. If this codex is used for crypting chunks we recommend you to set this minimum to zero for compressing chunks use you should use this minimum.
      Parameters:
        `minChunkSizeEnc` - Minimal size of chunks that are encoded.

    - #### ChunkCodec

          public ChunkCodec(boolean optimize)

      Creates a new codecs for encoding and decoding chunks and sets the optimize flag. If the encoded chunk is bigger than the plain chunk and the optimize flag is set, the plain chunk is written. This is useful for compressing chunks; for crypting chunks the optimze flag should always be false.
      Parameters:
        `optimize` - true, if optimze.

    - #### ChunkCodec

          public ChunkCodec(int minChunkSizeEnc,
                    boolean optimize)

      Creates a new codex for encoding and decoding chunks, sets the minimal size of chunks that are encoded and optimize flag.
      Parameters:
        `minChunkSizeEnc` - Minimal size of chunks that are encoded.
        `optimize` - true, if optimze.

  - ### Method Detail

    - #### encode

          protected void encode(byte[] bytes,
                    int len)
                         throws java.io.IOException

      Do overwrite this methode for encoding a chunk. If you have encoded the chunk call writeEncoded() methods.
      Parameters:
        `bytes` - Bytes of chunk. Note to respect the len parameter.
        `len` - Length of chunk.
      Throws:
        `java.io.IOException`

    - #### decode

          protected void decode(byte[] bytes,
                    int len)
                         throws java.io.IOException

      Do overwrite this methode for decoding a chunk. If you have decoded the chunk call writeDecoded() methods.
      Parameters:
        `bytes` - Bytes of chunk. Note to respect the len parameter.
        `len` - Length of chunk.
      Throws:
        `java.io.IOException`

    - #### writeEncoded

          protected final void writeEncoded(byte[] bytes)
                                     throws java.io.IOException

      Use this call back methode for encoding.
      Parameters:
        `bytes` - Encoded bytes.
      Throws:
        `java.io.IOException`

    - #### writeEncoded

          protected final void writeEncoded(byte[] bytes,
                          int len)
                                     throws java.io.IOException

      Use this call back methode for encoding.
      Parameters:
        `bytes` - Encoded bytes.
        `len` - Length.
      Throws:
        `java.io.IOException`

    - #### writeDecoded

          protected final void writeDecoded(byte[] bytes)
                                     throws java.io.IOException

      Use this call back methode for decoding.
      Parameters:
        `bytes` - Encoded bytes.
      Throws:
        `java.io.IOException`

    - #### writeDecoded

          protected final void writeDecoded(byte[] bytes,
                          int len)
                                     throws java.io.IOException

      Use this call back methode for decoding.
      Parameters:
        `bytes` - Encoded bytes.
        `len` - Length.
      Throws:
        `java.io.IOException`

© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.