Show GPSResult.java syntax highlighted
/*
* Copyright (c) 2005
* Helsinki Institute of Physics
* see LICENSE file for details
*
* GPSResult.java
* Created on Aug 19, 2003
*/
package fi.hip.gb.bluetooth;
import fi.hip.gb.bluetooth.util.Properties;
/**
* Minimal result container for one job. Contains the actual result and
* metadata about the result.
*
* @author Juho Karppinen
*/
public class GPSResult {
/** result is gps */
public static final int GPS_TYPE = 0;
/** name of the result file*/
private String name;
/** type of the data */
private int type = -1;
/** additional description about the result */
private String description;
/** size of the result */
private int size;
/** internal data about the result, contains key/value pairs */
private Properties flags = new Properties();
/** actual payload data */
private byte[] data;
/** own record ID */
private int recordID = -1;
/** name of the record store for results */
public final static String STORAGE_NAME = "results";
/**
* Default empty constructor
*/
public GPSResult() {
}
/**
* Reads result content
* @return content of the result
*/
public String readContent() {
return new String(this.data);
}
/**
* Reads result content as bytes
* @return content of the result in bytes
*/
public byte[] readBytes() {
return this.data;
}
/**
* Write the payload inside result object
* @param data as string
*/
public void writeContent(String data) {
this.data = data.getBytes();
}
/**
* Write the payload inside result object
* @param data as bytes
*/
public void writeBytes(byte[] data) {
this.data = data;
}
/**
* Gets the name of the result.
* When loaded from the server, the name is filename on the disk.
* @return filename of the file
*/
public String getName() {
return this.name;
}
/**
* Sets the name of the result.
* When loaded from the server, the name is filename on the disk.
* @param resultName name for the result
*/
public void setName(String resultName) {
this.name = resultName;
}
/**
* Gets the type of result data
* @return type as integer number
*/
public int getType() {
return this.type;
}
/**
* Sets the type of result data
* @param resultType as integer number
*/
public void setType(int resultType) {
this.type = resultType;
}
/**
* Gets additional description about the result
* @return addtional informations
*/
public String getDescription() {
return this.description;
}
/**
* Gets the size of the result
* @return result size in bytes
*/
public int getSize() {
return this.size;
}
/**
* Gets the size of the actual payload stored inside the object.
* @return result size in bytes
*/
public int getPayloadSize() {
return this.data.length;
}
/**
* Gets flags for this result inside Properties hashtable
* @return flags
*/
public Properties getFlags() {
return this.flags;
}
/**
* Sets flags for this result inside Properties hashtable
* @param flags
*/
public void setFlags(Properties flags) {
this.flags = flags;
}
/**
* Prints some debugging information
* @return String representation of the object
*/
public String toString() {
return
"name: " + this.name + "\n" +
"description: " + this.description + "\n" +
"type: " + this.type + "\n" +
"flags: " + this.flags.toString() + "\n" +
"data: " + this.data;
}
}
See more files for this project here