ch.panter.li.bi.asn.ber
Class AsnBerDecodingContextImpl

java.lang.Object
  extended by ch.panter.li.bi.asn.ber.AsnBerDecodingContextImpl
All Implemented Interfaces:
AsnDecodingContextInfo, AsnBerDecodingContext, AsnBerDecodingContextInfo

public final class AsnBerDecodingContextImpl
extends Object
implements AsnBerDecodingContext


Constructor Summary
AsnBerDecodingContextImpl(AsnSyntax syntax, AsnBerInputStream input)
           
 
Method Summary
 void addDecodingListener(AsnBerDecodingListener listener)
          Adds a listener to be notified of events when parsing with this context.
 String getContextDescriptor()
          Provides convenient (and efficient) access to the current tag context in form of a string.
 long getCurrentDecodingPosition()
           
 ReadOnlyCollection<AsnBerDecodingListener> getDecodingListeners()
          Access to the registered listeners.
 AsnBerInputStream getInput()
           
 AsnBerNodeInfo getLastPDUInfo()
           
 ReadOnlyStack<AsnBerNode> getOpenTagNodes()
           
 ReadOnlyStack<AsnTag> getOpenTags()
           
 AsnSyntax getSyntax()
           
 boolean isDecodeToFloatIfPossible()
           
 boolean isFailFast()
           
 boolean isListeningToEndOfContentTags()
           
 boolean isPDU()
          Determines whether the current context is decoding a PDU.
 boolean isSkipRestOfPDUInCaseOfFailure()
           
 boolean isTruncateChildLength()
           
 void pop()
          Pops the top of the stack
 void push(AsnBerNode node)
          Pushes the given node onto the stack of open tags.
 void removeDecodingListener(AsnBerDecodingListener listener)
          Removes a listener from this context.
 void setDecodeToFloatIfPossible(boolean decodeToFloatIfPossible)
          Determines whether the decoder should attempt to store REAL values in a java float if precision allows it.
 void setFailFast(boolean failFast)
          Determines whether to immediately throw an exception when inconsistent length information is detected (child tags which exceed their parents length).
 void setListeningToEndOfContentTags(boolean listenToEndOfContentTags)
          Determines whether the listeners should be notified when end-of-content markers are encountered during decoding of indefinite length tags.
 void setSkipRestOfPDUInCaseOfFailure(boolean skipRestOfPDUInCaseOfFailure)
          Determines whether it should be attempted to 'recover' from an erroneous PDU in the stream by skipping the rest of its contents, thereby 'seeking' to the beginning of the next pdu.
 void setTruncateChildLength(boolean truncateChildLength)
          Determines whether to truncate the length of children if they exceed the length of their parent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsnBerDecodingContextImpl

public AsnBerDecodingContextImpl(AsnSyntax syntax,
                                 AsnBerInputStream input)
Method Detail

getSyntax

public final AsnSyntax getSyntax()
Specified by:
getSyntax in interface AsnDecodingContextInfo

isListeningToEndOfContentTags

public final boolean isListeningToEndOfContentTags()
Specified by:
isListeningToEndOfContentTags in interface AsnBerDecodingContextInfo

setListeningToEndOfContentTags

public final void setListeningToEndOfContentTags(boolean listenToEndOfContentTags)
Description copied from interface: AsnBerDecodingContext
Determines whether the listeners should be notified when end-of-content markers are encountered during decoding of indefinite length tags. default is false.

Specified by:
setListeningToEndOfContentTags in interface AsnBerDecodingContext
Parameters:
listenToEndOfContentTags - the new mode

isFailFast

public final boolean isFailFast()
Specified by:
isFailFast in interface AsnBerDecodingContextInfo

setFailFast

public final void setFailFast(boolean failFast)
Description copied from interface: AsnBerDecodingContext
Determines whether to immediately throw an exception when inconsistent length information is detected (child tags which exceed their parents length). default is true. Turning this off is not dangerous but changes the behavior in such erroneous cases, as as many children are read as possible before exceeding the parent length.

Specified by:
setFailFast in interface AsnBerDecodingContext
Parameters:
failFast - the new mode

isSkipRestOfPDUInCaseOfFailure

public final boolean isSkipRestOfPDUInCaseOfFailure()
Specified by:
isSkipRestOfPDUInCaseOfFailure in interface AsnBerDecodingContextInfo

setSkipRestOfPDUInCaseOfFailure

public final void setSkipRestOfPDUInCaseOfFailure(boolean skipRestOfPDUInCaseOfFailure)
Description copied from interface: AsnBerDecodingContext
Determines whether it should be attempted to 'recover' from an erroneous PDU in the stream by skipping the rest of its contents, thereby 'seeking' to the beginning of the next pdu.

