GarminDevice.js

Summary

Garmin.Device A place-holder for Garmin device information.
Source: Hosted Distribution   Source Control


Version: 1.0

Author: Michael Bina michael.bina.at.garmin.com


Class Summary
Garmin.Device Garmin.Device A place-holder for Garmin device information.
Garmin.DeviceDataType Garmin.DeviceDataType A place-holder for Garmin Device Data Type information

if (Garmin == undefined) var Garmin = {};
/**
 * Copyright © 2007 Garmin Ltd. or its subsidiaries.
 *
 * Licensed under the Apache License, Version 2.0 (the 'License')
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * @fileoverview Garmin.Device A place-holder for Garmin device information. <br/>
 * Source: 
 * <a href="http://developer.garmin.com/web/communicator-api/garmin/device/GarminDevice.js">Hosted Distribution</a> &nbsp;
 * <a href="https://svn.garmindeveloper.com/web/trunk/communicator/communicator-api/src/main/webapp/garmin/device/GarminDevice.js">Source Control</a><br/>
 * 
 * @author Michael Bina michael.bina.at.garmin.com
 * @version 1.0
 */
/**
 * @class Garmin.Device
 * A place-holder for Garmin device information.
 *
 * @constructor 
 * @param {String} displayName for the device
 * @param {Number} number of the model
 **/
Garmin.Device = function(displayName, number){}; //just here for jsdoc
Garmin.Device = Class.create();
Garmin.Device.prototype = {

	initialize: function(displayName, number) {
	    this.displayName = displayName;
	    this.number = number;
	    
	    this.partNumber = null;
	    this.softwareVersion = null;
	    this.description = null;
	    this.id = null;
	    
	    this.dataTypes = new Hash({});
	},
	
	/**
	 * @type String
	 * @return The display name of this device
	 * @member Garmin.Device
	 **/
	getDisplayName: function() {
		return this.displayName;
	},
	
	/**
	 * @type Number
	 * @return The device number that the plug-in uses to identify this device
	 * @member Garmin.Device
	 **/
	getNumber: function() {
		return this.number;
	},
	
	/**
	 * @member Garmin.Device
	 **/
	setPartNumber: function(partNumber) {
		this.partNumber = partNumber;
	},

	/**
	 * @type String
	 * @return The part number of the device
	 * @member Garmin.Device
	 **/
	getPartNumber: function() {
		return this.partNumber;
	},

	/**
	 *
	 * @member Garmin.Device
	 **/
	setSoftwareVersion: function(softwareVersion) {
		this.softwareVersion = softwareVersion;
	},

	/**
	 * @type String
	 * @return The software version currently on the device
	 * @member Garmin.Device
	 **/
	getSoftwareVersion: function() {
		return this.softwareVersion;
	},

	/**
	 *
	 * @member Garmin.Device
	 **/
	setDescription: function(description) {
		this.description = description;
	},

	/**
	 * @type String
	 * @return A description of the device
	 * @member Garmin.Device
	 **/
	getDescription: function() {
		return this.description;
	},

	/**
	 *
	 * @member Garmin.Device
	 **/
	setId: function(id) {
		this.id = id;
	},

	/**
	 * @type Number
	 * @return The device id
	 * @member Garmin.Device
	 **/
	getId: function() {
		return this.id;
	},
	
	/**
	 * Adds a data type to the list of data types supported by this device
	 * @param dataType A DeviceDataType object containing information about the data type being added
	 * @member Garmin.Device
	 */
	addDeviceDataType: function(dataType) {
		var newDataType = new Hash({});
		newDataType[dataType.getFileExtension().toLowerCase()] = dataType;
		this.dataTypes.merge(newDataType);	
	},

	/**
	 * Returns a specific DeviceDataType object
	 * @type Garmin.DeviceDataType
	 * @return The DeviceDataType object containing the specified extension
	 * @param extension The file extension of the data type you are trying to get
	 * @member Garmin.Device
	 */	
	getDeviceDataType: function(extension) {
		return this.dataTypes[extension.toLowerCase()];
	},

	/**
	 * @type Hash
	 * @return The hash containing all DeviceDataType objects
	 * @member Garmin.Device
	 */	
	getDeviceDataTypes: function() {
		return this.dataTypes;
	},

	/**	 
	 * @type Boolean
	 * @return True if the device has read support for the file type
	 * @param extension The extension of the file type you are checking for support
	 * @member Garmin.Device
	 */	
	supportDeviceDataTypeRead: function(extension) {
		var dataType = this.dataTypes[extension.toLowerCase()];
		if (dataType != null && dataType.hasReadAccess()) {
			return true;
		} else {
			return false;
		}	
	},
	
	/**
	 * @type Boolean
	 * @return True if the device has write support for the file type 
	 * @param extension The extension of the file type you are checking for support
	 * @member Garmin.Device
	 */		
	supportDeviceDataTypeWrite: function(extension) {
		var dataType = this.dataTypes[extension.toLowerCase()];
		if (dataType != null && dataType.hasWriteAccess()) {
			return true;
		} else {
			return false;
		}			
	}
};

/**
 * @class Garmin.DeviceDataType
 * A place-holder for Garmin Device Data Type information
 *
 * @constructor 
 * @param {displayName} displayName for the data type
 * @param {fileExtension} file extension for the data type
 **/
Garmin.DeviceDataType = function(displayName, fileExtension){}; //just here for jsdoc
Garmin.DeviceDataType = Class.create();
Garmin.DeviceDataType.prototype = {
	
	initialize: function(displayName, fileExtension) {
		this.displayName = displayName;
		this.fileExtension = fileExtension;
		this.readAccess = false;
		this.writeAccess = false;
	},
	
	/**
	 * @type String
	 * @return The display name of this data type
	 * @member Garmin.DeviceDataType
	 **/
	getDisplayName: function() {
		return this.displayName;
	},
	
	/**
	 * @type String
	 * @return The file extension of this data type
	 * @member Garmin.DeviceDataType
	 **/
	getFileExtension: function() {
		return this.fileExtension;
	},
	
	/**
	 * @param readAccess True == has read access
	 * @member Garmin.DeviceDataType
	 */
	setReadAccess: function(readAccess) {
		this.readAccess = readAccess;
	},
	
	/**
	 * @type Boolean
	 * @return The value indicating if the device supports read access for this file type
	 * @member Garmin.DeviceDataType
	 **/
	hasReadAccess: function() {
		return this.readAccess;
	},
	
	/**
	 * @param writeAccess True == has write access
	 * @member Garmin.DeviceDataType
	 */	
	setWriteAccess: function(writeAccess) {
		this.writeAccess = writeAccess;
	},
	
	/**
	 * @type Boolean
	 * @return The value indicating if the device supports write access for this file type
	 * @member Garmin.DeviceDataType
	 **/
	hasWriteAccess: function() {
		return this.writeAccess;
	}	
};


Documentation generated by JSDoc on Tue May 29 09:15:02 2007