org.apache.asn1.ber.digester.rules
Class PrimitiveBooleanRule

java.lang.Object
  extended by org.apache.asn1.ber.digester.AbstractRule
      extended by org.apache.asn1.ber.digester.rules.PrimitiveBooleanRule
All Implemented Interfaces:
Rule

public class PrimitiveBooleanRule
extends AbstractRule

A rule to Decode a BER encoded ASN.1 INTEGER into a Java primitive int.

The bytes to form the integer are extracted from the BER value which may arrive in multiple chunks. The individual bytes are temporarily stored within a 4 byte array while incrementing a counter to track the capture. Once gathered the bytes are decoded into a int in the finish

As a side effect once the decode is complete, the primitive value is pushed onto the primitive int stack to be utilized by other rules later. If there is a loss of precision where the ASN.1 INTEGER is larger or smaller than the maximum or minimum value of a Java primitive integer an exception is thrown.

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

Field Summary
private  boolean octetSet
          boolean flag to determine if we have read the single octet
private  TagEnum tag
          the tag this rule accepts
private  byte value
          the octet for the Java primitive boolean
 
Constructor Summary
PrimitiveBooleanRule()
          Creates a default primitive boolean decoding rule that only accepts tags of UniversalTag.BOOLEAN.
PrimitiveBooleanRule(TagEnum tag)
          Creates a default primitive integer decoding rule that only accepts tags of UniversalTag.INTEGER.
 
Method Summary
 void finish()
          Called when the tlv has been completely consumed.
 void length(int length)
          Called when the length of a TLV is encountered.
 void tag(int id, boolean isPrimitive, TypeClass typeClass)
          Called when the tag of the matched TLV is encountered.
 void value(java.nio.ByteBuffer buf)
          Called when a peice of the value is available.
 
Methods inherited from class org.apache.asn1.ber.digester.AbstractRule
getDigester, setDigester
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

private byte value
the octet for the Java primitive boolean


octetSet

private boolean octetSet
boolean flag to determine if we have read the single octet


tag

private final TagEnum tag
the tag this rule accepts

Constructor Detail

PrimitiveBooleanRule

public PrimitiveBooleanRule()
Creates a default primitive boolean decoding rule that only accepts tags of UniversalTag.BOOLEAN.


PrimitiveBooleanRule

public PrimitiveBooleanRule(TagEnum tag)
Creates a default primitive integer decoding rule that only accepts tags of UniversalTag.INTEGER.

Method Detail

tag

public void tag(int id,
                boolean isPrimitive,
                TypeClass typeClass)
Description copied from interface: Rule
Called when the tag of the matched TLV is encountered.

Specified by:
tag in interface Rule
Overrides:
tag in class AbstractRule
Parameters:
id - the tag's id
isPrimitive - whether tlv is primitive or constructed
typeClass - the tag's type class

length

public void length(int length)
Description copied from interface: Rule
Called when the length of a TLV is encountered.

Specified by:
length in interface Rule
Overrides:
length in class AbstractRule
Parameters:
length - the length in bytes of the value

value

public void value(java.nio.ByteBuffer buf)
Description copied from interface: Rule
Called when a peice of the value is available.

Specified by:
value in interface Rule
Overrides:
value in class AbstractRule
Parameters:
buf - a portion of the value

finish

public void finish()
Description copied from interface: Rule
Called when the tlv has been completely consumed.

Specified by:
finish in interface Rule
Overrides:
finish in class AbstractRule


Copyright © 2004-2009 . All Rights Reserved.