java.lang.Object
org.xbib.rpm.header.AbstractHeader
- Direct Known Subclasses:
Header,SignatureHeader
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSpecEntry<?>Adds a pending entry to this header.<T> voidaddOrAppendEntry(EntryType entryType, T values) This is the main entry point through which entries are created or appended to from the builder or from places like the ChangelogHandler.intcount()voidcreateEntry(EntryType entryType, CharSequence value) voidcreateEntry(EntryType entryType, Integer value) <T> voidcreateEntry(EntryType entryType, T values) This is the main entry point through which entries are created from the builder code for types other than String.intSpecEntry<?>getEntry(int code) SpecEntry<?>protected ByteBufferMemory maps the portion of the destination file that will contain the header structure header and advances the file channels position.intprotected abstract booleanpad()intReads the entire header contents for this channel and returns the number of entries found.voidsetEndPos(int endPos) voidsetStartPos(int startPos) toString()intwrite(WritableByteChannel out) Writes this header section to the provided file at the current position and returns the required padding.voidwritePending(SeekableByteChannel channel)
-
Field Details
-
tags
-
-
Constructor Details
-
AbstractHeader
public AbstractHeader()
-
-
Method Details
-
pad
protected abstract boolean pad() -
read
Reads the entire header contents for this channel and returns the number of entries found.- Parameters:
in- the ReadableByteChannel to read- Returns:
- the number read
- Throws:
IOException- there was an IO error
-
write
Writes this header section to the provided file at the current position and returns the required padding. The caller is responsible for adding the padding immediately after this data.- Parameters:
out- the WritableByteChannel to output to- Returns:
- the number written
- Throws:
IOException- there was an IO error
-
getEntries
-
count
public int count() -
getEntry
-
getEntry
-
createEntry
-
createEntry
-
writePending
-
createEntry
This is the main entry point through which entries are created from the builder code for types other than String.- Type Parameters:
T- type parameter- Parameters:
entryType- the Tag identifying the type of header this is bound forvalues- the values to be stored in the entry.- Throws:
ClassCastException- - if the type of values is not compatible with the type required by tag
-
addOrAppendEntry
This is the main entry point through which entries are created or appended to from the builder or from places like the ChangelogHandler. This is useful for header types which may have multiple components of each tag, as changelogs do.- Type Parameters:
T- type parameter- Parameters:
entryType- the Tag identifying the type of header this is bound forvalues- the values to be stored in or appended to the entry.- Throws:
ClassCastException- - if the type of values is not compatible with the type required by tag
-
addEntry
Adds a pending entry to this header. This entry will have the correctly sized buffer allocated, but will not be written until the caller writes a value and then invokeswritePending(java.nio.channels.SeekableByteChannel)on this object.- Parameters:
entryType- the tagcount- the count- Returns:
- the entry added
-
getEndPos
public int getEndPos() -
setEndPos
public void setEndPos(int endPos) -
getStartPos
public int getStartPos() -
setStartPos
public void setStartPos(int startPos) -
getHeader
Memory maps the portion of the destination file that will contain the header structure header and advances the file channels position. The resulting buffer will be prefilled with the necesssary magic data and the correct index count, but will require an integer value to be written with the total data section size once data writing is complete. This method must be invoked before mapping the index or data sections.- Returns:
- a buffer containing the header
-
toString
-