Class AppendRecord

  • All Implemented Interfaces:
    Record

    public class AppendRecord
    extends AbstractRecord
    Default temporary record used for appending to some journal.
    • Constructor Detail

      • AppendRecord

        public AppendRecord​(AbstractJournal journal,
                            String producerId)
        Create a new instance of this class.
        Parameters:
        journal - journal where record is being appended
        producerId - producer identifier
    • Method Detail

      • getJournalId

        public String getJournalId()
        Return this record's journal identifier.
        Returns:
        journal identifier
      • getProducerId

        public String getProducerId()
        Return this record's producer identifier.
        Returns:
        producer identifier
      • getRevision

        public long getRevision()
        Returns the revision this record represents.
        Returns:
        revision
      • setRevision

        public void setRevision​(long revision)
        Set the revision this record represents.
        Parameters:
        revision - revision
      • writeByte

        public void writeByte​(int n)
                       throws JournalException
        Write a byte to the underlying stream.
        Parameters:
        n - byte
        Throws:
        JournalException - if an error occurs
      • writeChar

        public void writeChar​(char c)
                       throws JournalException
        Write a character to the underlying stream.
        Parameters:
        c - character
        Throws:
        JournalException - if an error occurs
      • writeBoolean

        public void writeBoolean​(boolean b)
                          throws JournalException
        Write a boolean from the underlying stream.
        Parameters:
        b - boolean
        Throws:
        JournalException - if an error occurs
      • writeInt

        public void writeInt​(int n)
                      throws JournalException
        Write an integer to the underlying stream.
        Parameters:
        n - integer
        Throws:
        JournalException - if an error occurs
      • writeLong

        public void writeLong​(long n)
                       throws JournalException
        Write a long to the underlying stream.
        Parameters:
        n - long
        Throws:
        JournalException - if an error occurs
      • writeString

        public void writeString​(String s)
                         throws JournalException
        Write a string to the underlying stream.
        Parameters:
        s - string, may be null
        Throws:
        JournalException - if an error occurs
      • write

        public void write​(byte[] b)
                   throws JournalException
        Write an array of bytes to the underlying stream.
        Parameters:
        b - byte array
        Throws:
        JournalException - if an error occurs
      • update

        public long update()
                    throws JournalException
        Update the changes made to an appended record. This will also update this record's revision.
        Returns:
        The update size in bytes.
        Throws:
        JournalException - if this record has not been appended, or if another error occurs
      • cancelUpdate

        public void cancelUpdate()
        Cancel the changes made to an appended record.
      • readChar

        public char readChar()
                      throws JournalException
        Description copied from interface: Record
        Read a character from the underlying stream.
        Returns:
        character
        Throws:
        JournalException - if an error occurs
      • readBoolean

        public boolean readBoolean()
                            throws JournalException
        Description copied from interface: Record
        Read a boolean from the underlying stream.
        Returns:
        boolean
        Throws:
        JournalException - if an error occurs
      • readInt

        public int readInt()
                    throws JournalException
        Description copied from interface: Record
        Read an integer from the underlying stream.
        Returns:
        integer
        Throws:
        JournalException - if an error occurs
      • readLong

        public long readLong()
                      throws JournalException
        Description copied from interface: Record
        Read a long from the underlying stream.
        Returns:
        long value.
        Throws:
        JournalException - if an error occurs
      • readString

        public String readString()
                          throws JournalException
        Description copied from interface: Record
        Read a string from the underlying stream.
        Returns:
        string or null
        Throws:
        JournalException - if an error occurs
      • readFully

        public void readFully​(byte[] b)
                       throws JournalException
        Description copied from interface: Record
        Fully read an array of bytes from the underlying stream.
        Parameters:
        b - byte array
        Throws:
        JournalException - if an error occurs