All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.openhft.chronicle.bytes.BytesPrepender Maven / Gradle / Ivy

/*
 * Copyright 2016 higherfrequencytrading.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.openhft.chronicle.bytes;

import net.openhft.chronicle.core.io.IORuntimeException;
import org.jetbrains.annotations.NotNull;

import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;

/**
 * Created by peter on 12/09/15.
 */
public interface BytesPrepender> {

    /**
     * Clear a buffer, with a given padding to allow for prepending later. clearAndPad(0) is the same as clear()
     *
     * @param length to pad
     * @return this
     * @throws BufferOverflowException if the length > capacity() - start()
     */
    B clearAndPad(long length) throws BufferOverflowException;

    /**
     * Prepends a long in decimal, this method moves the readPosition() backwards.
     * 

Note: it moves the readPosition not the writePosition / readLimit

* * @param value to prepend as text. * @return this * @throws BufferUnderflowException if the capacity of the underlying buffer was exceeded * @throws IORuntimeException if an error occurred while attempting to resize the underlying buffer */ @NotNull default B prepend(long value) throws BufferOverflowException, IORuntimeException { BytesInternal.prepend(this, value); return (B) this; } /** * Write backward in binary a byte *

Note: it moves the readPosition not the writePosition / readLimit

* * @param bytes to prepend to. */ B prewrite(byte[] bytes); /** * Write backward in binary a byte *

Note: it moves the readPosition not the writePosition / readLimit

* * @param bytes to prepend to. */ B prewrite(BytesStore bytes); /** * Write backward in binary a byte *

Note: it moves the readPosition not the writePosition / readLimit

* * @param b byte to prepend to. */ B prewriteByte(byte b); /** * Write backward in binary a 2 byte int *

Note: it moves the readPosition not the writePosition / readLimit

* * @param i short to prepend to. */ B prewriteShort(short i); /** * Write backward in binary a 4 byte int *

Note: it moves the readPosition not the writePosition / readLimit

* * @param i integer to prepend to. */ B prewriteInt(int i); /** * Write backward in binary an 8 byte long *

Note: it moves the readPosition not the writePosition / readLimit

* * @param l long to prepend to. */ B prewriteLong(long l); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy