Mercurial > jhg
diff src/org/tmatesoft/hg/internal/ByteArrayChannel.java @ 608:e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 07 May 2013 21:27:51 +0200 |
parents | 1a7a9a20e1f9 |
children |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/ByteArrayChannel.java Tue May 07 16:52:46 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/ByteArrayChannel.java Tue May 07 21:27:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 TMate Software Ltd + * Copyright (c) 2011-2013 TMate Software Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +23,8 @@ import org.tmatesoft.hg.util.ByteChannel; /** - * + * {@link ByteChannel} implementation that serializes data into a byte array + * * @author Artem Tikhomirov * @author TMate Software Ltd. */ @@ -48,7 +49,10 @@ } } - // TODO document what happens on write after toArray() in each case + /* + * {@link #toArray()} calls do not clear data collected so far, subsequent {@link #write(ByteBuffer)} + * augment collected content. + */ public int write(ByteBuffer buffer) { int rv = buffer.remaining(); if (buffers == null) { @@ -58,9 +62,13 @@ copy.put(buffer); buffers.add(copy); } + result = null; return rv; } + /** + * @return content accumulated so far + */ public byte[] toArray() { if (result != null) { return result; @@ -84,7 +92,6 @@ bb.get(result, off, bb.limit()); off += bb.limit(); } - buffers.clear(); return result; } }