org.apache.mina.filter.errorgenerating

## Class ErrorGeneratingFilter

- java.lang.Object
- - org.apache.mina.core.filterchain.IoFilterAdapter
  - - org.apache.mina.filter.errorgenerating.ErrorGeneratingFilter

- All Implemented Interfaces:
    IoFilter

      public class ErrorGeneratingFilter
      extends IoFilterAdapter

  An `IoFilter` implementation generating random bytes and PDU modification in your communication streams. It's quite simple to use : `ErrorGeneratingFilter egf = new ErrorGeneratingFilter();` For activate the change of some bytes in your `IoBuffer`, for a probability of 200 out of 1000 `IoBuffer` processed : `egf.setChangeByteProbability(200);` For activate the insertion of some bytes in your `IoBuffer`, for a probability of 200 out of 1000 : `egf.setInsertByteProbability(200);` And for the removing of some bytes : `egf.setRemoveByteProbability(200);` You can activate the error generation for write or read with the following methods : `egf.setManipulateReads(true); egf.setManipulateWrites(true);`
  Author:
    Apache MINA Project

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter

      `IoFilter.NextFilter`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ErrorGeneratingFilter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)` Filters `IoSession.write(Object)` method invocation.
    `int` | `getChangeByteProbability()`
    `int` | `getDuplicatePduProbability()`
    `int` | `getInsertByteProbability()`
    `int` | `getMaxInsertByte()`
    `int` | `getRemoveByteProbability()`
    `int` | `getRemovePduProbability()`
    `int` | `getResendPduLasterProbability()`
    `boolean` | `isManipulateReads()`
    `boolean` | `isManipulateWrites()`
    `void` | `messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message)` Filters `IoHandler.messageReceived(IoSession,Object)` event.
    `void` | `setChangeByteProbability(int changeByteProbability)` Set the probability for the change byte error.
    `void` | `setDuplicatePduProbability(int duplicatePduProbability)` not functional ATM
    `void` | `setInsertByteProbability(int insertByteProbability)` Set the probability for the insert byte error.
    `void` | `setManipulateReads(boolean manipulateReads)` Set to true if you want to apply error to the read `IoBuffer`
    `void` | `setManipulateWrites(boolean manipulateWrites)` Set to true if you want to apply error to the written `IoBuffer`
    `void` | `setMaxInsertByte(int maxInsertByte)` Set the maximum number of byte the filter can insert in a `IoBuffer`.
    `void` | `setRemoveByteProbability(int removeByteProbability)` Set the probability for the remove byte error.
    `void` | `setRemovePduProbability(int removePduProbability)` not functional ATM
    `void` | `setResendPduLasterProbability(int resendPduLasterProbability)` not functional ATM

    - ### Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter

      `destroy, exceptionCaught, filterClose, init, messageSent, onPostAdd, onPostRemove, onPreAdd, onPreRemove, sessionClosed, sessionCreated, sessionIdle, sessionOpened, toString`

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

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

- - ### Constructor Detail

    - #### ErrorGeneratingFilter

          public ErrorGeneratingFilter()

  - ### Method Detail

    - #### filterWrite

          public void filterWrite(IoFilter.NextFilter nextFilter,
                         IoSession session,
                         WriteRequest writeRequest)
                           throws Exception

      Description copied from class: `IoFilterAdapter`
      Filters `IoSession.write(Object)` method invocation.
      Specified by:
        `filterWrite` in interface `IoFilter`
      Overrides:
        `filterWrite` in class `IoFilterAdapter`
      Throws:
        `Exception`

    - #### messageReceived

          public void messageReceived(IoFilter.NextFilter nextFilter,
                             IoSession session,
                             Object message)
                               throws Exception

      Description copied from class: `IoFilterAdapter`
      Filters `IoHandler.messageReceived(IoSession,Object)` event.
      Specified by:
        `messageReceived` in interface `IoFilter`
      Overrides:
        `messageReceived` in class `IoFilterAdapter`
      Throws:
        `Exception`

    - #### getChangeByteProbability

          public int getChangeByteProbability()

    - #### setChangeByteProbability

          public void setChangeByteProbability(int changeByteProbability)

      Set the probability for the change byte error. If this probability is > 0 the filter will modify a random number of byte of the processed `IoBuffer`.
      Parameters:
        `changeByteProbability` - probability of modifying an IoBuffer out of 1000 processed `IoBuffer`

    - #### getDuplicatePduProbability

          public int getDuplicatePduProbability()

    - #### setDuplicatePduProbability

          public void setDuplicatePduProbability(int duplicatePduProbability)

      not functional ATM
      Parameters:
        `duplicatePduProbability` -

    - #### getInsertByteProbability

          public int getInsertByteProbability()

    - #### setInsertByteProbability

          public void setInsertByteProbability(int insertByteProbability)

      Set the probability for the insert byte error. If this probability is > 0 the filter will insert a random number of byte in the processed `IoBuffer`.
      Parameters:
        `changeByteProbability` - probability of inserting in IoBuffer out of 1000 processed `IoBuffer`

    - #### isManipulateReads

          public boolean isManipulateReads()

    - #### setManipulateReads

          public void setManipulateReads(boolean manipulateReads)

      Set to true if you want to apply error to the read `IoBuffer`
      Parameters:
        `manipulateReads` -

    - #### isManipulateWrites

          public boolean isManipulateWrites()

    - #### setManipulateWrites

          public void setManipulateWrites(boolean manipulateWrites)

      Set to true if you want to apply error to the written `IoBuffer`
      Parameters:
        `manipulateWrites` -

    - #### getRemoveByteProbability

          public int getRemoveByteProbability()

    - #### setRemoveByteProbability

          public void setRemoveByteProbability(int removeByteProbability)

      Set the probability for the remove byte error. If this probability is > 0 the filter will remove a random number of byte in the processed `IoBuffer`.
      Parameters:
        `changeByteProbability` - probability of modifying an `IoBuffer` out of 1000 processed IoBuffer

    - #### getRemovePduProbability

          public int getRemovePduProbability()

    - #### setRemovePduProbability

          public void setRemovePduProbability(int removePduProbability)

      not functional ATM
      Parameters:
        `removePduProbability` -

    - #### getResendPduLasterProbability

          public int getResendPduLasterProbability()

    - #### setResendPduLasterProbability

          public void setResendPduLasterProbability(int resendPduLasterProbability)

      not functional ATM
      Parameters:
        `resendPduLasterProbability` -

    - #### getMaxInsertByte

          public int getMaxInsertByte()

    - #### setMaxInsertByte

          public void setMaxInsertByte(int maxInsertByte)

      Set the maximum number of byte the filter can insert in a `IoBuffer`. The default value is 10.
      Parameters:
        `maxInsertByte` - maximum bytes inserted in a `IoBuffer`

Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.