goldengate.ftp.core.data.handler
Class FtpDataModeCodec

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by org.jboss.netty.handler.codec.frame.FrameDecoder
          extended by goldengate.ftp.core.data.handler.FtpDataModeCodec
All Implemented Interfaces:
org.jboss.netty.channel.ChannelDownstreamHandler, org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler, org.jboss.netty.channel.LifeCycleAwareChannelHandler

public class FtpDataModeCodec
extends org.jboss.netty.handler.codec.frame.FrameDecoder
implements org.jboss.netty.channel.ChannelDownstreamHandler

First CODEC :
- encode : takes a DataBlock and transforms it to a ChannelBuffer
- decode : takes a ChannelBuffer and transforms it to a DataBlock
STREAM and BLOCK mode are implemented. COMPRESSED mode is not implemented.

Author:
Frederic Bregier

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Field Summary
 
Fields inherited from class org.jboss.netty.handler.codec.frame.FrameDecoder
cumulation
 
Constructor Summary
FtpDataModeCodec(FtpArgumentCode.TransferMode mode, FtpArgumentCode.TransferStructure structure)
           
 
Method Summary
protected  Object decode(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.Channel channel, org.jboss.netty.buffer.ChannelBuffer buf)
           
protected  Object decodeRecord(org.jboss.netty.buffer.ChannelBuffer buf, int length)
           
protected  Object decodeRecordStandard(org.jboss.netty.buffer.ChannelBuffer buf, int length)
           
protected  org.jboss.netty.buffer.ChannelBuffer encode(goldengate.common.file.DataBlock msg)
          Encode a DataBlock in the correct format for Mode
protected  org.jboss.netty.buffer.ChannelBuffer encodeRecord(goldengate.common.file.DataBlock msg, org.jboss.netty.buffer.ChannelBuffer buffer)
           
protected  org.jboss.netty.buffer.ChannelBuffer encodeRecordStandard(goldengate.common.file.DataBlock msg, org.jboss.netty.buffer.ChannelBuffer buffer)
           
 FtpArgumentCode.TransferMode getMode()
           
 FtpArgumentCode.TransferStructure getStructure()
           
 void handleDownstream(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ChannelEvent e)
           
 void setCodecReady()
          Inform the Codec that DataNetworkHandler is ready (called from DataNetworkHandler after setCorrectCodec).
 void setMode(FtpArgumentCode.TransferMode mode)
           
 void setStructure(FtpArgumentCode.TransferStructure structure)
           
 
Methods inherited from class org.jboss.netty.handler.codec.frame.FrameDecoder
actualReadableBytes, afterAdd, afterRemove, appendToCumulation, beforeAdd, beforeRemove, channelClosed, channelDisconnected, cleanup, decodeLast, exceptionCaught, getMaxCumulationBufferCapacity, internalBuffer, isUnfold, messageReceived, newCumulationBuffer, replace, setMaxCumulationBufferCapacity, setUnfold, unfoldAndFireMessageReceived, updateCumulation
 
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
channelBound, channelConnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FtpDataModeCodec

public FtpDataModeCodec(FtpArgumentCode.TransferMode mode,
                        FtpArgumentCode.TransferStructure structure)
Parameters:
mode -
structure -
Method Detail

setCodecReady

public void setCodecReady()
Inform the Codec that DataNetworkHandler is ready (called from DataNetworkHandler after setCorrectCodec).


decodeRecordStandard

protected Object decodeRecordStandard(org.jboss.netty.buffer.ChannelBuffer buf,
                                      int length)

decodeRecord

protected Object decodeRecord(org.jboss.netty.buffer.ChannelBuffer buf,
                              int length)

decode

protected Object decode(org.jboss.netty.channel.ChannelHandlerContext ctx,
                        org.jboss.netty.channel.Channel channel,
                        org.jboss.netty.buffer.ChannelBuffer buf)
                 throws Exception
Specified by:
decode in class org.jboss.netty.handler.codec.frame.FrameDecoder
Throws:
Exception

encodeRecordStandard

protected org.jboss.netty.buffer.ChannelBuffer encodeRecordStandard(goldengate.common.file.DataBlock msg,
                                                                    org.jboss.netty.buffer.ChannelBuffer buffer)

encodeRecord

protected org.jboss.netty.buffer.ChannelBuffer encodeRecord(goldengate.common.file.DataBlock msg,
                                                            org.jboss.netty.buffer.ChannelBuffer buffer)

encode

protected org.jboss.netty.buffer.ChannelBuffer encode(goldengate.common.file.DataBlock msg)
                                               throws goldengate.common.exception.InvalidArgumentException
Encode a DataBlock in the correct format for Mode

Parameters:
msg -
Returns:
the ChannelBuffer or null when the last block is already done
Throws:
goldengate.common.exception.InvalidArgumentException

getMode

public FtpArgumentCode.TransferMode getMode()
Returns:
the mode

setMode

public void setMode(FtpArgumentCode.TransferMode mode)
Parameters:
mode - the mode to set

getStructure

public FtpArgumentCode.TransferStructure getStructure()
Returns:
the structure

setStructure

public void setStructure(FtpArgumentCode.TransferStructure structure)
Parameters:
structure - the structure to set

handleDownstream

public void handleDownstream(org.jboss.netty.channel.ChannelHandlerContext ctx,
                             org.jboss.netty.channel.ChannelEvent e)
                      throws Exception
Specified by:
handleDownstream in interface org.jboss.netty.channel.ChannelDownstreamHandler
Throws:
Exception


Copyright © 2009-2012 Frederic Bregier. All Rights Reserved.