Class HDTPart

java.lang.Object
org.eclipse.rdf4j.rio.hdt.HDTPart
Direct Known Subclasses:
HDTArray, HDTBitmap, HDTDictionary, HDTDictionarySection, HDTGlobal, HDTHeader, HDTTriples, HDTTriplesSection

abstract class HDTPart extends Object
Helper class for different HDT parts.

Each part starts with $HDT, followed by a byte indicating the type of the part.

Structure:

 +------+------+
 | $HDT | type |
 +------+------+
 
  • Field Details

    • BUFLEN

      private static final int BUFLEN
      See Also:
    • name

      protected final String name
    • pos

      protected final long pos
    • properties

      protected Map<String,String> properties
  • Constructor Details

    • HDTPart

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

      protected HDTPart()
      Constructor
  • Method Details

    • parse

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

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

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

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

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

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

      protected static int countToNull(byte[] b, int start) throws 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:
      IOException
    • getProperties

      protected static Map<String,String> getProperties(InputStream is) throws 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:
      IOException
    • mapProperties

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

      protected int getIntegerProperty(Map<String,String> props, String prop, String name) throws 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:
      IOException
    • checkCRC

      protected static void checkCRC(CheckedInputStream cis, InputStream is, int len) throws 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:
      IOException