Package com.github._1c_syntax.bsl.parser
Class UnicodeBOMInputStream
java.lang.Object
java.io.InputStream
com.github._1c_syntax.bsl.parser.UnicodeBOMInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
The
UnicodeBOMInputStream
class wraps any
InputStream
and detects the presence of any Unicode BOM
(Byte Order Mark) at its beginning, as defined by
RFC 3629 - UTF-8, a
transformation format of ISO 10646
The Unicode FAQ defines 5 types of BOMs: -
00 00 FE FF = UTF-32, big-endian-
FF FE 00 00 = UTF-32, little-endian-
FE FF = UTF-16, big-endian-
FF FE = UTF-16, little-endian-
EF BB BF = UTF-8
Use the getBOM()
method to know whether a BOM has been detected
or not.
Use the skipBOM()
method to remove the detected BOM from the
wrapped InputStream
object.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Type safe enumeration class that describes the different types of Unicode BOMs. -
Constructor Summary
ConstructorDescriptionUnicodeBOMInputStream
(InputStream inputStream) Constructs a newUnicodeBOMInputStream
that wraps the specifiedInputStream
. -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
getBOM()
Returns theBOM
that was detected in the wrappedInputStream
object.void
mark
(int readlimit) boolean
int
read()
int
read
(byte[] b) int
read
(byte[] b, int off, int len) void
reset()
long
skip
(long n) final UnicodeBOMInputStream
skipBOM()
Skips theBOM
that was found in the wrappedInputStream
object.Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
UnicodeBOMInputStream
Constructs a newUnicodeBOMInputStream
that wraps the specifiedInputStream
.- Parameters:
inputStream
- anInputStream
.- Throws:
NullPointerException
- wheninputStream
isnull
.IOException
- on reading from the specifiedInputStream
when trying to detect the Unicode BOM.
-
-
Method Details
-
getBOM
Returns theBOM
that was detected in the wrappedInputStream
object.- Returns:
- a
BOM
value.
-
skipBOM
Skips theBOM
that was found in the wrappedInputStream
object.- Returns:
- this
UnicodeBOMInputStream
. - Throws:
IOException
- when trying to skip the BOM from the wrappedInputStream
object.
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
NullPointerException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
NullPointerException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
mark
in classInputStream
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-