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 class
OpusBlockHelper.Block
Convenience class for handling blocks.static class
OpusBlockHelper.BlockDefinition
Container class for Opus block definitions in the header.static class
OpusBlockHelper.CommandlineData
Encapsulates and parses a commandline string.
-
Field Summary
Fields Modifier and Type Field Description static byte[]
APF
the APF character sequence.static byte[]
APT
the APT character sequence.static byte[]
AQM
the AQM character sequence.static int
BLOCK_DEFINITION_LENGTH
the block definition length (type, length, offset).static int
BLOCK_OFFSET
the offset for block definitions in the header.static int
BLOCKTYPE_DUMMY
the dummy block type (???).static int
BLOCKTYPE_INCREMENT_DATA_TO_DPF
increment from data to DPF block type.static int
BLOCKTYPE_MAIN_MASK
the mask for the block type of the main spectrum.static int
BLOCKTYPE_SPEC_MASK
the mask for the block type of the main spectrum.static int
BLOCKTYPE_TEXT
the text block type.static byte[]
CNM
the CNM character sequence.static byte[]
CSF
the CSF character sequence.static byte[]
DPF
the DPF character sequence.static byte[]
END
the END character sequence.static byte[]
FXV
the FXV character sequence.static int
HEADER_LENGTH
maximum length of header (made up value!).static byte[]
INS
the INS character sequence.static String
KEY_SAMPLEID
the key for the sample ID.static String
KEY_SAMPLEID2
the key for the sample ID (2).static String
KEYWORD_CMDLINE
the command line keyword.static byte[]
LXV
the LXV character sequence.static byte[]
NPT
the NPT character sequence.static String
OPERATION_MEASURESAMPLE
the operation containing the sample ID.static byte[]
PLF
the PLF character sequence.static String
TEXT_SEPARATOR
the text separator.
-
Constructor Summary
Constructors Constructor Description OpusBlockHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
byteToUnsignedByte(byte b)
Convert byte to unsigned byte.static int
findID(byte[] buf, byte[] id, int start)
Locates the first occurrence of the specified ID in the buffer after the starting position.static Double
getDouble(byte[] buf, int offset)
Returns the double with the given ID.static long
getLong(byte[] buf, int offset)
Returns the long at the specified offset.static String
getText(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
-
-