KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xsocket > IDataSink


1 // $Id: IDataSink.java 1532 2007-07-17 11:04:50Z grro $
2
/*
3  * Copyright (c) xsocket.org, 2006 - 2007. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Please refer to the LGPL license at: http://www.gnu.org/copyleft/lesser.txt
20  * The latest copy of this software may be found on http://www.xsocket.org/
21  */

22 package org.xsocket;
23
24 import java.io.IOException JavaDoc;
25 import java.nio.ByteBuffer JavaDoc;
26
27
28
29
30 /**
31  * A data sink is an I/O resource capable of receiving data.
32  *
33  * @author grro@xsocket.org
34  */

35 public interface IDataSink {
36
37
38     /**
39      * writes a byte to the data sink
40      *
41      * @param b the byte to write
42      * @return the number of send bytes
43      * @throws IOException If some other I/O error occurs
44      */

45     public int write(byte b) throws IOException JavaDoc;
46
47     
48     /**
49      * writes bytes to the data sink
50      *
51      * @param bytes the bytes to write
52      * @return the number of send bytes
53      * @throws IOException If some other I/O error occurs
54      */

55     public int write(byte... bytes) throws IOException JavaDoc;
56     
57
58     /**
59      * writes bytes to the data sink
60      *
61      * @param bytes the bytes to write
62      * @param offset The offset of the subarray to be used; must be non-negative and no larger than array.length. The new buffer's position will be set to this value.
63      * @param length The length of the subarray to be used; must be non-negative and no larger than array.length - offset. The new buffer's limit will be set to offset + length.
64      * @return the number of send bytes
65      * @throws IOException If some other I/O error occurs
66      */

67     public int write(byte[] bytes, int offset, int length) throws IOException JavaDoc;
68
69
70     /**
71      * writes a byte buffer to the data sink
72      *
73      * @param buffer the bytes to write
74      * @return the number of send bytes
75      * @throws IOException If some other I/O error occurs
76      */

77     public int write(ByteBuffer JavaDoc buffer) throws IOException JavaDoc;
78     
79     
80     /**
81      * writes a byte array to the data sink
82      *
83      * @param buffers the bytes to write
84      * @return the number of send bytes
85      * @throws IOException If some other I/O error occurs
86      */

87     public long write(ByteBuffer JavaDoc[] buffers) throws IOException JavaDoc;
88
89
90     /**
91      * writes a int to the data sink
92      *
93      * @param i the int value to write
94      * @return the number of send bytes
95      * @throws IOException If some other I/O error occurs
96      */

97     public int write(int i) throws IOException JavaDoc;
98
99     
100     /**
101      * writes a short to the data sink
102      *
103      * @param s the short value to write
104      * @return the number of send bytes
105      * @throws IOException If some other I/O error occurs
106      */

107     public int write(short s) throws IOException JavaDoc;
108
109     /**
110      * writes a long to the data sink
111      *
112      * @param l the int value to write
113      * @return the number of send bytes
114      * @throws IOException If some other I/O error occurs
115      */

116     public int write(long l) throws IOException JavaDoc;
117
118     
119     /**
120      * writes a double to the data sink
121      *
122      * @param d the int value to write
123      * @return the number of send bytes
124      * @throws IOException If some other I/O error occurs
125      */

126     public int write(double d) throws IOException JavaDoc;
127     
128     
129     /**
130      * write a message
131      *
132      * @param message the message to write
133      * @param encoding the encoding which should be used th encode the chars into byte (e.g. 'US-ASCII' or 'UTF-8')
134      * @return the number of send bytes
135      * @throws IOException If some other I/O error occurs
136      */

137     public int write(String JavaDoc message, String JavaDoc encoding) throws IOException JavaDoc;
138
139     
140     /**
141      * writes a message
142      *
143      * @param message the message to write
144      * @return the number of send bytes
145      * @throws IOException If some other I/O error occurs
146      */

147     public int write(String JavaDoc message) throws IOException JavaDoc;
148
149 }
150
Popular Tags