public class Decoder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected com.garmin.fit.Accumulator |
accumulator |
protected int |
CompressedHeaderMask |
protected int |
decoderMesgIndex |
protected int |
DevDataMask |
protected java.util.ArrayList<DeveloperFieldDescriptionListener> |
devFieldDescListeners |
protected byte[] |
fieldData |
protected MesgDefinition[] |
localMesgDefs |
protected int |
LocalMesgNumMask |
protected int |
MesgDefinitionMask |
protected java.util.ArrayList<MesgDefinitionListener> |
mesgDefListeners |
protected int |
MesgHeaderMask |
protected java.util.ArrayList<MesgListener> |
mesgListeners |
protected ByteArrayDataInputStream |
stream |
Constructor and Description |
---|
Decoder(byte[] bytes) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(DeveloperFieldDescriptionListener listener) |
void |
addListener(MesgDefinitionListener mesgDefinitionListener) |
void |
addListener(MesgListener mesgListener)
Add a MesgListener observer
|
static boolean |
checkIntegrity(byte[] bytes)
Reads the FIT file header from the input stream and checks that the input
is a valid .FIT file and checks the integrity file.
|
protected void |
decodeCompressedTimestampDataMessage() |
protected void |
expandComponents(Mesg mesg,
Field containingField,
java.util.ArrayList<FieldComponent> componentList) |
protected void |
flipFieldDataByteOrder(int typeSize,
int elements) |
protected long |
getCrcValue() |
static boolean |
isFIT(byte[] bytes)
Reads the FIT file header from the input stream and checks that the input
is a valid .FIT file.
|
static boolean |
isFIT(java.io.ByteArrayInputStream stream)
Reads the FIT file header from the input stream and checks that the input
is a valid .FIT file.
|
void |
read()
Reads a .FIT file and passes messages to the listeners
|
int |
readByte() |
int |
readBytes(byte[] bytes,
int off,
int len) |
protected byte[] |
readHeader() |
protected static byte[] |
readHeader(java.io.InputStream stream)
Reads the FIT file header from the input stream and returns the byte array containing the header.
|
int |
readUShort() |
protected void |
resetCrc() |
protected final int CompressedHeaderMask
protected final int MesgDefinitionMask
protected final int DevDataMask
protected final int MesgHeaderMask
protected final int LocalMesgNumMask
protected final MesgDefinition[] localMesgDefs
protected final byte[] fieldData
protected final java.util.ArrayList<MesgListener> mesgListeners
protected final com.garmin.fit.Accumulator accumulator
protected ByteArrayDataInputStream stream
protected java.util.ArrayList<MesgDefinitionListener> mesgDefListeners
protected java.util.ArrayList<DeveloperFieldDescriptionListener> devFieldDescListeners
protected int decoderMesgIndex
public void read() throws java.lang.Exception
java.lang.Exception
- if an error occurs while readingpublic static boolean isFIT(java.io.ByteArrayInputStream stream)
stream
- representing the FIT file to be checkedpublic static boolean isFIT(byte[] bytes)
bytes
- representing the FIT file to be checkedpublic static boolean checkIntegrity(byte[] bytes)
bytes
- representing the FIT file to be checkedprotected static byte[] readHeader(java.io.InputStream stream) throws java.lang.Exception
stream
- representing the FIT file to read the header fromjava.lang.Exception
- if an error occurs while trying to read the headerFitRuntimeException
- if the file header is invalidprotected byte[] readHeader() throws java.lang.Exception
java.lang.Exception
public int readByte()
public int readUShort()
public int readBytes(byte[] bytes, int off, int len)
protected long getCrcValue()
protected void resetCrc()
public void addListener(MesgListener mesgListener)
addListener
in interface MesgSource
mesgListener
- to add as an observerpublic void addListener(MesgDefinitionListener mesgDefinitionListener)
public void addListener(DeveloperFieldDescriptionListener listener)
protected void expandComponents(Mesg mesg, Field containingField, java.util.ArrayList<FieldComponent> componentList)
protected void decodeCompressedTimestampDataMessage() throws java.lang.Exception
java.lang.Exception
protected void flipFieldDataByteOrder(int typeSize, int elements)