Package org.ldaptive.asn1
Class BooleanType
java.lang.Object
org.ldaptive.asn1.AbstractDERType
org.ldaptive.asn1.BooleanType
- All Implemented Interfaces:
DEREncoder
Converts booleans to and from their DER encoded format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
Boolean to encode.private static final byte
Boolean false byte representation.private static final byte
Boolean true byte representation. -
Constructor Summary
ConstructorsConstructorDescriptionBooleanType
(boolean item) Creates a new boolean type.BooleanType
(DERTag tag, boolean item) Creates a new boolean type. -
Method Summary
Methods inherited from class org.ldaptive.asn1.AbstractDERType
encode
-
Field Details
-
TRUE_BYTE
private static final byte TRUE_BYTEBoolean true byte representation.- See Also:
-
FALSE_BYTE
private static final byte FALSE_BYTEBoolean false byte representation.- See Also:
-
derItem
private final byte[] derItemBoolean to encode.
-
-
Constructor Details
-
BooleanType
public BooleanType(boolean item) Creates a new boolean type.- Parameters:
item
- to DER encode
-
BooleanType
Creates a new boolean type.- Parameters:
tag
- der tag associated with this typeitem
- to DER encode- Throws:
IllegalArgumentException
- if the der tag is constructed
-
-
Method Details
-
encode
public byte[] encode()Description copied from interface:DEREncoder
Encode this object into it's DER type.- Specified by:
encode
in interfaceDEREncoder
- Returns:
- DER encoded object
-
decode
Converts bytes in the buffer to a boolean by reading from the current position to the limit.- Parameters:
encoded
- buffer containing DER-encoded data where the buffer is positioned at the start of boolean bytes and the limit is set beyond the last byte of integer data.- Returns:
- decoded bytes as a boolean.
-
toBytes
public static byte[] toBytes(boolean b) Converts the supplied boolean to a byte array.- Parameters:
b
- to convert- Returns:
- byte array
-