Package org.eclipse.rdf4j.rio.hdt
Class HDTPart
java.lang.Object
org.eclipse.rdf4j.rio.hdt.HDTPart
- Direct Known Subclasses:
HDTArray
,HDTBitmap
,HDTDictionary
,HDTDictionarySection
,HDTGlobal
,HDTHeader
,HDTTriples
,HDTTriplesSection
Helper class for different HDT parts.
Each part starts with $HDT
, followed by a byte indicating the type of the part.
Structure:
+------+------+ | $HDT | type | +------+------+
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
checkControl
(InputStream is, HDTPart.Type ctype) Check start of part for$HDT
and the byte indicating the typeprotected static void
checkCRC
(CheckedInputStream cis, InputStream is, int len) Compare the calculated checksum to the expected one.protected static void
checkFormat
(InputStream is, byte[] format) Check fornull
terminated format string.protected static int
countToNull
(byte[] b, int start) Get the first position of the NULL byte within an array of bytesprotected String
Get a string for debugging purposes, containing the name and starting position of this part.protected int
Get the positive integer value from a property map.Get properties, if any.Get the properties from the input stream, reading at most BUFLEN bytes.mapProperties
(byte[] props) Get properties as a key, value mapprotected abstract void
parse
(InputStream is) Parse from input streamprotected static byte[]
Read null terminated series of bytes
-
Field Details
-
COOKIE
protected static final byte[] COOKIE -
BUFLEN
private static final int BUFLEN- See Also:
-
name
-
pos
protected final long pos -
properties
-
-
Constructor Details
-
HDTPart
Constructor- Parameters:
name
- part namepos
- starting position in input stream
-
HDTPart
protected HDTPart()Constructor
-
-
Method Details
-
parse
Parse from input stream- Parameters:
is
-- Throws:
IOException
-
getProperties
Get properties, if any.- Returns:
- key, value map
-
getDebugPartStr
Get a string for debugging purposes, containing the name and starting position of this part.- Returns:
- string
-
checkControl
Check start of part for$HDT
and the byte indicating the type- Parameters:
is
- input streamctype
- control type- Throws:
IOException
-
checkFormat
Check fornull
terminated format string.- Parameters:
is
-format
-- Throws:
IOException
-
readToNull
Read null terminated series of bytes- Parameters:
is
- input stream- Returns:
- Throws:
IOException
-
countToNull
Get the first position of the NULL byte within an array of bytes- Parameters:
b
- byte arraystart
- position to start from- Returns:
- position of first NULL byte
- Throws:
IOException
-
getProperties
Get the properties from the input stream, reading at most BUFLEN bytes. The properties are encoded as akey=value;
string and must benull
terminated.- Parameters:
is
- input stream- Returns:
- key, value map
- Throws:
IOException
-
mapProperties
Get properties as a key, value map- Parameters:
props
-- Returns:
-
getIntegerProperty
protected int getIntegerProperty(Map<String, String> props, String prop, String name) throws IOExceptionGet the positive integer value from a property map. Throw an exception when the property is missing, or less than 1.- Parameters:
props
- property mapprop
- name of the propertyname
- display name of the property- Returns:
- positive integer
- Throws:
IOException
-
checkCRC
Compare the calculated checksum to the expected one.- Parameters:
cis
- checked input streamis
- (unchecked) input streamlen
- number of bytes of the checksum- Throws:
IOException
-