KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jruby > util > IOHandlerNull


1 /***** BEGIN LICENSE BLOCK *****
2  * Version: CPL 1.0/GPL 2.0/LGPL 2.1
3  *
4  * The contents of this file are subject to the Common Public
5  * License Version 1.0 (the "License"); you may not use this file
6  * except in compliance with the License. You may obtain a copy of
7  * the License at http://www.eclipse.org/legal/cpl-v10.html
8  *
9  * Software distributed under the License is distributed on an "AS
10  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11  * implied. See the License for the specific language governing
12  * rights and limitations under the License.
13  *
14  * Copyright (C) 2006 Thomas E Enebo <enebo@acm.org>
15  * Copyright (C) 2006 Charles O Nutter <headius@headius.com>
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either of the GNU General Public License Version 2 or later (the "GPL"),
19  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the CPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the CPL, the GPL or the LGPL.
28  ***** END LICENSE BLOCK *****/

29 package org.jruby.util;
30
31 import java.io.EOFException JavaDoc;
32 import java.io.IOException JavaDoc;
33 import java.nio.channels.FileChannel JavaDoc;
34
35 import org.jruby.Ruby;
36
37 public class IOHandlerNull extends IOHandler {
38     
39     public IOHandlerNull(Ruby runtime, IOModes modes) {
40         super(runtime);
41         
42         this.modes = modes;
43     }
44
45     public FileChannel JavaDoc getFileChannel() {
46         // TODO Auto-generated method stub
47
return null;
48     }
49
50     public ByteList gets(ByteList separatorString) throws IOException JavaDoc, BadDescriptorException,
51         EOFException JavaDoc {
52         throw new EOFException JavaDoc();
53     }
54
55     public ByteList getsEntireStream() throws IOException JavaDoc,
56             BadDescriptorException, EOFException JavaDoc {
57         throw new EOFException JavaDoc();
58     }
59
60     public ByteList read(int number) throws IOException JavaDoc, BadDescriptorException,
61             EOFException JavaDoc {
62         throw new EOFException JavaDoc();
63     }
64
65     public int write(ByteList string) throws IOException JavaDoc, BadDescriptorException {
66         return string.length();
67     }
68
69     public int getc() throws IOException JavaDoc, BadDescriptorException, EOFException JavaDoc {
70         throw new EOFException JavaDoc();
71     }
72
73     public void ungetc(int c) {
74     }
75
76     public void putc(int c) throws IOException JavaDoc, BadDescriptorException {
77     }
78
79     public ByteList sysread(int number) throws IOException JavaDoc, BadDescriptorException, EOFException JavaDoc {
80         throw new EOFException JavaDoc();
81     }
82
83     public int syswrite(ByteList buf) throws IOException JavaDoc, BadDescriptorException {
84         return buf.length();
85     }
86
87     public int syswrite(int c) throws IOException JavaDoc, BadDescriptorException {
88         return 1;
89     }
90
91     public IOHandler cloneIOHandler() throws IOException JavaDoc, PipeException, InvalidValueException {
92         return new IOHandlerNull(getRuntime(), modes);
93     }
94
95     public void close() throws IOException JavaDoc, BadDescriptorException {
96     }
97
98     public void flush() throws IOException JavaDoc, BadDescriptorException {
99     }
100
101     public void sync() throws IOException JavaDoc, BadDescriptorException {
102     }
103
104     public boolean isEOF() throws IOException JavaDoc, BadDescriptorException {
105         return true;
106     }
107
108     public int pid() {
109         return 0;
110     }
111
112     public long pos() throws IOException JavaDoc, PipeException {
113         return 0;
114     }
115
116     protected void resetByModes(IOModes newModes) throws IOException JavaDoc, InvalidValueException {
117     }
118
119     public void rewind() throws IOException JavaDoc, PipeException, InvalidValueException {
120     }
121
122     public void seek(long offset, int type) throws IOException JavaDoc, PipeException,
123         InvalidValueException {
124     }
125
126     public void truncate(long newLength) throws IOException JavaDoc, PipeException {
127     }
128 }
129
Popular Tags