I'm open to ideas for a better name, but in this case we are draining data 
_from_ the specified ByteBuffer into the destination (which can be anything). 

Sent from my iPhone

> On 2016/02/21, at 15:24, Gary Gregory <[email protected]> wrote:
> 
> Should we consider renaming drain(ByteBuffer) to drainTo(ByteBuffer) as there 
> is precedent in the JRE for this naming. See 
> java.util.concurrent.BlockingQueue.drainTo(Collection<? super E>)
> 
> Gary
> ---------- Forwarded message ----------
> From: <[email protected]>
> Date: Sat, Feb 20, 2016 at 7:36 PM
> Subject: [2/5] logging-log4j2 git commit: LOG4J2-1274 add 
> ByteBufferDestination interface
> To: [email protected]
> 
> 
> LOG4J2-1274 add ByteBufferDestination interface
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8ad09137
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8ad09137
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8ad09137
> 
> Branch: refs/heads/master
> Commit: 8ad0913756eeb9c285161c5d8bfaab4f638f4d1f
> Parents: 5a19927
> Author: rpopma <[email protected]>
> Authored: Sun Feb 21 12:17:39 2016 +0900
> Committer: rpopma <[email protected]>
> Committed: Sun Feb 21 12:17:39 2016 +0900
> 
> ----------------------------------------------------------------------
>  .../core/layout/ByteBufferDestination.java      | 45 ++++++++++++++++++++
>  1 file changed, 45 insertions(+)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8ad09137/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/ByteBufferDestination.java
> ----------------------------------------------------------------------
> diff --git 
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/ByteBufferDestination.java
>  
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/ByteBufferDestination.java
> new file mode 100644
> index 0000000..61ce3ba
> --- /dev/null
> +++ 
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/ByteBufferDestination.java
> @@ -0,0 +1,45 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements. See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You 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 org.apache.logging.log4j.core.layout;
> +
> +import java.nio.ByteBuffer;
> +
> +/**
> + * ByteBufferDestination addresses the problem a producer has when the 
> destination ByteBuffer is not large enough to
> + * fit all the data. This interface allows a producer to write arbitrary 
> amounts of data to a destination.
> + *
> + * @since 2.6
> + */
> +public interface ByteBufferDestination {
> +    /**
> +     * Returns the buffer to write to.
> +     *
> +     * @return the buffer to write to
> +     */
> +    ByteBuffer getByteBuffer();
> +
> +    /**
> +     * Consumes the buffer content and returns a buffer with more 
> {@linkplain ByteBuffer#remaining() available} space
> +     * (which may or may not be the same instance).
> +     * <p>
> +     * Called by the producer when buffer becomes too full to write to.
> +     *
> +     * @param buf the buffer to drain
> +     * @return a buffer with more available space (which may or may not be 
> the same instance)
> +     */
> +    ByteBuffer drain(ByteBuffer buf);
> +}
> 
> 
> 
> 
> -- 
> E-Mail: [email protected] | [email protected] 
> Java Persistence with Hibernate, Second Edition
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

Reply via email to