Package org.ldaptive.asn1
Class BooleanType
- java.lang.Object
-
- org.ldaptive.asn1.AbstractDERType
-
- org.ldaptive.asn1.BooleanType
-
- All Implemented Interfaces:
DEREncoder
public class BooleanType extends AbstractDERType implements DEREncoder
Converts booleans to and from their DER encoded format.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
derItem
Boolean to encode.private static byte
FALSE_BYTE
Boolean false byte representation.private static byte
TRUE_BYTE
Boolean true byte representation.
-
Constructor Summary
Constructors Constructor Description BooleanType(boolean item)
Creates a new boolean type.BooleanType(DERTag tag, boolean item)
Creates a new boolean type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
decode(DERBuffer encoded)
Converts bytes in the buffer to a boolean by reading from the current position to the limit.byte[]
encode()
Encode this object into its DER type.static byte[]
toBytes(boolean b)
Converts the supplied boolean to a byte array.-
Methods inherited from class org.ldaptive.asn1.AbstractDERType
encode
-
-
-
-
Field Detail
-
TRUE_BYTE
private static final byte TRUE_BYTE
Boolean true byte representation.- See Also:
- Constant Field Values
-
FALSE_BYTE
private static final byte FALSE_BYTE
Boolean false byte representation.- See Also:
- Constant Field Values
-
derItem
private final byte[] derItem
Boolean to encode.
-
-
Constructor Detail
-
BooleanType
public BooleanType(boolean item)
Creates a new boolean type.- Parameters:
item
- to DER encode
-
BooleanType
public BooleanType(DERTag tag, boolean item)
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 Detail
-
encode
public byte[] encode()
Description copied from interface:DEREncoder
Encode this object into its DER type.- Specified by:
encode
in interfaceDEREncoder
- Returns:
- DER encoded object
-
decode
public static boolean decode(DERBuffer encoded)
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
-
-