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

java.lang.Object
  extended byorg.apache.asn1.ber.digester.AbstractRule
      extended byorg.apache.asn1.ber.digester.rules.PrimitiveOctetStringRule
All Implemented Interfaces:
Rule
Direct Known Subclasses:
Octets2StringRule

public class PrimitiveOctetStringRule
extends AbstractRule

A rule that collects the value bytes of an ASN.1 OCTET STRING and pushes the buffer of bytes onto the digester's Object stack as a ByteBuffer.

This rule can only handle primitive octet strings. Constructed OCTET STRING values are simply ignored by this rule rather than throwing exceptions.

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

Field Summary
private  ByteAccumulator accumulator
          used to accumulate value bytes
private  boolean isConstructed
          used to determine if our type is constructed or primitive
private  TagEnum tag
          the tag to be accepted which defaults to an UNIVERSAL OCTET_STRING
 
Fields inherited from class org.apache.asn1.ber.digester.AbstractRule
 
Constructor Summary
PrimitiveOctetStringRule()
          Creates a rule using defaults where only the OCTET_STRING tag id is accepted.
PrimitiveOctetStringRule(TagEnum tag)
          Creates a rule where only a specific tag is accepted.
 
Method Summary
 void finish()
          Called when the tlv has been completely consumed.
protected  ByteAccumulator getAccumulator()
          Gets the ByteAccumulator used by this octet string gathering rule.
protected  TagEnum getTag()
          Gets the tag associated with this rule.
protected  boolean isConstructed()
          Gets whether or not the current TLV for this octet string is constructed.
 void length(int length)
          Called when the length of a TLV is encountered.
protected  void setConstructed(boolean isConstructed)
          Gets whether or not the current TLV for this octet string is constructed.
 void tag(int id, boolean isPrimitive, TypeClass typeClass)
          Rejects tag id's that are not equal to this Rules's id.
 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

accumulator

private final ByteAccumulator accumulator
used to accumulate value bytes


isConstructed

private boolean isConstructed
used to determine if our type is constructed or primitive


tag

private final TagEnum tag
the tag to be accepted which defaults to an UNIVERSAL OCTET_STRING

Constructor Detail

PrimitiveOctetStringRule

public PrimitiveOctetStringRule()
Creates a rule using defaults where only the OCTET_STRING tag id is accepted.


PrimitiveOctetStringRule

public PrimitiveOctetStringRule(TagEnum tag)
Creates a rule where only a specific tag is accepted. Sometimes OCTET_STRING fields are tagged with application specific tags. In this case we match for a different tag.

Parameters:
tag - the tag to accept
Method Detail

tag

public void tag(int id,
                boolean isPrimitive,
                TypeClass typeClass)
Rejects tag id's that are not equal to this Rules's id.

Specified by:
tag in interface Rule
Overrides:
tag in class AbstractRule
See Also:
Rule.tag(int, boolean, org.apache.asn1.ber.TypeClass)

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

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

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

getAccumulator

protected ByteAccumulator getAccumulator()
Gets the ByteAccumulator used by this octet string gathering rule.

Returns:
the accumulator used to store octets

isConstructed

protected boolean isConstructed()
Gets whether or not the current TLV for this octet string is constructed.

Returns:
true if it's constructed, false otherwise

setConstructed

protected void setConstructed(boolean isConstructed)
Gets whether or not the current TLV for this octet string is constructed.

Parameters:
isConstructed - true to set to constructed, false otherwise

getTag

protected TagEnum getTag()
Gets the tag associated with this rule.

Returns:
the tag associated with this rule


Copyright © 2004-2006 . All Rights Reserved.