edu.iris.Fissures.seed.container
Class Btime

java.lang.Object
  extended by edu.iris.Fissures.seed.container.SeedObject
      extended by edu.iris.Fissures.seed.container.Btime
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class Btime
extends SeedObject

Structure for storing SEED time elements. Acts as a container for the BTIME structure. Capable of String and Binary operations.

Version:
01/14/2008
Author:
Robert Casey, IRIS DMC
See Also:
Serialized Form

Nested Class Summary
static class Btime.MonthDayYear
          Month, day and year.
 
Constructor Summary
Btime()
          Construct object initialized to the current GMT time.
Btime(byte[] timeArr)
          Accept input BTIME array with automatic byte swap checking.
Btime(byte[] timeArr, boolean byteSwapFlag)
          Accept input BTIME array and indicated byte swap flag.
Btime(java.lang.String timeString)
          Create object using string value.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compare our value to the provided object, which needs to be a Btime object.
 long diffSeconds(Btime minusTime)
          Return time difference in seconds.
 boolean equals(Btime compareTime)
          Compare our object's time with the offered compareTime.
 byte[] getByteTime()
           
 byte[] getByteTime(boolean swapFlag)
          Return byte array consisting of SEED BTIME representation of time.
 int getDayOfYear()
           
 long getEpochTime()
          Return the number of seconds since January 1, 1970.
 java.lang.String getError()
          Return error messages regarding the reading of a time string as input.
 int getHour()
           
static java.lang.String getJulianDay(int year, int month, int day)
          Convert year, month, and day values to a year/julian day representation.
 int getLookupId()
          Return SeedObject lookup ID.
 int getMinute()
           
static java.lang.String getMonthDay(int year, int jday)
          Convert a year and julian day value to a year/month/day representation.
 Btime.MonthDayYear getMonthDayYear()
          Returns the month, day and year.
static Btime.MonthDayYear getMonthDayYear(int year, int jday)
          Returns the month, day and year.
 int getSecond()
           
 java.lang.String getStringTime()
          Get string representation of time.
 boolean getSwapFlag()
          Return the binary word swap flag.
 int getTenthMill()
           
 int getType()
          Return SeedObject type number.
 int getYear()
          private int year = 2500; private int jday = 1; private int hour = 0; private int min = 0; private int sec = 0; private int tenthMilli = 0;
 Btime projectTime(double tenThousandths)
          Return a new time value that is a projection from this object's current time.
 void setDayOfYear(int i)
           
 void setHour(int i)
           
 void setMinute(int i)
           
 void setSecond(int i)
           
 void setTenthMill(int i)
           
 void setYear(int i)
           
 java.lang.String toString()
          Get string representation of time.
protected  double ttConvert()
          Get ten-thousandths representation of time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Btime

public Btime()
      throws SeedInputException
Construct object initialized to the current GMT time.

Throws:
SeedInputException

Btime

public Btime(byte[] timeArr,
             boolean byteSwapFlag)
      throws SeedInputException
Accept input BTIME array and indicated byte swap flag.

Throws:
SeedInputException

Btime

public Btime(byte[] timeArr)
      throws SeedInputException
Accept input BTIME array with automatic byte swap checking.

Throws:
SeedInputException

Btime

public Btime(java.lang.String timeString)
      throws SeedInputException
Create object using string value. String format must be YYYY,DDD,HH:MM:SS.FFFF.

Throws:
SeedInputException
Method Detail

getType

public int getType()
Return SeedObject type number.

Specified by:
getType in class SeedObject

getLookupId

public int getLookupId()
Return SeedObject lookup ID.

Specified by:
getLookupId in class SeedObject

getByteTime

public byte[] getByteTime(boolean swapFlag)
Return byte array consisting of SEED BTIME representation of time.


getByteTime

public byte[] getByteTime()

getStringTime

public java.lang.String getStringTime()
Get string representation of time. Format is YYYY,DDD,HH:MM:SS.FFFF.


toString

public java.lang.String toString()
Get string representation of time. Same as getStringTime();

Specified by:
toString in class SeedObject

getEpochTime

public long getEpochTime()
Return the number of seconds since January 1, 1970. If the year is earlier than 1970, the result is a negative EpochTime.


equals

public boolean equals(Btime compareTime)
Compare our object's time with the offered compareTime. Return true if the two times are equal.


diffSeconds

public long diffSeconds(Btime minusTime)
Return time difference in seconds. Subtract minusTime from our time value and return the result in seconds. (return = ourTime - minusTime).


getSwapFlag

public boolean getSwapFlag()
Return the binary word swap flag. The flag applies to binary reads. The value is TRUE for VAX/8086 word order.


getError

public java.lang.String getError()
Return error messages regarding the reading of a time string as input.


compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compare our value to the provided object, which needs to be a Btime object. Override Comparable method in SeedObject in favor of comparing ten-thousandths of a second. Return an integer indicating the comparison relationship of this object to the object provided. If this object has an earlier time value the the parameter object, return -1. If the parameter object is earlier than this object, return 1. If equal, return 0.

Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class SeedObject
Throws:
java.lang.ClassCastException

projectTime

public Btime projectTime(double tenThousandths)
                  throws SeedInputException
Return a new time value that is a projection from this object's current time. Take the Btime structure and forward-project a new time that is the specified number of ten thousandths of seconds ahead. Return a new Btime with the projected value.

Throws:
SeedInputException

getMonthDayYear

public Btime.MonthDayYear getMonthDayYear()
Returns the month, day and year.

Returns:
the month, day and year.

getMonthDayYear

public static Btime.MonthDayYear getMonthDayYear(int year,
                                                 int jday)
Returns the month, day and year.

Parameters:
year - the year.
jday - the julian day.
Returns:
the month, day and year.

getMonthDay

public static java.lang.String getMonthDay(int year,
                                           int jday)
Convert a year and julian day value to a year/month/day representation. Calendar calculation is set to Lenient which may result in date conversion to proper values. Return string format is "YYYY/MM/DD".

Parameters:
year - the year.
jday - the julian day.
Returns:
a year/month/day representation.

getJulianDay

public static java.lang.String getJulianDay(int year,
                                            int month,
                                            int day)
Convert year, month, and day values to a year/julian day representation. Calendar calculation is set to Lenient, which may result in date conversion to proper values. Return string format is "YYYY/JJJ".


getYear

public int getYear()
private int year = 2500; private int jday = 1; private int hour = 0; private int min = 0; private int sec = 0; private int tenthMilli = 0;


getDayOfYear

public int getDayOfYear()

getHour

public int getHour()

getMinute

public int getMinute()

getSecond

public int getSecond()

getTenthMill

public int getTenthMill()

setYear

public void setYear(int i)

setDayOfYear

public void setDayOfYear(int i)

setHour

public void setHour(int i)

setMinute

public void setMinute(int i)

setSecond

public void setSecond(int i)

setTenthMill

public void setTenthMill(int i)

ttConvert

protected double ttConvert()
Get ten-thousandths representation of time. Convert contents of Btime structure to the number of ten thousandths of seconds it represents within that year. Made a protected method to allow comparison between Btime objects.