org.apache.directory.shared.asn1.codec.stateful
Class DecoderStack

java.lang.Object
  extended byorg.apache.directory.shared.asn1.codec.stateful.AbstractStatefulDecoder
      extended byorg.apache.directory.shared.asn1.codec.stateful.DecoderStack
All Implemented Interfaces:
StatefulDecoder

public class DecoderStack
extends AbstractStatefulDecoder

A stack of decoders used for the additive application of multiple decoders forming a linear staged decoder pipeline.

Version:
$Rev: 434412 $
Author:
Apache Directory Project

Constructor Summary
DecoderStack()
          Creates an empty stack of chained decoders.
 
Method Summary
 void clear()
          Clears the stack popping all decoders setting their callbacks to null.
 void decode(java.lang.Object encoded)
          Decodes an encoded object by calling decode on the decoder at the bottom of the stack.
 boolean isEmpty()
          Gets whether or not this stack is empty.
 StatefulDecoder pop()
          Pops the terminal decoder off of this DecoderStack.
 void push(StatefulDecoder decoder)
          Pushs a new terminal decoder onto the top of this DecoderStack.
 
Methods inherited from class org.apache.directory.shared.asn1.codec.stateful.AbstractStatefulDecoder
decodeOccurred, getDecoderMonitor, setCallback, setDecoderMonitor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecoderStack

public DecoderStack()
Creates an empty stack of chained decoders.

Method Detail

push

public void push(StatefulDecoder decoder)
Pushs a new terminal decoder onto the top of this DecoderStack. The old top decoder is chained to feed its decoded object to the new top decoder. The new pushed decoder will report decode events to this DecoderStacks callback.

Parameters:
decoder - the terminal decoder to push onto this stack

pop

public StatefulDecoder pop()
Pops the terminal decoder off of this DecoderStack. The popped decoder has its callback cleared. If the stack is empty nothing happens and this StatefulDecoder, the DecoderStack, is returned to protect against null.

Returns:
the top decoder that was popped, or this DecoderStack

decode

public void decode(java.lang.Object encoded)
            throws DecoderException
Decodes an encoded object by calling decode on the decoder at the bottom of the stack. Callbacks are chained to feed the output of one decoder into the input decode method of another. If the stack is empty then the arguement is delivered without change to this StatefulDecoder's callback.

Parameters:
encoded - an object representing a peice of encoded data
Throws:
DecoderException
See Also:
decode(java.lang.Object)

isEmpty

public boolean isEmpty()
Gets whether or not this stack is empty.

Returns:
true if the stack is empty, false otherwise

clear

public void clear()
Clears the stack popping all decoders setting their callbacks to null.



Copyright © 2004-2007 null. All Rights Reserved.