Class ConnectionEntryWriter

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable, EntryWriter

    public final class ConnectionEntryWriter
    extends Object
    implements EntryWriter
    A ConnectionEntryWriter is a bridge from Connections to EntryWriters. A connection entry writer writes entries by sending Add requests to an underlying connection.

    All Add requests are performed synchronously, blocking until an Add result is received. If an Add result indicates that an Add request has failed for some reason then the error result is propagated to the caller using an LdapException.

    Note: comments are not supported by connection change record writers. Attempts to write comments will be ignored.

    • Constructor Detail

      • ConnectionEntryWriter

        public ConnectionEntryWriter​(Connection connection)
        Creates a new connection entry writer whose destination is the provided connection.
        Parameters:
        connection - The connection to use.
        Throws:
        NullPointerException - If connection was null.
    • Method Detail

      • close

        public void close()
        Closes this connection entry writer, including the underlying connection. Closing a previously closed entry writer has no effect.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface EntryWriter
      • flush

        public void flush()
        Connection entry writers do not require flushing, so this method has no effect.
        Specified by:
        flush in interface EntryWriter
        Specified by:
        flush in interface Flushable
      • writeComment

        public ConnectionEntryWriter writeComment​(CharSequence comment)
        Connection entry writers do not support comments, so the provided comment will be ignored.
        Specified by:
        writeComment in interface EntryWriter
        Parameters:
        comment - The CharSequence to be written as a comment.
        Returns:
        A reference to this connection entry writer.
        Throws:
        NullPointerException - If comment was null.
      • writeEntry

        public ConnectionEntryWriter writeEntry​(Entry entry)
                                         throws LdapException
        Writes an entry to the underlying connection using an Add request, blocking until the request completes.
        Specified by:
        writeEntry in interface EntryWriter
        Parameters:
        entry - The Entry to be written.
        Returns:
        A reference to this connection entry writer.
        Throws:
        LdapException - If the result code indicates that the request failed for some reason.
        NullPointerException - If entry was null.