java.lang.Object
kala.compress.compressors.gzip.ExtraField
- All Implemented Interfaces:
Iterable<ExtraField.SubField>
If the
FLG.FEXTRA bit is set, an "extra field" is present in the header, with total length XLEN bytes. It consists of a series of subfields, each of
the form:
+---+---+---+---+==================================+ |SI1|SI2| LEN |... LEN bytes of subfield data ...| +---+---+---+---+==================================+This class does not expose the internal subfields list to prevent adding subfields without total extra length validation. However a copy of the list is available.
- Since:
- 1.28.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIf theFLG.FEXTRAbit is set, an "extra field" is present in the header, with total length XLEN bytes. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final List<ExtraField.SubField> private intprivate static final byte[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddSubField(String id, byte[] payload) Append a subfield by a 2-chars ISO-8859-1 string.(package private) static ExtraFieldfromBytes(byte[] bytes) getSubFieldAt(int index) Gets the subfield at the given index.iterator()Returns an iterator over the SubField elements in this extra field in proper sequence.(package private) byte[]Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
MAX_SIZE
private static final int MAX_SIZE- See Also:
-
ZERO_BYTES
private static final byte[] ZERO_BYTES -
subFields
-
totalSize
private int totalSize
-
-
Constructor Details
-
ExtraField
public ExtraField()Constructs a new instance.
-
-
Method Details
-
fromBytes
- Throws:
IOException
-
addSubField
Append a subfield by a 2-chars ISO-8859-1 string. The char at index 0 and 1 are respectiovely si1 and si2 (subfield id 1 and 2).- Parameters:
id- The subfield ID.payload- The subfield payload.- Returns:
- this instance.
- Throws:
NullPointerException- ifidisnull.NullPointerException- ifpayloadisnull.IllegalArgumentException- if the subfield is not 2 characters or the payload is nullIOException- if appending this subfield would exceed the max size 65535 of the extra header.
-
getSubFieldAt
Gets the subfield at the given index.- Parameters:
index- index of the element to return- Returns:
- the subfield at the specified position in this list
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= size())
-
iterator
Returns an iterator over the SubField elements in this extra field in proper sequence.- Specified by:
iteratorin interfaceIterable<ExtraField.SubField>- Returns:
- an iterator over the SubField elements in this extra field in proper sequence.
-
toByteArray
byte[] toByteArray()
-