Package adams.data.io.input.opus
Class OpusBlockHelper
- java.lang.Object
-
- adams.data.io.input.opus.OpusBlockHelper
-
public class OpusBlockHelper extends Object
Analyzer for Opus file blocks in the header.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOpusBlockHelper.BlockConvenience class for handling blocks.static classOpusBlockHelper.BlockDefinitionContainer class for Opus block definitions in the header.static classOpusBlockHelper.CommandlineDataEncapsulates and parses a commandline string.
-
Field Summary
Fields Modifier and Type Field Description static byte[]APFthe APF character sequence.static byte[]APTthe APT character sequence.static byte[]AQMthe AQM character sequence.static intBLOCK_DEFINITION_LENGTHthe block definition length (type, length, offset).static intBLOCK_OFFSETthe offset for block definitions in the header.static intBLOCKTYPE_DUMMYthe dummy block type (???).static intBLOCKTYPE_INCREMENT_DATA_TO_DPFincrement from data to DPF block type.static intBLOCKTYPE_MAIN_MASKthe mask for the block type of the main spectrum.static intBLOCKTYPE_SPEC_MASKthe mask for the block type of the main spectrum.static intBLOCKTYPE_TEXTthe text block type.static byte[]CNMthe CNM character sequence.static byte[]CSFthe CSF character sequence.static byte[]DPFthe DPF character sequence.static byte[]ENDthe END character sequence.static byte[]FXVthe FXV character sequence.static intHEADER_LENGTHmaximum length of header (made up value!).static byte[]INSthe INS character sequence.static StringKEY_SAMPLEIDthe key for the sample ID.static StringKEY_SAMPLEID2the key for the sample ID (2).static StringKEYWORD_CMDLINEthe command line keyword.static byte[]LXVthe LXV character sequence.static byte[]NPTthe NPT character sequence.static StringOPERATION_MEASURESAMPLEthe operation containing the sample ID.static byte[]PLFthe PLF character sequence.static StringTEXT_SEPARATORthe text separator.
-
Constructor Summary
Constructors Constructor Description OpusBlockHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intbyteToUnsignedByte(byte b)Convert byte to unsigned byte.static intfindID(byte[] buf, byte[] id, int start)Locates the first occurrence of the specified ID in the buffer after the starting position.static DoublegetDouble(byte[] buf, int offset)Returns the double with the given ID.static longgetLong(byte[] buf, int offset)Returns the long at the specified offset.static StringgetText(byte[] buf, int offset)Returns the 0-terminated text at the specified offset.static List<OpusBlockHelper.Block>readBlocks(byte[] buf, List<OpusBlockHelper.BlockDefinition> defs)Creates blocks from the definitions.static List<OpusBlockHelper.BlockDefinition>readDefinitions(byte[] buf, adams.core.MessageCollection errors)Parses the opus header and returns the blocks definitions.static List<OpusBlockHelper.BlockDefinition>readDefinitions(File file, adams.core.MessageCollection errors)Parses the opus header and returns the blocks definitions.
-
-
-
Field Detail
-
BLOCK_OFFSET
public static final int BLOCK_OFFSET
the offset for block definitions in the header.- See Also:
- Constant Field Values
-
HEADER_LENGTH
public static final int HEADER_LENGTH
maximum length of header (made up value!).- See Also:
- Constant Field Values
-
BLOCK_DEFINITION_LENGTH
public static final int BLOCK_DEFINITION_LENGTH
the block definition length (type, length, offset).- See Also:
- Constant Field Values
-
BLOCKTYPE_DUMMY
public static final int BLOCKTYPE_DUMMY
the dummy block type (???).- See Also:
- Constant Field Values
-
BLOCKTYPE_TEXT
public static final int BLOCKTYPE_TEXT
the text block type.- See Also:
- Constant Field Values
-
BLOCKTYPE_SPEC_MASK
public static final int BLOCKTYPE_SPEC_MASK
the mask for the block type of the main spectrum.- See Also:
- Constant Field Values
-
BLOCKTYPE_MAIN_MASK
public static final int BLOCKTYPE_MAIN_MASK
the mask for the block type of the main spectrum.- See Also:
- Constant Field Values
-
BLOCKTYPE_INCREMENT_DATA_TO_DPF
public static final int BLOCKTYPE_INCREMENT_DATA_TO_DPF
increment from data to DPF block type.- See Also:
- Constant Field Values
-
END
public static final byte[] END
the END character sequence.
-
APT
public static final byte[] APT
the APT character sequence.
-
APF
public static final byte[] APF
the APF character sequence.
-
AQM
public static final byte[] AQM
the AQM character sequence.
-
CNM
public static final byte[] CNM
the CNM character sequence.
-
DPF
public static final byte[] DPF
the DPF character sequence.
-
NPT
public static final byte[] NPT
the NPT character sequence.
-
FXV
public static final byte[] FXV
the FXV character sequence.
-
LXV
public static final byte[] LXV
the LXV character sequence.
-
CSF
public static final byte[] CSF
the CSF character sequence.
-
INS
public static final byte[] INS
the INS character sequence.
-
PLF
public static final byte[] PLF
the PLF character sequence.
-
TEXT_SEPARATOR
public static final String TEXT_SEPARATOR
the text separator.- See Also:
- Constant Field Values
-
KEYWORD_CMDLINE
public static final String KEYWORD_CMDLINE
the command line keyword.- See Also:
- Constant Field Values
-
OPERATION_MEASURESAMPLE
public static final String OPERATION_MEASURESAMPLE
the operation containing the sample ID.- See Also:
- Constant Field Values
-
KEY_SAMPLEID
public static final String KEY_SAMPLEID
the key for the sample ID.- See Also:
- Constant Field Values
-
KEY_SAMPLEID2
public static final String KEY_SAMPLEID2
the key for the sample ID (2).- See Also:
- Constant Field Values
-
-
Method Detail
-
readDefinitions
public static List<OpusBlockHelper.BlockDefinition> readDefinitions(File file, adams.core.MessageCollection errors)
Parses the opus header and returns the blocks definitions.- Parameters:
file- the fileerrors- for collecting errors- Returns:
- the definitions
-
readDefinitions
public static List<OpusBlockHelper.BlockDefinition> readDefinitions(byte[] buf, adams.core.MessageCollection errors)
Parses the opus header and returns the blocks definitions.- Parameters:
buf- the file contenterrors- for collecting errors- Returns:
- the definitions
-
readBlocks
public static List<OpusBlockHelper.Block> readBlocks(byte[] buf, List<OpusBlockHelper.BlockDefinition> defs)
Creates blocks from the definitions.- Parameters:
buf- the file contentdefs- the definitions to use- Returns:
- the blocks
-
findID
public static int findID(byte[] buf, byte[] id, int start)Locates the first occurrence of the specified ID in the buffer after the starting position.- Parameters:
buf- the file contentid- the block type to findstart- the starting point- Returns:
- the start/end, null if failed to detect
-
byteToUnsignedByte
public static int byteToUnsignedByte(byte b)
Convert byte to unsigned byte.- Parameters:
b- the byte- Returns:
- the unsigned byte
-
getLong
public static long getLong(byte[] buf, int offset)Returns the long at the specified offset.- Parameters:
offset- the offset to use- Returns:
- the long
-
getDouble
public static Double getDouble(byte[] buf, int offset)
Returns the double with the given ID.- Parameters:
offset- starting pos- Returns:
- the double value, null if failed to convert
-
getText
public static String getText(byte[] buf, int offset)
Returns the 0-terminated text at the specified offset.- Parameters:
offset- the offset to use- Returns:
- the text
-
-