Source Code Cross Referenced for Latin1Reader.java in  » XML » xerces-2_9_1 » org » apache » xerces » impl » 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 » XML » xerces 2_9_1 » org.apache.xerces.impl.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 org.apache.xerces.impl.io;
019:
020:        import java.io.IOException;
021:        import java.io.InputStream;
022:        import java.io.Reader;
023:
024:        /**
025:         * <p>Reader for the ISO-8859-1 encoding.</p>
026:         * 
027:         * @xerces.internal
028:         * 
029:         * @author Michael Glavassevich, IBM
030:         * 
031:         * @version $Id: Latin1Reader.java 446716 2006-09-15 20:28:48Z mrglavas $
032:         */
033:        public class Latin1Reader extends Reader {
034:
035:            //
036:            // Constants
037:            //
038:
039:            /** Default byte buffer size (2048). */
040:            public static final int DEFAULT_BUFFER_SIZE = 2048;
041:
042:            //
043:            // Data
044:            //
045:
046:            /** Input stream. */
047:            protected final InputStream fInputStream;
048:
049:            /** Byte buffer. */
050:            protected final byte[] fBuffer;
051:
052:            //
053:            // Constructors
054:            //
055:
056:            /** 
057:             * Constructs an ISO-8859-1 reader from the specified input stream 
058:             * using the default buffer size.
059:             *
060:             * @param inputStream The input stream.
061:             */
062:            public Latin1Reader(InputStream inputStream) {
063:                this (inputStream, DEFAULT_BUFFER_SIZE);
064:            } // <init>(InputStream)
065:
066:            /** 
067:             * Constructs an ISO-8859-1 reader from the specified input stream 
068:             * and buffer size.
069:             *
070:             * @param inputStream The input stream.
071:             * @param size        The initial buffer size.
072:             */
073:            public Latin1Reader(InputStream inputStream, int size) {
074:                this (inputStream, new byte[size]);
075:            } // <init>(InputStream, int)
076:
077:            /** 
078:             * Constructs an ISO-8859-1 reader from the specified input stream and buffer.
079:             *
080:             * @param inputStream The input stream.
081:             * @param buffer      The byte buffer.
082:             */
083:            public Latin1Reader(InputStream inputStream, byte[] buffer) {
084:                fInputStream = inputStream;
085:                fBuffer = buffer;
086:            } // <init>(InputStream, byte[])
087:
088:            //
089:            // Reader methods
090:            //
091:
092:            /**
093:             * Read a single character. This method will block until a character is
094:             * available, an I/O error occurs, or the end of the stream is reached.
095:             *
096:             * <p> Subclasses that intend to support efficient single-character input
097:             * should override this method.
098:             *
099:             * @return     The character read, as an integer in the range 0 to 255
100:             *             (<tt>0x00-0xff</tt>), or -1 if the end of the stream has
101:             *             been reached
102:             *
103:             * @exception  IOException  If an I/O error occurs
104:             */
105:            public int read() throws IOException {
106:                return fInputStream.read();
107:            } // read():int
108:
109:            /**
110:             * Read characters into a portion of an array.  This method will block
111:             * until some input is available, an I/O error occurs, or the end of the
112:             * stream is reached.
113:             *
114:             * @param      ch     Destination buffer
115:             * @param      offset Offset at which to start storing characters
116:             * @param      length Maximum number of characters to read
117:             *
118:             * @return     The number of characters read, or -1 if the end of the
119:             *             stream has been reached
120:             *
121:             * @exception  IOException  If an I/O error occurs
122:             */
123:            public int read(char ch[], int offset, int length)
124:                    throws IOException {
125:                if (length > fBuffer.length) {
126:                    length = fBuffer.length;
127:                }
128:                int count = fInputStream.read(fBuffer, 0, length);
129:                for (int i = 0; i < count; ++i) {
130:                    ch[offset + i] = (char) (fBuffer[i] & 0xff);
131:                }
132:                return count;
133:            } // read(char[],int,int)
134:
135:            /**
136:             * Skip characters.  This method will block until some characters are
137:             * available, an I/O error occurs, or the end of the stream is reached.
138:             *
139:             * @param  n  The number of characters to skip
140:             *
141:             * @return    The number of characters actually skipped
142:             *
143:             * @exception  IOException  If an I/O error occurs
144:             */
145:            public long skip(long n) throws IOException {
146:                return fInputStream.skip(n);
147:            } // skip(long):long
148:
149:            /**
150:             * Tell whether this stream is ready to be read.
151:             *
152:             * @return True if the next read() is guaranteed not to block for input,
153:             * false otherwise.  Note that returning false does not guarantee that the
154:             * next read will block.
155:             *
156:             * @exception  IOException  If an I/O error occurs
157:             */
158:            public boolean ready() throws IOException {
159:                return false;
160:            } // ready()
161:
162:            /**
163:             * Tell whether this stream supports the mark() operation.
164:             */
165:            public boolean markSupported() {
166:                return fInputStream.markSupported();
167:            } // markSupported()
168:
169:            /**
170:             * Mark the present position in the stream.  Subsequent calls to reset()
171:             * will attempt to reposition the stream to this point.  Not all
172:             * character-input streams support the mark() operation.
173:             *
174:             * @param  readAheadLimit  Limit on the number of characters that may be
175:             *                         read while still preserving the mark.  After
176:             *                         reading this many characters, attempting to
177:             *                         reset the stream may fail.
178:             *
179:             * @exception  IOException  If the stream does not support mark(),
180:             *                          or if some other I/O error occurs
181:             */
182:            public void mark(int readAheadLimit) throws IOException {
183:                fInputStream.mark(readAheadLimit);
184:            } // mark(int)
185:
186:            /**
187:             * Reset the stream.  If the stream has been marked, then attempt to
188:             * reposition it at the mark.  If the stream has not been marked, then
189:             * attempt to reset it in some way appropriate to the particular stream,
190:             * for example by repositioning it to its starting point.  Not all
191:             * character-input streams support the reset() operation, and some support
192:             * reset() without supporting mark().
193:             *
194:             * @exception  IOException  If the stream has not been marked,
195:             *                          or if the mark has been invalidated,
196:             *                          or if the stream does not support reset(),
197:             *                          or if some other I/O error occurs
198:             */
199:            public void reset() throws IOException {
200:                fInputStream.reset();
201:            } // reset()
202:
203:            /**
204:             * Close the stream.  Once a stream has been closed, further read(),
205:             * ready(), mark(), or reset() invocations will throw an IOException.
206:             * Closing a previously-closed stream, however, has no effect.
207:             *
208:             * @exception  IOException  If an I/O error occurs
209:             */
210:            public void close() throws IOException {
211:                fInputStream.close();
212:            } // close()
213:
214:        } // class Latin1Reader
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.