Source Code Cross Referenced for ScatteringByteChannel.java in  » 6.0-JDK-Core » io-nio » java » nio » channels » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » io nio » java.nio.channels 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package java.nio.channels;
027
028        import java.io.IOException;
029        import java.nio.ByteBuffer;
030
031        /**
032         * A channel that can read bytes into a sequence of buffers.
033         *
034         * <p> A <i>scattering</i> read operation reads, in a single invocation, a
035         * sequence of bytes into one or more of a given sequence of buffers.
036         * Scattering reads are often useful when implementing network protocols or
037         * file formats that, for example, group data into segments consisting of one
038         * or more fixed-length headers followed by a variable-length body.  Similar
039         * <i>gathering</i> write operations are defined in the {@link
040         * GatheringByteChannel} interface.  </p>
041         *
042         *
043         * @author Mark Reinhold
044         * @author JSR-51 Expert Group
045         * @version 1.21, 07/05/05
046         * @since 1.4
047         */
048
049        public interface ScatteringByteChannel extends ReadableByteChannel {
050
051            /**
052             * Reads a sequence of bytes from this channel into a subsequence of the
053             * given buffers.
054             *
055             * <p> An invocation of this method attempts to read up to <i>r</i> bytes
056             * from this channel, where <i>r</i> is the total number of bytes remaining
057             * the specified subsequence of the given buffer array, that is,
058             *
059             * <blockquote><pre>
060             * dsts[offset].remaining()
061             *     + dsts[offset+1].remaining()
062             *     + ... + dsts[offset+length-1].remaining()</pre></blockquote>
063             *
064             * at the moment that this method is invoked.
065             *
066             * <p> Suppose that a byte sequence of length <i>n</i> is read, where
067             * <tt>0</tt>&nbsp;<tt>&lt;=</tt>&nbsp;<i>n</i>&nbsp;<tt>&lt;=</tt>&nbsp;<i>r</i>.
068             * Up to the first <tt>dsts[offset].remaining()</tt> bytes of this sequence
069             * are transferred into buffer <tt>dsts[offset]</tt>, up to the next
070             * <tt>dsts[offset+1].remaining()</tt> bytes are transferred into buffer
071             * <tt>dsts[offset+1]</tt>, and so forth, until the entire byte sequence
072             * is transferred into the given buffers.  As many bytes as possible are
073             * transferred into each buffer, hence the final position of each updated
074             * buffer, except the last updated buffer, is guaranteed to be equal to
075             * that buffer's limit.
076             *
077             * <p> This method may be invoked at any time.  If another thread has
078             * already initiated a read operation upon this channel, however, then an
079             * invocation of this method will block until the first operation is
080             * complete. </p>
081             *
082             * @param  dsts
083             *         The buffers into which bytes are to be transferred
084             *
085             * @param  offset
086             *         The offset within the buffer array of the first buffer into
087             *         which bytes are to be transferred; must be non-negative and no
088             *         larger than <tt>dsts.length</tt>
089             *
090             * @param  length
091             *         The maximum number of buffers to be accessed; must be
092             *         non-negative and no larger than
093             *         <tt>dsts.length</tt>&nbsp;-&nbsp;<tt>offset</tt>
094             *
095             * @return The number of bytes read, possibly zero,
096             *         or <tt>-1</tt> if the channel has reached end-of-stream
097             *
098             * @throws  IndexOutOfBoundsException
099             *          If the preconditions on the <tt>offset</tt> and <tt>length</tt>
100             *          parameters do not hold
101             *
102             * @throws  NonReadableChannelException
103             *          If this channel was not opened for reading
104             *
105             * @throws  ClosedChannelException
106             *          If this channel is closed
107             *
108             * @throws  AsynchronousCloseException
109             *          If another thread closes this channel
110             *          while the read operation is in progress
111             *
112             * @throws  ClosedByInterruptException
113             *          If another thread interrupts the current thread
114             *          while the read operation is in progress, thereby
115             *          closing the channel and setting the current thread's
116             *          interrupt status
117             *
118             * @throws  IOException
119             *          If some other I/O error occurs
120             */
121            public long read(ByteBuffer[] dsts, int offset, int length)
122                    throws IOException;
123
124            /**
125             * Reads a sequence of bytes from this channel into the given buffers.
126             *
127             * <p> An invocation of this method of the form <tt>c.read(dsts)</tt>
128             * behaves in exactly the same manner as the invocation
129             *
130             * <blockquote><pre>
131             * c.read(dsts, 0, dsts.length);</pre></blockquote>
132             *
133             * @param  dsts
134             *         The buffers into which bytes are to be transferred
135             *
136             * @return The number of bytes read, possibly zero,
137             *         or <tt>-1</tt> if the channel has reached end-of-stream
138             *
139             * @throws  NonReadableChannelException
140             *          If this channel was not opened for reading
141             *
142             * @throws  ClosedChannelException
143             *          If this channel is closed
144             *
145             * @throws  AsynchronousCloseException
146             *          If another thread closes this channel
147             *          while the read operation is in progress
148             *
149             * @throws  ClosedByInterruptException
150             *          If another thread interrupts the current thread
151             *          while the read operation is in progress, thereby
152             *          closing the channel and setting the current thread's
153             *          interrupt status
154             *
155             * @throws  IOException
156             *          If some other I/O error occurs
157             */
158            public long read(ByteBuffer[] dsts) throws IOException;
159
160        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.