@Override public byte[] encode() { return encode(derItem); }
/** * Creates a new context type. * * @param index of this item in the context * @param item to encode */ public ContextType(final int index, final boolean item) { this(index, BooleanType.toBytes(item)); }
@Override public void handle(final DERParser parser, final ByteBuffer encoded) { getObject().setRefreshDeletes(BooleanType.decode(encoded)); } }
@Override public byte[] encode() { int types = 0; for (PersistentSearchChangeType type : getChangeTypes()) { types |= type.value(); } final ConstructedDEREncoder se = new ConstructedDEREncoder( UniversalDERTag.SEQ, new IntegerType(types), new BooleanType(getChangesOnly()), new BooleanType(getReturnEcs())); return se.encode(); } }
/** * Converts bytes in the buffer to a boolean by reading from the current position to the limit. * * @param 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. * * @return decoded bytes as a boolean. */ public static boolean decode(final ByteBuffer encoded) { final byte[] bytes = readBuffer(encoded); if (bytes.length > 1) { throw new IllegalArgumentException("Boolean cannot be longer than 1 byte"); } if (bytes[0] == TRUE_BYTE) { return true; } else if (bytes[0] == FALSE_BYTE) { return false; } else { throw new IllegalArgumentException("Invalid boolean value: " + (int) bytes[0]); } }
@Override public void handle(final DERParser parser, final ByteBuffer encoded) { getObject().setRefreshDone(BooleanType.decode(encoded)); } }
@Override public byte[] encode() { int types = 0; for (PersistentSearchChangeType type : getChangeTypes()) { types |= type.value(); } final ConstructedDEREncoder se = new ConstructedDEREncoder( UniversalDERTag.SEQ, new IntegerType(types), new BooleanType(getChangesOnly()), new BooleanType(getReturnEcs())); return se.encode(); } }
/** * Converts bytes in the buffer to a boolean by reading from the current position to the limit. * * @param 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. * * @return decoded bytes as a boolean. */ public static boolean decode(final ByteBuffer encoded) { final byte[] bytes = readBuffer(encoded); if (bytes.length > 1) { throw new IllegalArgumentException("Boolean cannot be longer than 1 byte"); } if (bytes[0] == TRUE_BYTE) { return true; } else if (bytes[0] == FALSE_BYTE) { return false; } else { throw new IllegalArgumentException("Invalid boolean value: " + (int) bytes[0]); } }
@Override public void handle(final DERParser parser, final ByteBuffer encoded) { getObject().setRefreshDeletes(BooleanType.decode(encoded)); } }
/** * Creates a new context type. * * @param index of this item in the context * @param item to encode */ public ContextType(final int index, final boolean item) { this(index, BooleanType.toBytes(item)); }
@Override public byte[] encode() { int types = 0; for (PersistentSearchChangeType type : getChangeTypes()) { types |= type.value(); } final ConstructedDEREncoder se = new ConstructedDEREncoder( UniversalDERTag.SEQ, new IntegerType(types), new BooleanType(getChangesOnly()), new BooleanType(getReturnEcs())); return se.encode(); } }
@Override public byte[] encode() { return encode(derItem); }
/** * Converts bytes in the buffer to a boolean by reading from the current position to the limit. * * @param 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. * * @return decoded bytes as a boolean. */ public static boolean decode(final ByteBuffer encoded) { final byte[] bytes = readBuffer(encoded); if (bytes.length > 1) { throw new IllegalArgumentException("Boolean cannot be longer than 1 byte"); } if (bytes[0] == TRUE_BYTE) { return true; } else if (bytes[0] == FALSE_BYTE) { return false; } else { throw new IllegalArgumentException("Invalid boolean value: " + (int) bytes[0]); } }
@Override public void handle(final DERParser parser, final ByteBuffer encoded) { getObject().setRefreshDone(BooleanType.decode(encoded)); } }
/** * Creates a new boolean type. * * @param item to DER encode */ public BooleanType(final boolean item) { super(UniversalDERTag.BOOL); derItem = toBytes(item); }
@Override public byte[] encode() { final ConstructedDEREncoder se; if (getCookie() != null) { se = new ConstructedDEREncoder( UniversalDERTag.SEQ, new IntegerType(getRequestMode().value()), new OctetStringType(getCookie()), new BooleanType(getReloadHint())); } else { se = new ConstructedDEREncoder( UniversalDERTag.SEQ, new IntegerType(getRequestMode().value()), new BooleanType(getReloadHint())); } return se.encode(); } }
@Override public byte[] encode() { return encode(derItem); }
@Override public void handle(final DERParser parser, final ByteBuffer encoded) { getObject().setRefreshDone(BooleanType.decode(encoded)); } }
/** * Creates a new boolean type. * * @param item to DER encode */ public BooleanType(final boolean item) { super(UniversalDERTag.BOOL); derItem = toBytes(item); }
@Override public byte[] encode() { final ConstructedDEREncoder se; if (getCookie() != null) { se = new ConstructedDEREncoder( UniversalDERTag.SEQ, new IntegerType(getRequestMode().value()), new OctetStringType(getCookie()), new BooleanType(getReloadHint())); } else { se = new ConstructedDEREncoder( UniversalDERTag.SEQ, new IntegerType(getRequestMode().value()), new BooleanType(getReloadHint())); } return se.encode(); } }