Package com.basis.filesystem.util
Class KeyDescription
java.lang.Object
com.basis.filesystem.util.KeyDescription
- All Implemented Interfaces:
Serializable,Cloneable
Class used to describe derived keys in MKEYED and XKEYED files.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intDeprecated.static final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionKeyDescription(int p_keyNum, byte[] p_data, int p_offset, int p_end) Constructor from a byte array in FIN format.KeyDescription(int p_keyNum, byte[] p_data, int p_offset, int p_end, boolean p_extended) Constructor from a byte array in FIN or XFIN format.KeyDescription(List<KeySegment> p_segments, boolean p_unique) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckSegments(int p_errorCode) voidcheckSegments(String p_filename, int p_errorCode) Helper function to check and make sure that segments are valid for an MKEYED file.clone()booleanfinal voidfixDescendingSegments(byte[] p_fromKey, int p_fromKeyLen, byte[] p_toKey, int p_toKeyLen, boolean p_mangle) Fix descending segments so that they are switched to/from normal.final voidfixDescendingSegments(byte[] p_fromKey, int p_fromOffset, int p_fromKeyLen, byte[] p_toKey, int p_toOffset, int p_toKeyLen, boolean p_mangle) Fix descending segments so that they are switched to/from normal.final voidfixDescendingSegments(byte[] p_fromKey, int p_fromOffset, int p_fromKeyLen, byte[] p_toKey, int p_toOffset, int p_toKeyLen, Locale p_locale, Charset p_charset, boolean p_mangle) Fix descending segments so that they are switched to/from normal.final voidfixDescendingSegments(io.netty.buffer.ByteBuf p_fromKey, io.netty.buffer.ByteBuf p_toKey, Locale p_locale, Charset p_charset, boolean p_mangle) Fix descending segments so that they are switched to/from normal.final voidgetAndFixKeyForRecord(io.netty.buffer.ByteBuf p_record, int p_actualRecordSize, io.netty.buffer.ByteBuf p_key, boolean p_checkFields, Locale p_locale, Charset p_charset, boolean p_mangle) final voidgetAndFixKeyForRecord(String p_filename, io.netty.buffer.ByteBuf p_record, int p_actualRecordSize, io.netty.buffer.ByteBuf p_key, boolean p_checkFields, Locale p_locale, Charset p_charset, boolean p_mangle) static List<KeyDescription>getKeyDescriptions(byte[] p_data, int p_offset, int p_end) static List<KeyDescription>getKeyDescriptions(String p_filename, byte[] p_data, int p_offset, int p_end) Helper function to pull a list ofKeyDescriptionobjects out of a byte array.static intgetKeyDescriptionsSize(KeyDescription[] p_keyDesc) Return number of bytes needed to encode an array ofKeyDescriptionobjects in FIN format.static intgetKeyDescriptionsSize(List<KeyDescription> p_keyDesc) Return number of bytes needed to encode a list ofKeyDescriptionobjects in FIN format.final voidgetKeyForRecord(byte[] p_record, int p_size, byte[] p_key) final voidgetKeyForRecord(byte[] p_record, int p_size, byte[] p_key, boolean p_checkFields) final voidgetKeyForRecord(byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength) final voidgetKeyForRecord(byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields) final voidgetKeyForRecord(byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields, Charset p_charset) final voidgetKeyForRecord(byte[] p_record, int p_roffset, int p_size, int p_actualRecordSize, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields) final voidgetKeyForRecord(byte[] p_record, int p_roffset, int p_size, int p_actualRecordSize, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields, Charset p_charset) final voidgetKeyForRecord(io.netty.buffer.ByteBuf p_record, int p_actualRecordSize, io.netty.buffer.ByteBuf p_key, boolean p_checkFields, Charset p_charset) final voidgetKeyForRecord(String p_filename, byte[] p_record, int p_size, byte[] p_key) Get the derived key value for a record.final voidgetKeyForRecord(String p_filename, byte[] p_record, int p_size, byte[] p_key, boolean p_checkFields) Get the derived key value for a record.final voidgetKeyForRecord(String p_filename, byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength) Get the derived key value for a record.final voidgetKeyForRecord(String p_filename, byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields) Get the derived key value for a record.final voidgetKeyForRecord(String p_filename, byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields, Charset p_charset) Get the derived key value for a record.final voidgetKeyForRecord(String p_filename, byte[] p_record, int p_roffset, int p_size, int p_actualRecordSize, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields) final voidgetKeyForRecord(String p_filename, byte[] p_record, int p_roffset, int p_size, int p_actualRecordSize, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields, Charset p_charset) final voidgetKeyForRecord(String p_filename, io.netty.buffer.ByteBuf p_record, int p_actualRecordSize, io.netty.buffer.ByteBuf p_key, boolean p_checkFields, Charset p_charset) Get list of key segments (copy of internal list).intGet the key size (sum of lengths of the segments).static List<KeyDescription>getXKeyDescriptions(byte[] p_data, int p_offset, int p_end) static List<KeyDescription>getXKeyDescriptions(String p_filename, byte[] p_data, int p_offset, int p_end) Helper function to pull a list ofKeyDescriptionobjects out of a byte array in XFIN format.static intgetXKeyDescriptionsSize(KeyDescription p_keyDesc) Return number of bytes needed to encode a list ofKeyDescriptionobjects in XFIN format.static intgetXKeyDescriptionsSize(KeyDescription[] p_keyDesc) Return number of bytes needed to encode an array ofKeyDescriptionobjects in XFIN format.static intgetXKeyDescriptionsSize(List<KeyDescription> p_keyDesc) Return number of bytes needed to encode a list ofKeyDescriptionobjects in XFIN format.inthashCode()booleanhasSpecialType(int p_special) Helper method to see if any of the segments have a given special type.booleanIs the last key segment fielded?booleanisUnique()Get whether this key is unique.static intputKeyDescriptions(KeyDescription[] p_keyDesc, byte[] p_data, int p_offset, int p_length) Helper function to putKeyDescriptionobjects into a byte array.static intputKeyDescriptions(List<KeyDescription> p_keyDesc, byte[] p_data, int p_offset, int p_length) Helper function to putKeyDescriptionobjects into a byte array.static intputXKeyDescriptions(KeyDescription[] p_keyDesc, byte[] p_data, int p_offset, int p_length) Helper function to putKeyDescriptionobjects into a byte array.static intputXKeyDescriptions(KeyDescription p_keyDesc, byte[] p_data, int p_offset, int p_length) Helper function to putKeyDescriptionobjects into a byte array.static intputXKeyDescriptions(List<KeyDescription> p_keyDesc, byte[] p_data, int p_offset, int p_length) Helper function to putKeyDescriptionobjects into a byte array.voidsetUnique(boolean p_unique) Set that this key is unique.toString()
-
Field Details
-
FLAG_DESCENDING
public static final int FLAG_DESCENDING- See Also:
-
FLAG_UNIQUE
public static final int FLAG_UNIQUE- See Also:
-
FLAG_BUS
public static final int FLAG_BUS- See Also:
-
FLAG_NUMERIC
Deprecated.- See Also:
-
FLAG_ORDERED_NUMERIC
public static final int FLAG_ORDERED_NUMERIC- See Also:
-
FLAG_CASE_INSENSITIVE
public static final int FLAG_CASE_INSENSITIVE- See Also:
-
-
Constructor Details
-
KeyDescription
public KeyDescription() -
KeyDescription
Constructor- Parameters:
p_segments- List of KeySegment objects describing the segments of this key.p_unique- true if the key is unique.- Throws:
FilesystemException- If a filesystem problem occurs.
-
KeyDescription
public KeyDescription(int p_keyNum, byte[] p_data, int p_offset, int p_end) throws FilesystemException Constructor from a byte array in FIN format.- Parameters:
p_keyNum- Key number to extract from the buffer.p_data- Buffer with the key information.p_offset- Offset in the buffer to start extracting.p_end- End of the buffer to extract keys.- Throws:
FilesystemException- If a filesystem problem occurs.
-
KeyDescription
public KeyDescription(int p_keyNum, byte[] p_data, int p_offset, int p_end, boolean p_extended) throws FilesystemException Constructor from a byte array in FIN or XFIN format.- Parameters:
p_keyNum- Key number to extract from the buffer.p_data- Buffer with the key information.p_offset- Offset in the buffer to start extracting.p_end- End of the buffer to extract keys.p_extended- true if the byte array is in XFIN format.- Throws:
FilesystemException- If a filesystem problem occurs.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
isLastSegmentFielded
public boolean isLastSegmentFielded()Is the last key segment fielded? -
hasSpecialType
public boolean hasSpecialType(int p_special) Helper method to see if any of the segments have a given special type.- Parameters:
p_special- Special type to look for.- Returns:
- True if a segment in this key has the special type provided.
-
checkSegments
- Throws:
FilesystemException
-
checkSegments
Helper function to check and make sure that segments are valid for an MKEYED file.- Parameters:
p_filename-p_errorCode- Error code to use for violations.- Throws:
FilesystemException- If a filesystem problem occurs.
-
getKeySize
public int getKeySize()Get the key size (sum of lengths of the segments).- Returns:
- Actual size of this key.
-
setUnique
public void setUnique(boolean p_unique) Set that this key is unique.- Parameters:
p_unique- Is this key unique?
-
isUnique
public boolean isUnique()Get whether this key is unique.- Returns:
- true if the key is unique.
-
getKeySegments
Get list of key segments (copy of internal list).- Returns:
- List of the key segments for this key.
-
getKeyForRecord
public final void getKeyForRecord(byte[] p_record, int p_size, byte[] p_key) throws FilesystemException - Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(String p_filename, byte[] p_record, int p_size, byte[] p_key) throws FilesystemException Get the derived key value for a record.- Parameters:
p_filename-p_record- Record to derive key for.p_size- Size of the record.p_key- Buffer to fill with the key value.- Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(byte[] p_record, int p_size, byte[] p_key, boolean p_checkFields) throws FilesystemException - Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(String p_filename, byte[] p_record, int p_size, byte[] p_key, boolean p_checkFields) throws FilesystemException Get the derived key value for a record.- Parameters:
p_filename-p_record- Record to derive key for.p_size- Size of the record.p_key- Buffer to fill with the key value.p_checkFields- Should field existence be enforced?- Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength) throws FilesystemException - Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(String p_filename, byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength) throws FilesystemException Get the derived key value for a record.- Parameters:
p_filename-p_record- Record to derive key for.p_roffset- Record offset.p_size- Size of the record.p_key- Buffer to fill with the key value.p_koffset- Key offset.p_klength- Key Length.- Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields) throws FilesystemException - Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(String p_filename, byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields) throws FilesystemException Get the derived key value for a record.- Parameters:
p_filename-p_record- Record to derive key for.p_roffset- Record offset.p_size- Size of the record.p_key- Buffer to fill with the key value.p_koffset- Key offset.p_klength- Key Length.p_checkFields- Should field existence be enforced?- Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(byte[] p_record, int p_roffset, int p_size, int p_actualRecordSize, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields) throws FilesystemException - Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(String p_filename, byte[] p_record, int p_roffset, int p_size, int p_actualRecordSize, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields) throws FilesystemException - Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields, Charset p_charset) throws FilesystemException - Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(String p_filename, byte[] p_record, int p_roffset, int p_size, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields, Charset p_charset) throws FilesystemException Get the derived key value for a record.- Parameters:
p_filename-p_record- Record to derive key for.p_roffset- Record offset.p_size- Size of the record.p_key- Buffer to fill with the key value.p_koffset- Key offset.p_klength- Key Length.p_checkFields- Should field existence be enforced?p_charset- Charset for decoding/encoding strings.- Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(byte[] p_record, int p_roffset, int p_size, int p_actualRecordSize, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields, Charset p_charset) throws FilesystemException - Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(String p_filename, byte[] p_record, int p_roffset, int p_size, int p_actualRecordSize, byte[] p_key, int p_koffset, int p_klength, boolean p_checkFields, Charset p_charset) throws FilesystemException - Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(io.netty.buffer.ByteBuf p_record, int p_actualRecordSize, io.netty.buffer.ByteBuf p_key, boolean p_checkFields, Charset p_charset) throws FilesystemException - Throws:
FilesystemException
-
getKeyForRecord
public final void getKeyForRecord(String p_filename, io.netty.buffer.ByteBuf p_record, int p_actualRecordSize, io.netty.buffer.ByteBuf p_key, boolean p_checkFields, Charset p_charset) throws FilesystemException - Throws:
FilesystemException
-
getAndFixKeyForRecord
public final void getAndFixKeyForRecord(io.netty.buffer.ByteBuf p_record, int p_actualRecordSize, io.netty.buffer.ByteBuf p_key, boolean p_checkFields, Locale p_locale, Charset p_charset, boolean p_mangle) throws FilesystemException - Throws:
FilesystemException
-
getAndFixKeyForRecord
public final void getAndFixKeyForRecord(String p_filename, io.netty.buffer.ByteBuf p_record, int p_actualRecordSize, io.netty.buffer.ByteBuf p_key, boolean p_checkFields, Locale p_locale, Charset p_charset, boolean p_mangle) throws FilesystemException - Throws:
FilesystemException
-
fixDescendingSegments
public final void fixDescendingSegments(byte[] p_fromKey, int p_fromKeyLen, byte[] p_toKey, int p_toKeyLen, boolean p_mangle) Fix descending segments so that they are switched to/from normal.- Parameters:
p_fromKey- Key to convert.p_fromKeyLen- Length of the key to convert.p_toKey- Key buffer to fill.p_toKeyLen- Length of the key buffer to fill.p_mangle- true if numeric fields should be adjusted for descending.
-
fixDescendingSegments
public final void fixDescendingSegments(byte[] p_fromKey, int p_fromOffset, int p_fromKeyLen, byte[] p_toKey, int p_toOffset, int p_toKeyLen, boolean p_mangle) Fix descending segments so that they are switched to/from normal.- Parameters:
p_fromKey- Key to convert.p_fromOffset- Starting offset.p_fromKeyLen- Length of the key to convert.p_toKey- Key buffer to fill.p_toOffset- Starting offset.p_toKeyLen- Length of the key buffer to fill.p_mangle- true if numeric fields should be adjusted for descending.
-
fixDescendingSegments
public final void fixDescendingSegments(byte[] p_fromKey, int p_fromOffset, int p_fromKeyLen, byte[] p_toKey, int p_toOffset, int p_toKeyLen, Locale p_locale, Charset p_charset, boolean p_mangle) Fix descending segments so that they are switched to/from normal.- Parameters:
p_fromKey- Key to convert.p_fromOffset- Starting offset.p_fromKeyLen- Length of the key to convert.p_toKey- Key buffer to fill.p_toOffset- Starting offset.p_toKeyLen- Length of the key buffer to fill.p_locale- Locale for case insensitive segments.p_charset- Charset for decoding/encoding stringsp_mangle- true if numeric fields should be adjusted for descending.
-
fixDescendingSegments
public final void fixDescendingSegments(io.netty.buffer.ByteBuf p_fromKey, io.netty.buffer.ByteBuf p_toKey, Locale p_locale, Charset p_charset, boolean p_mangle) Fix descending segments so that they are switched to/from normal.- Parameters:
p_fromKey- Key to convert.p_toKey- Key buffer to fill.p_locale- Locale for case insensitive segments.p_charset- Charset for decoding/encoding stringsp_mangle- true if numeric fields should be adjusted for descending.
-
toString
-
clone
-
getKeyDescriptions
public static List<KeyDescription> getKeyDescriptions(byte[] p_data, int p_offset, int p_end) throws FilesystemException - Throws:
FilesystemException
-
getKeyDescriptions
public static List<KeyDescription> getKeyDescriptions(String p_filename, byte[] p_data, int p_offset, int p_end) throws FilesystemException Helper function to pull a list ofKeyDescriptionobjects out of a byte array.- Parameters:
p_filename-p_data- Buffer with keys.p_offset- Offset in buffer to start looking for keys.p_end- End in the buffer to look for keys.- Throws:
FilesystemException- If a filesystem problem occurs.
-
getKeyDescriptionsSize
Return number of bytes needed to encode an array ofKeyDescriptionobjects in FIN format.- Parameters:
p_keyDesc- Array ofKeyDescriptionobjects.
-
getKeyDescriptionsSize
Return number of bytes needed to encode a list ofKeyDescriptionobjects in FIN format.- Parameters:
p_keyDesc- List ofKeyDescriptionobjects.
-
putXKeyDescriptions
public static int putXKeyDescriptions(KeyDescription[] p_keyDesc, byte[] p_data, int p_offset, int p_length) Helper function to putKeyDescriptionobjects into a byte array.- Parameters:
p_keyDesc- Array of key descriptions.p_data- Buffer to put key information in.p_offset- Offset in the buffer to start placing key information.p_length- Length of the buffer that we are allowed to place key information in.
-
putXKeyDescriptions
public static int putXKeyDescriptions(List<KeyDescription> p_keyDesc, byte[] p_data, int p_offset, int p_length) Helper function to putKeyDescriptionobjects into a byte array.- Parameters:
p_keyDesc- List of key descriptions.p_data- Buffer to put key information in.p_offset- Offset in the buffer to start placing key information.p_length- Length of the buffer that we are allowed to place key information in.
-
putXKeyDescriptions
public static int putXKeyDescriptions(KeyDescription p_keyDesc, byte[] p_data, int p_offset, int p_length) Helper function to putKeyDescriptionobjects into a byte array.- Parameters:
p_keyDesc- List of key descriptions.p_data- Buffer to put key information in.p_offset- Offset in the buffer to start placing key information.p_length- Length of the buffer that we are allowed to place key information in.
-
getXKeyDescriptions
public static List<KeyDescription> getXKeyDescriptions(byte[] p_data, int p_offset, int p_end) throws FilesystemException - Throws:
FilesystemException
-
getXKeyDescriptions
public static List<KeyDescription> getXKeyDescriptions(String p_filename, byte[] p_data, int p_offset, int p_end) throws FilesystemException Helper function to pull a list ofKeyDescriptionobjects out of a byte array in XFIN format.- Parameters:
p_filename-p_data- Buffer with keys.p_offset- Offset in buffer to start looking for keys.p_end- End in the buffer to look for keys.- Throws:
FilesystemException- If a filesystem problem occurs.
-
getXKeyDescriptionsSize
Return number of bytes needed to encode an array ofKeyDescriptionobjects in XFIN format.- Parameters:
p_keyDesc- Array ofKeyDescriptionobjects.
-
getXKeyDescriptionsSize
Return number of bytes needed to encode a list ofKeyDescriptionobjects in XFIN format.- Parameters:
p_keyDesc- List ofKeyDescriptionobjects.
-
getXKeyDescriptionsSize
Return number of bytes needed to encode a list ofKeyDescriptionobjects in XFIN format.- Parameters:
p_keyDesc- List ofKeyDescriptionobjects.
-
putKeyDescriptions
public static int putKeyDescriptions(KeyDescription[] p_keyDesc, byte[] p_data, int p_offset, int p_length) Helper function to putKeyDescriptionobjects into a byte array.- Parameters:
p_keyDesc- Array of key descriptions.p_data- Buffer to put key information in.p_offset- Offset in the buffer to start placing key information.p_length- Length of the buffer that we are allowed to place key information in.
-
putKeyDescriptions
public static int putKeyDescriptions(List<KeyDescription> p_keyDesc, byte[] p_data, int p_offset, int p_length) Helper function to putKeyDescriptionobjects into a byte array.- Parameters:
p_keyDesc- List of key descriptions.p_data- Buffer to put key information in.p_offset- Offset in the buffer to start placing key information.p_length- Length of the buffer that we are allowed to place key information in.
-