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
Nested ClassesModifier and TypeClassDescriptionstatic final classType safe enumeration class that describes the different types of Unicode BOMs. -
Constructor Summary
ConstructorsConstructorDescriptionUnicodeBOMInputStream(InputStream inputStream) Constructs a newUnicodeBOMInputStreamthat wraps the specifiedInputStream. -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()getBOM()Returns theBOMthat was detected in the wrappedInputStreamobject.voidmark(int readlimit) booleanintread()intread(byte[] b) intread(byte[] b, int off, int len) voidreset()longskip(long n) final UnicodeBOMInputStreamskipBOM()Skips theBOMthat was found in the wrappedInputStreamobject.Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
UnicodeBOMInputStream
Constructs a newUnicodeBOMInputStreamthat wraps the specifiedInputStream.- Parameters:
inputStream- anInputStream.- Throws:
NullPointerException- wheninputStreamisnull.IOException- on reading from the specifiedInputStreamwhen trying to detect the Unicode BOM.
-
-
Method Details
-
getBOM
Returns theBOMthat was detected in the wrappedInputStreamobject.- Returns:
- a
BOMvalue.
-
skipBOM
Skips theBOMthat was found in the wrappedInputStreamobject.- Returns:
- this
UnicodeBOMInputStream. - Throws:
IOException- when trying to skip the BOM from the wrappedInputStreamobject.
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOExceptionNullPointerException
-
read
- Overrides:
readin classInputStream- Throws:
IOExceptionNullPointerException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-