KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > quercus > lib > file > BinaryInput


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.quercus.lib.file;
31
32 import com.caucho.quercus.env.BinaryValue;
33 import com.caucho.quercus.env.StringValue;
34
35 import java.io.IOException JavaDoc;
36 import java.io.InputStream JavaDoc;
37 import java.io.UnsupportedEncodingException JavaDoc;
38
39 /**
40  * Interface for a Quercus binary input stream
41  */

42 public interface BinaryInput extends BinaryStream {
43   public static final int SEEK_SET = 0;
44   public static final int SEEK_CUR = 1;
45   public static final int SEEK_END = 2;
46
47   /**
48    * Returns an InputStream to the input.
49    */

50   public InputStream JavaDoc getInputStream();
51
52   /**
53    * Opens a new copy.
54    */

55   public BinaryInput openCopy()
56     throws IOException JavaDoc;
57   
58   /**
59    * Reads the next byte, returning -1 on eof.
60    */

61   public int read()
62     throws IOException JavaDoc;
63   
64   /**
65    * Unreads the last byte.
66    */

67   public void unread()
68     throws IOException JavaDoc;
69
70   /**
71    * Reads into a buffer, returning -1 on eof.
72    */

73   public int read(byte []buffer, int offset, int length)
74     throws IOException JavaDoc;
75   
76   /**
77    * Reads a Binary string.
78    */

79   public BinaryValue read(int length)
80     throws IOException JavaDoc;
81
82   /**
83    * Reads the optional linefeed character from a \r\n
84    */

85   public boolean readOptionalLinefeed()
86     throws IOException JavaDoc;
87   
88   /**
89    * Reads a line from the buffer.
90    */

91   public StringValue readLine(long length)
92     throws IOException JavaDoc;
93
94   /**
95    * Returns the current location in the stream
96    */

97   public long getPosition();
98
99   /**
100    * Sets the current location in the stream
101    */

102   public boolean setPosition(long offset);
103
104   /**
105    * Closes the stream.
106    */

107   public void close();
108
109   /**
110    * Closes the stream for reading
111    */

112   public void closeRead();
113
114   /**
115    * Sets the current read encoding. The encoding can either be a
116    * Java encoding name or a mime encoding.
117    *
118    * @param encoding name of the read encoding
119    */

120   public void setEncoding(String JavaDoc encoding)
121     throws UnsupportedEncodingException JavaDoc;
122
123   /**
124    * Seek according to offset and whence. For fseek() compatibility in
125    * wrapped streams.
126    */

127   public long seek(long offset, int whence);
128 }
129
130
Popular Tags