KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xsocket > IDataSource


1 // $Id: IDataSource.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.io.UnsupportedEncodingException JavaDoc;
26
27
28 /**
29  * A data sink is an I/O resource capable of providing data.
30  *
31  * @author grro@xsocket.org
32  */

33 public interface IDataSource {
34
35
36     
37     /**
38      * read a byte
39      *
40      * @return the byte value
41      * @throws IOException If some other I/O error occurs
42      */

43     public byte readByte() throws IOException JavaDoc;
44     
45     
46     
47     /**
48      * read a short value
49      *
50      * @return the short value
51      * @throws IOException If some other I/O error occurs
52      */

53     public short readShort() throws IOException JavaDoc;
54     
55     
56     /**
57      * read an int
58      *
59      * @return the int value
60      * @throws IOException If some other I/O error occurs
61      */

62     public int readInt() throws IOException JavaDoc;
63
64     
65     /**
66      * read a long
67      *
68      * @return the long value
69      * @throws IOException If some other I/O error occurs
70      */

71     public long readLong() throws IOException JavaDoc;
72
73     
74     /**
75      * read a double
76      *
77      * @return the double value
78      * @throws IOException If some other I/O error occurs
79      */

80     public double readDouble() throws IOException JavaDoc;
81     
82     
83
84     /**
85      * read bytes by using a length defintion
86      *
87      * @param length the amount of bytes to read
88      * @return the read bytes
89      * @throws IOException If some other I/O error occurs
90      */

91     public byte[] readBytesByLength(int length) throws IOException JavaDoc;
92
93     
94
95     
96     
97     /**
98      * read a string by using a length definition and the connection default encoding
99      *
100      * @param length the amount of bytes to read
101      * @return the string
102      * @throws IOException If some other I/O error occurs
103      * @throws UnsupportedEncodingException if the given encoding is not supported
104      */

105     public String JavaDoc readStringByLength(int length) throws IOException JavaDoc, UnsupportedEncodingException JavaDoc;
106
107
108
109     /**
110      * read a string by using a length definition
111      *
112      * @param length the amount of bytes to read
113      * @param encoding the encodin to use
114      * @return the string
115      * @throws IOException If some other I/O error occurs
116      * @throws UnsupportedEncodingException if the given encoding is not supported
117      */

118     public String JavaDoc readStringByLength(int length, String JavaDoc encoding) throws IOException JavaDoc, UnsupportedEncodingException JavaDoc;
119     
120     
121     /**
122      * read a string by using a delimiter and the connection default encoding
123      *
124      * @param delimiter the delimiter
125      * @return the string
126      * @throws IOException If some other I/O error occurs
127      * @throws UnsupportedEncodingException if the default encoding is not supported
128      */

129     public String JavaDoc readStringByDelimiter(String JavaDoc delimiter) throws IOException JavaDoc, UnsupportedEncodingException JavaDoc;
130     
131     
132     /**
133      * read a string by using a delimiter and the connection default encoding
134      *
135      * @param delimiter the delimiter
136      * @param maxLength the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
137      * @return the string
138      * @throws MaxReadSizeExceededException If the max read length has been exceeded and the delimiter hasnít been found
139      * @throws IOException If some other I/O error occurs
140      * @throws UnsupportedEncodingException if the default encoding is not supported
141      */

142     public String JavaDoc readStringByDelimiter(String JavaDoc delimiter, int maxLength) throws IOException JavaDoc, UnsupportedEncodingException JavaDoc, MaxReadSizeExceededException;
143     
144     
145     
146     /**
147      * read a string by using a delimiter
148      *
149      * @param delimiter the delimiter
150      * @param encoding the encodin to use
151      * @param maxLength the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
152      * @return the string
153      * @throws MaxReadSizeExceededException If the max read length has been exceeded and the delimiter hasnít been found
154      * @throws IOException If some other I/O error occurs
155      * @throws UnsupportedEncodingException if the given encoding is not supported
156      */

157     public String JavaDoc readStringByDelimiter(String JavaDoc delimiter, String JavaDoc encoding, int maxLength) throws IOException JavaDoc, UnsupportedEncodingException JavaDoc, MaxReadSizeExceededException;
158
159     
160     
161     /**
162      * read a byte array by using a delimiter
163      *
164      * For performance reasons, the ByteBuffer readByteBuffer method is
165      * generally preferable to get bytes
166      *
167      * @param delimiter the delimiter
168      * @param maxLength the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
169      * @return the read bytes
170      * @throws MaxReadSizeExceededException If the max read length has been exceeded and the delimiter hasnít been found
171      * @throws IOException If some other I/O error occurs
172      */

173     public byte[] readBytesByDelimiter(String JavaDoc delimiter, int maxLength) throws IOException JavaDoc, MaxReadSizeExceededException;
174 }
175
Popular Tags