com.garmin.fit
Class BufferEncoder

java.lang.Object
  extended by com.garmin.fit.BufferEncoder
All Implemented Interfaces:
MesgDefinitionListener, MesgListener

public class BufferEncoder
extends java.lang.Object
implements MesgListener, MesgDefinitionListener

Encodes message objects into a FIT binary file buffer.


Constructor Summary
BufferEncoder()
          Deprecated. Encoder now supports encoding files of differing protocol versions, use BufferEncoder(Fit.ProtocolVersion) to ensure the encoder is validating your files correctly
BufferEncoder(Fit.ProtocolVersion version)
          Constructs a new File Encoder for specified file.
 
Method Summary
 byte[] close()
          Updates the data size in the file header, writes the CRC, and returns the buffer.
 void onMesg(Mesg mesg)
          MesgListener interface.
 void onMesgDefinition(MesgDefinition mesgDefinition)
          MesgDefinitionListener interface.
 void open()
          Resets the output stream and writes the file header.
 void write(java.util.List<Mesg> mesgs)
          Writes a list of messages to the file.
 void write(Mesg mesg)
          Writes a message to the buffer.
 void write(MesgDefinition mesgDefinition)
          Writes a message definition to the buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferEncoder

@Deprecated
public BufferEncoder()
Deprecated. Encoder now supports encoding files of differing protocol versions, use BufferEncoder(Fit.ProtocolVersion) to ensure the encoder is validating your files correctly

Constructs a new BufferEncoder. Forces ProtocolVersion.V1_0


BufferEncoder

public BufferEncoder(Fit.ProtocolVersion version)
Constructs a new File Encoder for specified file.

Parameters:
version - Fit Protocol Version to use when writing files
Method Detail

open

public void open()
Resets the output stream and writes the file header.


onMesg

public void onMesg(Mesg mesg)
MesgListener interface.

Specified by:
onMesg in interface MesgListener

onMesgDefinition

public void onMesgDefinition(MesgDefinition mesgDefinition)
MesgDefinitionListener interface.

Specified by:
onMesgDefinition in interface MesgDefinitionListener

write

public void write(MesgDefinition mesgDefinition)
Writes a message definition to the buffer.

Parameters:
mesgDefinition - message definition object to write

write

public void write(Mesg mesg)
Writes a message to the buffer. Automatically writes message definition if required.

Parameters:
mesg - message object to write

write

public void write(java.util.List<Mesg> mesgs)
Writes a list of messages to the file.

Parameters:
mesgs - list message objects to write

close

public byte[] close()
Updates the data size in the file header, writes the CRC, and returns the buffer. The output stream buffer is discarded and re-initialized to start encoding a new file.

Returns:
file buffer