Source Code Cross Referenced for FilterReader.java in  » Apache-Harmony-Java-SE » java-package » java » io » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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 geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package java.io;
019:
020:        /**
021:         * FilterReader is a class which takes a Reader and <em>filters</em> the input
022:         * in some way. The filtered view may be a buffered view or one which
023:         * uncompresses data before returning characters read.
024:         * 
025:         * @see FilterWriter
026:         */
027:        public abstract class FilterReader extends Reader {
028:
029:            /**
030:             * The target Reader which is being filtered.
031:             */
032:            protected Reader in;
033:
034:            /**
035:             * Constructs a new FilterReader on the Reader <code>in</code>. All reads
036:             * are now filtered through this Reader.
037:             * 
038:             * @param in
039:             *            The non-null Reader to filter reads on.
040:             */
041:            protected FilterReader(Reader in) {
042:                super (in);
043:                this .in = in;
044:            }
045:
046:            /**
047:             * Close this FilterReader. This implementation closes the target Reader.
048:             * 
049:             * @throws IOException
050:             *             If an error occurs attempting to close this Reader.
051:             */
052:            @Override
053:            public void close() throws IOException {
054:                synchronized (lock) {
055:                    in.close();
056:                }
057:            }
058:
059:            /**
060:             * Set a Mark position in this FilterReader. The parameter
061:             * <code>readLimit</code> indicates how many characters can be read before
062:             * a mark is invalidated. Sending reset() will reposition the Reader back to
063:             * the marked position provided <code>readLimit</code> has not been
064:             * surpassed.
065:             * <p>
066:             * This implementation sets a mark in the target Reader.
067:             * 
068:             * @param readlimit
069:             *            the number of characters to be able to read before
070:             *            invalidating the mark.
071:             * 
072:             * @throws IOException
073:             *             If an error occurs attempting mark this Reader.
074:             */
075:            @Override
076:            public synchronized void mark(int readlimit) throws IOException {
077:                synchronized (lock) {
078:                    in.mark(readlimit);
079:                }
080:            }
081:
082:            /**
083:             * Answers a boolean indicating whether or not this FilterReader supports
084:             * mark() and reset(). This implementation answers whether or not the target
085:             * Reader supports marking.
086:             * 
087:             * @return indicates whether or not mark() and reset() are supported.
088:             */
089:            @Override
090:            public boolean markSupported() {
091:                synchronized (lock) {
092:                    return in.markSupported();
093:                }
094:            }
095:
096:            /**
097:             * Reads a single char from this FilterReader and returns the result as an
098:             * int. The 2 lowest order bytes are returned or -1 of the end of reader was
099:             * encountered. This implementation returns a char from the target Reader.
100:             * 
101:             * @return The byte read or -1 if end of reader.
102:             * 
103:             * @throws IOException
104:             *             If an error occurs attempting to read from this Reader.
105:             */
106:            @Override
107:            public int read() throws IOException {
108:                synchronized (lock) {
109:                    return in.read();
110:                }
111:            }
112:
113:            /**
114:             * Reads at most <code>count</code> chars from this FilterReader and
115:             * stores them in char array <code>buffer</code> starting at offset
116:             * <code>offset</code>. Answer the number of chars actually read or -1 if
117:             * no chars were read and end of reader was encountered. This implementation
118:             * reads chars from the target reader.
119:             * 
120:             * @param buffer
121:             *            the char array in which to store the read chars.
122:             * @param offset
123:             *            the offset in <code>buffer</code> to store the read chars.
124:             * @param count
125:             *            the maximum number of chars to store in <code>buffer</code>.
126:             * @return the number of chars actually read or -1 if end of reader.
127:             * 
128:             * @throws IOException
129:             *             If an error occurs attempting to read from this Reader.
130:             */
131:            @Override
132:            public int read(char[] buffer, int offset, int count)
133:                    throws IOException {
134:                synchronized (lock) {
135:                    return in.read(buffer, offset, count);
136:                }
137:            }
138:
139:            /**
140:             * Answers a <code>boolean</code> indicating whether or not this Reader is
141:             * ready to be read without blocking. If the result is <code>true</code>,
142:             * the next <code>read()</code> will not block. If the result is
143:             * <code>false</code> this Reader may or may not block when
144:             * <code>read()</code> is sent.
145:             * 
146:             * @return <code>true</code> if the receiver will not block when
147:             *         <code>read()</code> is called, <code>false</code> if unknown
148:             *         or blocking will occur.
149:             * 
150:             * @throws IOException
151:             *             If the Reader is already closed or some other IO error
152:             *             occurs.
153:             */
154:            @Override
155:            public boolean ready() throws IOException {
156:                synchronized (lock) {
157:                    return in.ready();
158:                }
159:            }
160:
161:            /**
162:             * Reset this Readers position to the last <code>mark()</code> location.
163:             * Invocations of <code>read()/skip()</code> will occur from this new
164:             * location. If this Reader was not marked, the implementation of
165:             * <code>reset()</code> is implementation specific. See the comment for
166:             * the specific Reader subclass for implementation details. The default
167:             * action is to throw <code>IOException</code>.
168:             * 
169:             * @throws IOException
170:             *             if a problem occurred or the target Reader does not support
171:             *             <code>mark()/reset()</code>.
172:             */
173:            @Override
174:            public void reset() throws IOException {
175:                synchronized (lock) {
176:                    in.reset();
177:                }
178:            }
179:
180:            /**
181:             * Skips <code>count</code> number of characters in this Reader.
182:             * Subsequent <code>read()</code>'s will not return these characters
183:             * unless <code>reset()</code> is used. The default implementation is to
184:             * skip chars in the filtered Reader.
185:             * 
186:             * @param count
187:             *            the maximum number of characters to skip.
188:             * @return the number of characters actually skipped.
189:             * 
190:             * @throws IOException
191:             *             If the Reader is already closed or some other IO error
192:             *             occurs.
193:             */
194:            @Override
195:            public long skip(long count) throws IOException {
196:                synchronized (lock) {
197:                    return in.skip(count);
198:                }
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.