|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--codec.asn1.RunLengthEncoder
This encoder makes one pass through the given ASN.1 type and computes the
length of the type encoding according to the DER (ITU-T Recommendation
X.690). The result is an array of integers with the length of the individual
non-optional and non-implicit type encodings in the reverse order of the
order in which the given type is traversed during actual encoding. This array
is used by the DEREncoder when encoding a type.
| Field Summary | |
static int |
INCREMENT
The number of slots by which the internal buffer is incremented if its capacity is eexceeded. |
| Constructor Summary | |
RunLengthEncoder()
Creates an encoder. |
|
| Method Summary | |
protected int |
accumulate(int pos)
Accumulates all values on the accumulator stack from the given position to the top of the stack and returns the result. |
int |
getHeaderLength(int tag,
int len)
This method computes the number of octets needed to encode the identifier and length octets of the ASN.1 type with the given tag
and contents length. |
int[] |
getLengthFields()
This method brings in the harvest of the encoding procedure. |
protected void |
push(ASN1Type t,
int n)
Pushes another length integer onto the internal stacks. |
protected void |
reset()
Clears the length array and prepares this encoder for a new run. |
protected int |
significantBits(int n)
Counts the number of significant bits in the given integer. |
protected int |
sp()
Returns the accumulator stack pointer. |
void |
writeBitString(ASN1BitString t)
|
void |
writeBoolean(ASN1Boolean t)
|
void |
writeCollection(ASN1Collection t)
|
void |
writeCollectionOf(ASN1Collection t)
|
void |
writeInteger(ASN1Integer t)
|
void |
writeNull(ASN1Null t)
|
void |
writeObjectIdentifier(ASN1ObjectIdentifier t)
|
void |
writeOctetString(ASN1OctetString t)
|
void |
writeReal(ASN1Type t)
|
void |
writeString(ASN1String t)
|
void |
writeTaggedType(ASN1TaggedType t)
|
void |
writeTime(ASN1Time t)
|
void |
writeType(ASN1Type o)
Encodes the length array of the given type. |
void |
writeTypeIdentifier(ASN1Type t)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int INCREMENT
| Constructor Detail |
public RunLengthEncoder()
| Method Detail |
public int[] getLengthFields()
If this method is called before a type has been encoded then an array of zero length is returned. Only non-optional types are counted thus the zero length array might be returned also when all encoded types were declared optional.
public void writeType(ASN1Type o)
throws ASN1Exception
writeType in interface Encoder
public int getHeaderLength(int tag,
int len)
throws ASN1Exception
ASN.1 type with the given tag
and contents length. The length must not be negative else an exception is
thrown. Since this encoder is meant to work in conjunction with a
DEREncoder no indefinite length is supported.tag - The ASN.1 tag.len - The number of contents octets of the ASN.1 type with the
given tag and length.ASN1Exception - if the given length is negative.protected int significantBits(int n)
n - The integer.
public void writeBoolean(ASN1Boolean t)
throws ASN1Exception
writeBoolean in interface Encoder
public void writeInteger(ASN1Integer t)
throws ASN1Exception
writeInteger in interface Encoder
public void writeBitString(ASN1BitString t)
throws ASN1Exception
writeBitString in interface Encoder
public void writeOctetString(ASN1OctetString t)
throws ASN1Exception
writeOctetString in interface Encoder
public void writeNull(ASN1Null t)
throws ASN1Exception
writeNull in interface Encoder
public void writeObjectIdentifier(ASN1ObjectIdentifier t)
throws ASN1Exception
writeObjectIdentifier in interface Encoderpublic void writeReal(ASN1Type t)
writeReal in interface Encoder
public void writeString(ASN1String t)
throws ASN1Exception
writeString in interface Encoder
public void writeCollection(ASN1Collection t)
throws ASN1Exception
writeCollection in interface Encoder
public void writeCollectionOf(ASN1Collection t)
throws ASN1Exception
public void writeTime(ASN1Time t)
throws ASN1Exception
writeTime in interface Encoder
public void writeTaggedType(ASN1TaggedType t)
throws ASN1Exception
writeTaggedType in interface Encoderpublic void writeTypeIdentifier(ASN1Type t)
writeTypeIdentifier in interface Encoderprotected void reset()
protected void push(ASN1Type t,
int n)
throws ASN1Exception
INCREMENT integers and never shrink in capacity.t - The ASN.1 type.n - The integer.protected int sp()
protected int accumulate(int pos)
pos - The position to start from.IllegalStateException - if the given position is atop the top of the stack.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||