com.garmin.fit
Class Decode

java.lang.Object
  extended by com.garmin.fit.Decode

public class Decode
extends java.lang.Object

Decodes binary to java objects.


Nested Class Summary
static class Decode.RETURN
           
 
Constructor Summary
Decode()
           
 
Method Summary
 void addListener(DeveloperFieldDescriptionListener listener)
           
 void addListener(MesgDefinitionListener mesgDefinitionListener)
           
 void addListener(MesgListener mesgListener)
           
 boolean bytesAvailable(java.io.InputStream input)
           
 boolean checkFileIntegrity(java.io.InputStream in)
          Reads the FIT binary file header and crc to check compatibility and integrity.
protected  void expandComponents(Field containingField, java.util.ArrayList<FieldComponent> componentList)
           
 boolean getInvalidFileDataSize()
          Gets the property that indicates that the file has an invalid data size
 Mesg getMesg()
           
 void incompleteStream()
          Override the default read behaviour allowing decode of partial streams.
 boolean isFileFit(java.io.InputStream in)
          Reads the header to determine if the file is FIT.
 void nextFile()
           
 void pause()
           
 Decode.RETURN read(byte data)
           
 boolean read(java.io.InputStream in)
           
 boolean read(java.io.InputStream in, MesgListener mesgListener)
          Reads a FIT binary file.
 boolean read(java.io.InputStream in, MesgListener mesgListener, MesgDefinitionListener mesgDefListener)
          Reads a FIT binary file.
 boolean resume()
          Resumes reading the file.
 void setInvalidFileDataSize(boolean value)
          Sets the Invalid Data size Property (so that it can be reset)
 void setSystemTimeOffset(long systemTimeOffset)
           
 void showInvalidValues()
          Allow for invalid values in messages.
 void skipHeader()
          Override the default read behaviour by skipping header decode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Decode

public Decode()
Method Detail

getInvalidFileDataSize

public boolean getInvalidFileDataSize()
Gets the property that indicates that the file has an invalid data size

Returns:
true if file has an invalid data size

setInvalidFileDataSize

public void setInvalidFileDataSize(boolean value)
Sets the Invalid Data size Property (so that it can be reset)

Parameters:
value - boolean value to set

nextFile

public void nextFile()

addListener

public void addListener(MesgListener mesgListener)

addListener

public void addListener(MesgDefinitionListener mesgDefinitionListener)

addListener

public void addListener(DeveloperFieldDescriptionListener listener)

setSystemTimeOffset

public void setSystemTimeOffset(long systemTimeOffset)

skipHeader

public void skipHeader()
Override the default read behaviour by skipping header decode. CRC checking is not possible since the datasize is unknown. Decode continues until EOF is encountered or a decode error occurs. May only be called prior to calling read(). Can be combined with incompleteStream() option.


incompleteStream

public void incompleteStream()
Override the default read behaviour allowing decode of partial streams. If EOF is encountered no exception is raised. Caller may choose to call resume() possibly after more bytes have arrived in the stream. May only be set prior to first calling read().


showInvalidValues

public void showInvalidValues()
Allow for invalid values in messages. Can override setting implied by Fit.ENABLE_LEGACY_BEHAVIOUR. Should only be used by CSV tool to allow for override at the application level. If this behaviour is desired by default, Fit.ENABLE_LEGACY_BEHAVIOUR should be modified instead. Can only be called before calling resume().


read

public boolean read(java.io.InputStream in,
                    MesgListener mesgListener,
                    MesgDefinitionListener mesgDefListener)
Reads a FIT binary file.

Parameters:
in - file input stream
mesgListener - message listener
mesgDefListener - message definition listener
Returns:
true if finished reading file

read

public boolean read(java.io.InputStream in,
                    MesgListener mesgListener)
Reads a FIT binary file.

Parameters:
in - file input stream
mesgListener - message listener
Returns:
true if finished reading file

read

public boolean read(java.io.InputStream in)

pause

public void pause()

resume

public boolean resume()
Resumes reading the file.

Returns:
true if finished reading file

isFileFit

public boolean isFileFit(java.io.InputStream in)
Reads the header to determine if the file is FIT.

Parameters:
in - file input stream
Returns:
true if file is FIT

checkFileIntegrity

public boolean checkFileIntegrity(java.io.InputStream in)
Reads the FIT binary file header and crc to check compatibility and integrity.

Parameters:
in - file input stream
Returns:
true if file is ok (not corrupt)

read

public Decode.RETURN read(byte data)

expandComponents

protected void expandComponents(Field containingField,
                                java.util.ArrayList<FieldComponent> componentList)

getMesg

public Mesg getMesg()

bytesAvailable

public boolean bytesAvailable(java.io.InputStream input)
                       throws java.io.IOException
Throws:
java.io.IOException