t.21.120.2.source-code.DeveloperFieldDescription Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fit Show documentation
Show all versions of fit Show documentation
The Official Garmin FIT SDK
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2023 Garmin International, Inc.
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
// may not use this file except in compliance with the Flexible and Interoperable Data
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.120Release
// Tag = production/release/21.120.00-0-g2d77811
/////////////////////////////////////////////////////////////////////////////////////////////
package com.garmin.fit;
import java.nio.ByteBuffer;
import java.util.UUID;
/**
* Description of a Developer Field
*/
public class DeveloperFieldDescription {
private final FieldDescriptionMesg fieldDescription;
private final DeveloperDataIdMesg developerId;
/**
* Constructs a new Developer Field Description
* @param developerId Developer Id Message for the field. Can't be null
* @param fieldDescription Field Description Message for the field. Can't be null
*/
DeveloperFieldDescription(DeveloperDataIdMesg developerId, FieldDescriptionMesg fieldDescription) {
this.developerId = developerId;
this.fieldDescription = fieldDescription;
}
/**
* Retrieves the Application Version of the generating Field
* @return null
if there is no version encoded in the file
*/
public long getApplicationVersion() {
Long applicationVer = developerId.getApplicationVersion();
if(applicationVer == null) {
return (long)0xFFFF;
}
return applicationVer.longValue();
}
/**
* Retrieves the Application Id of the generating Field
* @return Application Id or null
if there is no valid Application Id for the description
*/
public UUID getApplicationId() {
Byte[] appId = developerId.getApplicationId();
if(appId == null || appId.length != 16) {
return null;
}
byte[] primitiveId = new byte[appId.length];
for(byte i = 0; i < appId.length; i++) {
if(appId[i] != null) {
primitiveId[i] = appId[i];
} else {
primitiveId[i] = (byte)0xFF;
}
}
ByteBuffer bb = ByteBuffer.wrap(primitiveId);
long high = bb.getLong();
long low = bb.getLong();
return new UUID(high, low);
}
/**
* Retrieves the Field Definition Number of the generating Field
* @return Field Definition Number
*/
public short getFieldDefinitionNumber() {
Short num = fieldDescription.getFieldDefinitionNumber();
if(num == null) {
return (short)0xFF;
}
return num.shortValue();
}
}