Package org.apache.batik.util.io
Class StreamNormalizingReader
- java.lang.Object
-
- java.io.Reader
-
- org.apache.batik.util.io.NormalizingReader
-
- org.apache.batik.util.io.StreamNormalizingReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
- Direct Known Subclasses:
XMLStreamNormalizingReader
public class StreamNormalizingReader extends NormalizingReader
This class represents a NormalizingReader which handles streams of bytes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
StreamNormalizingReader.ASCIIDecoderFactory
To create an ASCIIDecoder.protected static interface
StreamNormalizingReader.CharDecoderFactory
Represents a CharDecoder factory.protected static class
StreamNormalizingReader.ISO_8859_1DecoderFactory
To create an ISO_8859_1Decoder.protected static class
StreamNormalizingReader.UTF16DecoderFactory
To create a UTF16Decoder.protected static class
StreamNormalizingReader.UTF8DecoderFactory
To create a UTF8Decoder.
-
Field Summary
Fields Modifier and Type Field Description protected CharDecoder
charDecoder
The char decoder.protected static java.util.Map
charDecoderFactories
The CharDecoder factories map.protected int
column
The current column in the stream.protected int
line
The current line in the stream.protected int
nextChar
The next char.
-
Constructor Summary
Constructors Modifier Constructor Description protected
StreamNormalizingReader()
This constructor is intended for use by subclasses.StreamNormalizingReader(java.io.InputStream is)
Creates a new NormalizingReader.StreamNormalizingReader(java.io.InputStream is, java.lang.String enc)
Creates a new NormalizingReader.StreamNormalizingReader(java.io.Reader r)
Creates a new NormalizingReader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the stream.protected CharDecoder
createCharDecoder(java.io.InputStream is, java.lang.String enc)
Creates the CharDecoder mapped with the given encoding name.int
getColumn()
Returns the current column in the stream.int
getLine()
Returns the current line in the stream.int
read()
Read a single character.-
Methods inherited from class org.apache.batik.util.io.NormalizingReader
read
-
-
-
-
Field Detail
-
charDecoder
protected CharDecoder charDecoder
The char decoder.
-
nextChar
protected int nextChar
The next char.
-
line
protected int line
The current line in the stream.
-
column
protected int column
The current column in the stream.
-
charDecoderFactories
protected static final java.util.Map charDecoderFactories
The CharDecoder factories map.
-
-
Constructor Detail
-
StreamNormalizingReader
public StreamNormalizingReader(java.io.InputStream is) throws java.io.IOException
Creates a new NormalizingReader. The encoding is assumed to be ISO-8859-1.- Parameters:
is
- The input stream to decode.- Throws:
java.io.IOException
-
StreamNormalizingReader
public StreamNormalizingReader(java.io.InputStream is, java.lang.String enc) throws java.io.IOException
Creates a new NormalizingReader.- Parameters:
is
- The input stream to decode.enc
- The standard encoding name. A null encoding means ISO-8859-1.- Throws:
java.io.IOException
-
StreamNormalizingReader
public StreamNormalizingReader(java.io.Reader r) throws java.io.IOException
Creates a new NormalizingReader.- Parameters:
r
- The reader to wrap.- Throws:
java.io.IOException
-
StreamNormalizingReader
protected StreamNormalizingReader()
This constructor is intended for use by subclasses.
-
-
Method Detail
-
read
public int read() throws java.io.IOException
Read a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.- Overrides:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
getLine
public int getLine()
Returns the current line in the stream.- Specified by:
getLine
in classNormalizingReader
-
getColumn
public int getColumn()
Returns the current column in the stream.- Specified by:
getColumn
in classNormalizingReader
-
close
public void close() throws java.io.IOException
Close the stream.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
createCharDecoder
protected CharDecoder createCharDecoder(java.io.InputStream is, java.lang.String enc) throws java.io.IOException
Creates the CharDecoder mapped with the given encoding name.- Throws:
java.io.IOException
-
-