home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
linuxmafia.com 2016
/
linuxmafia.com.tar
/
linuxmafia.com
/
pub
/
palmos
/
astro-src-2.1.0beta.tar.gz
/
astro-src-2.1.0beta.tar
/
astro-src-2.1.0beta
/
java
/
AstroRecord.java
< prev
next >
Wrap
Text File
|
2000-08-13
|
2KB
|
67 lines
import palmutils.pdb.*;
import java.io.*;
public class AstroRecord extends PDBElement
{
public static final int DESCRIPTIONSIZE = 32;
public static final int MAGNITUDESIZE = 5;
public static final int SIZESIZE = 9;
String description; // must be less than 32 letters (32 bytes)
short raH, raM, raS; // right ascension in hours, minutes, seconds. (6 bytes)
short decD, decM, decS; // declination in degrees, minutes, seconds. (6 bytes)
String magnitude; // must be less than 5 characters (5 bytes)
String size; // must be less than 9 characters (9 bytes)
public String toString()
{
return "["+description+": ("+raH+":"+raM+":"+raS+"),("+
decD+":"+decM+":"+decS+"),"+magnitude+","+size+"]"+
"{"+getSize()+"}";
}
public int getSize()
{
return ((description.length() < DESCRIPTIONSIZE)?(description.length() + 1):DESCRIPTIONSIZE)
+ 12 // short fields
+ ((magnitude.length() < MAGNITUDESIZE)?(magnitude.length() + 1):MAGNITUDESIZE)
+ ((size.length() < SIZESIZE)?(size.length() + 1):SIZESIZE);
}
public void write(DataOutput out) throws IOException
{
writePackedString(out,description,32);
out.writeShort(raH);
out.writeShort(raM);
out.writeShort(raS);
out.writeShort(decD);
out.writeShort(decM);
out.writeShort(decS);
writePackedString(out,magnitude,5);
writePackedString(out,size,9);
}
public void read(DataInput in) throws IOException
{
description = readPackedString(in,32);
raH = in.readShort();
raM = in.readShort();
raS = in.readShort();
decD = in.readShort();
decM = in.readShort();
decS = in.readShort();
magnitude = readPackedString(in,5);
size = readPackedString(in,9);
}
public AstroRecord()
{}
public AstroRecord(DataInput in) throws IOException
{
read(in);
}
}