Specified by:
setSkipRestOfPDUInCaseOfFailure in interface AsnBerDecodingContext
Parameters:
skipRestOfPDUInCaseOfFailure - the new mode

isTruncateChildLength

public final boolean isTruncateChildLength()
Specified by:
isTruncateChildLength in interface AsnBerDecodingContextInfo

setTruncateChildLength

public final void setTruncateChildLength(boolean truncateChildLength)
Description copied from interface: AsnBerDecodingContext
Determines whether to truncate the length of children if they exceed the length of their parent. Only considered if fail-fast is false. default is true. Turning this off might be dangerous as indefinite length content might come in ...

Specified by:
setTruncateChildLength in interface AsnBerDecodingContext
Parameters:
truncateChildLength - the new mode

isDecodeToFloatIfPossible

public final boolean isDecodeToFloatIfPossible()
Specified by:
isDecodeToFloatIfPossible in interface AsnBerDecodingContextInfo

setDecodeToFloatIfPossible

public final void setDecodeToFloatIfPossible(boolean decodeToFloatIfPossible)
Description copied from interface: AsnBerDecodingContext
Determines whether the decoder should attempt to store REAL values in a java float if precision allows it.

Specified by:
setDecodeToFloatIfPossible in interface AsnBerDecodingContext
Parameters:
decodeToFloatIfPossible - the new mode

getCurrentDecodingPosition

public final long getCurrentDecodingPosition()
Specified by:
getCurrentDecodingPosition in interface AsnBerDecodingContextInfo

getInput

public final AsnBerInputStream getInput()
Specified by:
getInput in interface AsnBerDecodingContext
Returns:
the stream to read from. never null but possibly closed.

isPDU

public final boolean isPDU()
Description copied from interface: AsnDecodingContextInfo
Determines whether the current context is decoding a PDU.

Specified by:
isPDU in interface AsnDecodingContextInfo
Returns:
true if no tags are open, false otherwise

getLastPDUInfo

public final AsnBerNodeInfo getLastPDUInfo()
Specified by:
getLastPDUInfo in interface AsnBerDecodingContextInfo

getOpenTags

public final ReadOnlyStack<AsnTag> getOpenTags()
Specified by:
getOpenTags in interface AsnDecodingContextInfo
Returns:
the stack of currently 'open' tags. e.g. the tags whose content is currently in the process of being read. this provides the necessary context to correctly interpret types with custom tags. never null but possibly empty (for PDUs).

getOpenTagNodes

public final ReadOnlyStack<AsnBerNode> getOpenTagNodes()
Specified by:
getOpenTagNodes in interface AsnBerDecodingContextInfo
Returns:
the stack of currently 'open' tags. e.g. the tags whose content is currently in the process of being read. this provides the necessary context to correctly interpret types with custom tags. never null but possibly empty (for PDUs).

getContextDescriptor

public final String getContextDescriptor()
Description copied from interface: AsnDecodingContextInfo
Provides convenient (and efficient) access to the current tag context in form of a string.

Specified by:
getContextDescriptor in interface AsnDecodingContextInfo
Returns:
a string with the tag numbers of all open tags concatenated, separated by a dot ('.') character. e.g. "0.4.0.2.2.5.1.5" for the li-psDomainId.

push

public final void push(AsnBerNode node)
Description copied from interface: AsnBerDecodingContext
Pushes the given node onto the stack of open tags.

Specified by:
push in interface AsnBerDecodingContext
Parameters:
node - the node to push onto the stack

pop

public final void pop()
Description copied from interface: AsnBerDecodingContext
Pops the top of the stack

Specified by:
pop in interface AsnBerDecodingContext

addDecodingListener

public final void addDecodingListener(AsnBerDecodingListener listener)
Description copied from interface: AsnBerDecodingContext
Adds a listener to be notified of events when parsing with this context.

Specified by:
addDecodingListener in interface AsnBerDecodingContext
Parameters:
listener - the listener to add

getDecodingListeners

public final ReadOnlyCollection<AsnBerDecodingListener> getDecodingListeners()
Description copied from interface: AsnBerDecodingContext
Access to the registered listeners.

Specified by:
getDecodingListeners in interface AsnBerDecodingContext
Returns:
the (possibly empty) list of listeners.

removeDecodingListener

public final void removeDecodingListener(AsnBerDecodingListener listener)
Description copied from interface: AsnBerDecodingContext
Removes a listener from this context.

Specified by:
removeDecodingListener in interface AsnBerDecodingContext
Parameters:
listener - the listener to remove


Copyright 2007-2007 SourceForge. All Rights Reserved.