Class CssInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class CssInputStream
    extends java.io.PushbackInputStream
    An InputStream for CSS files that detects and skips past BOMs, and peeks for @charset rules.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  CssInputStream.Endian  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) com.google.common.base.Optional<java.lang.String> bom  
      private static java.util.Map<java.lang.String,​byte[]> boms  
      (package private) com.google.common.base.Optional<java.lang.String> charset  
      private boolean debug  
      private static int MAX_PUSHBACK  
      • Fields inherited from class java.io.PushbackInputStream

        buf, pos
      • Fields inherited from class java.io.FilterInputStream

        in
    • Constructor Summary

      Constructors 
      Constructor Description
      CssInputStream​(java.io.InputStream in)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String getBOM()  
      com.google.common.base.Optional<java.lang.String> getBomCharset()
      Get the character set as detected from a BOM.
      com.google.common.base.Optional<java.lang.String> getCssCharset()
      Get the value of the CSS @charset rule, if present.
      private java.lang.String getCssCharset​(java.lang.String bom)  
      private static java.lang.String map​(byte[] data)  
      • Methods inherited from class java.io.PushbackInputStream

        available, close, mark, markSupported, read, read, reset, skip, unread, unread, unread
      • Methods inherited from class java.io.FilterInputStream

        read
      • Methods inherited from class java.io.InputStream

        nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • bom

        com.google.common.base.Optional<java.lang.String> bom
      • charset

        com.google.common.base.Optional<java.lang.String> charset
      • boms

        private static final java.util.Map<java.lang.String,​byte[]> boms
      • debug

        private boolean debug
    • Constructor Detail

      • CssInputStream

        public CssInputStream​(java.io.InputStream in)
                       throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getBOM

        private java.lang.String getBOM()
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • getCssCharset

        private java.lang.String getCssCharset​(java.lang.String bom)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • map

        private static java.lang.String map​(byte[] data)
      • getBomCharset

        public final com.google.common.base.Optional<java.lang.String> getBomCharset()
        Get the character set as detected from a BOM. If present, the returned string is one of 'UTF-32BE', 'UTF-32LE", 'UTF-8", 'UTF-16BE' or 'UTF-16LE".
      • getCssCharset

        public final com.google.common.base.Optional<java.lang.String> getCssCharset()
        Get the value of the CSS @charset rule, if present.