Class HDTPart

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  HDTPart.Type  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int BUFLEN  
      protected static byte[] COOKIE  
      protected java.lang.String name  
      protected long pos  
      protected java.util.Map<java.lang.String,​java.lang.String> properties  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected HDTPart()
      Constructor
      protected HDTPart​(java.lang.String name, long pos)
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected static void checkControl​(java.io.InputStream is, HDTPart.Type ctype)
      Check start of part for $HDT and the byte indicating the type
      protected static void checkCRC​(java.util.zip.CheckedInputStream cis, java.io.InputStream is, int len)
      Compare the calculated checksum to the expected one.
      protected static void checkFormat​(java.io.InputStream is, byte[] format)
      Check for null terminated format string.
      protected static int countToNull​(byte[] b, int start)
      Get the first position of the NULL byte within an array of bytes
      protected java.lang.String getDebugPartStr()
      Get a string for debugging purposes, containing the name and starting position of this part.
      protected int getIntegerProperty​(java.util.Map<java.lang.String,​java.lang.String> props, java.lang.String prop, java.lang.String name)
      Get the positive integer value from a property map.
      protected java.util.Map<java.lang.String,​java.lang.String> getProperties()
      Get properties, if any.
      protected static java.util.Map<java.lang.String,​java.lang.String> getProperties​(java.io.InputStream is)
      Get the properties from the input stream, reading at most BUFLEN bytes.
      protected static java.util.Map<java.lang.String,​java.lang.String> mapProperties​(byte[] props)
      Get properties as a key, value map
      protected abstract void parse​(java.io.InputStream is)
      Parse from input stream
      protected static byte[] readToNull​(java.io.InputStream is)
      Read null terminated series of bytes
      • Methods inherited from class java.lang.Object

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

      • COOKIE

        protected static final byte[] COOKIE
      • name

        protected final java.lang.String name
      • pos

        protected final long pos
      • properties

        protected java.util.Map<java.lang.String,​java.lang.String> properties
    • Constructor Detail

      • HDTPart

        protected HDTPart​(java.lang.String name,
                          long pos)
        Constructor
        Parameters:
        name - part name
        pos - starting position in input stream
      • HDTPart

        protected HDTPart()
        Constructor
    • Method Detail

      • parse

        protected abstract void parse​(java.io.InputStream is)
                               throws java.io.IOException
        Parse from input stream
        Parameters:
        is -
        Throws:
        java.io.IOException
      • getProperties

        protected java.util.Map<java.lang.String,​java.lang.String> getProperties()
        Get properties, if any.
        Returns:
        key, value map
      • getDebugPartStr

        protected java.lang.String getDebugPartStr()
        Get a string for debugging purposes, containing the name and starting position of this part.
        Returns:
        string
      • checkControl

        protected static void checkControl​(java.io.InputStream is,
                                           HDTPart.Type ctype)
                                    throws java.io.IOException
        Check start of part for $HDT and the byte indicating the type
        Parameters:
        is - input stream
        ctype - control type
        Throws:
        java.io.IOException
      • checkFormat

        protected static void checkFormat​(java.io.InputStream is,
                                          byte[] format)
                                   throws java.io.IOException
        Check for null terminated format string.
        Parameters:
        is -
        format -
        Throws:
        java.io.IOException
      • readToNull

        protected static byte[] readToNull​(java.io.InputStream is)
                                    throws java.io.IOException
        Read null terminated series of bytes
        Parameters:
        is - input stream
        Returns:
        Throws:
        java.io.IOException
      • countToNull

        protected static int countToNull​(byte[] b,
                                         int start)
                                  throws java.io.IOException
        Get the first position of the NULL byte within an array of bytes
        Parameters:
        b - byte array
        start - position to start from
        Returns:
        position of first NULL byte
        Throws:
        java.io.IOException
      • getProperties

        protected static java.util.Map<java.lang.String,​java.lang.String> getProperties​(java.io.InputStream is)
                                                                                       throws java.io.IOException
        Get the properties from the input stream, reading at most BUFLEN bytes. The properties are encoded as a key=value; string and must be null terminated.
        Parameters:
        is - input stream
        Returns:
        key, value map
        Throws:
        java.io.IOException
      • mapProperties

        protected static java.util.Map<java.lang.String,​java.lang.String> mapProperties​(byte[] props)
        Get properties as a key, value map
        Parameters:
        props -
        Returns:
      • getIntegerProperty

        protected int getIntegerProperty​(java.util.Map<java.lang.String,​java.lang.String> props,
                                         java.lang.String prop,
                                         java.lang.String name)
                                  throws java.io.IOException
        Get the positive integer value from a property map. Throw an exception when the property is missing, or less than 1.
        Parameters:
        props - property map
        prop - name of the property
        name - display name of the property
        Returns:
        positive integer
        Throws:
        java.io.IOException
      • checkCRC

        protected static void checkCRC​(java.util.zip.CheckedInputStream cis,
                                       java.io.InputStream is,
                                       int len)
                                throws java.io.IOException
        Compare the calculated checksum to the expected one.
        Parameters:
        cis - checked input stream
        is - (unchecked) input stream
        len - number of bytes of the checksum
        Throws:
        java.io.IOException