Package org.ka2ddo.yaac.ax25
Class Age
java.lang.Object
org.ka2ddo.yaac.ax25.Age
- All Implemented Interfaces:
Comparable<Age>
This class represents a message parameter (in milliseconds) in a form that can be
rendered easily on a GUI widget.
- Author:
- Andrew Pavlin, KA2DDO
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
Convenience constant for the number of milliseconds in a half hour. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Test if this Age is older than another Age.static Age[]
createAgeArray
(long startInterval, long maxDelta) Create an array of Age objects covering the specified span of time in human-like spacings.static Age[]
createAgeArray
(long startInterval, long maxDelta, int padToString) Create an array of Age objects covering the specified span of time in human-like spacings.boolean
Indicates whether some other object is "equal to" this one.long
getAge()
Get the delta time of this Age in milliseconds.int
Obtain the minimum number of characters to render an Age.int
hashCode()
Returns a hash code value for the object.static long
Parse an Age value from a String in the format that Ages are presented in.void
setPadToString
(int padToString) Set the minimum number of characters to render an Age.toString()
Display a human-friendly representation of this Age's time interval.toString
(boolean showBackwardsTime) Display a human-friendly representation of this Age's time interval.static String
toString
(long age) Display a delta time (in milliseconds) in a human friendly String.static String
toString
(long age, boolean showBackwardsTime) Display a delta time (in milliseconds) in a human friendly String.static String
toString
(long age, boolean showBackwardsTime, boolean spellOutUnits) Display a delta time (in milliseconds) in a human friendly String.static String
toString
(long age, boolean showBackwardsTime, boolean spellOutUnits, int padToString) Display a delta time (in milliseconds) in a human friendly String.
-
Field Details
-
HALF_HOUR_IN_MSEC
public static final long HALF_HOUR_IN_MSECConvenience constant for the number of milliseconds in a half hour.- See Also:
-
-
Constructor Details
-
Age
public Age(long millisecondsOfAge) Create an Age object with the specified number of milliseconds in its age.- Parameters:
millisecondsOfAge
- milliseconds of age
-
Age
Create an Age object from a string in the format that Ages are presented in.- Parameters:
val
- String to parse- Throws:
IllegalArgumentException
- if val can't be parsed
-
-
Method Details
-
parseAge
Parse an Age value from a String in the format that Ages are presented in.- Parameters:
val
- String to parse- Returns:
- parsed age in milliseconds
- Throws:
IllegalArgumentException
- if val can't be parsed
-
createAgeArray
Create an array of Age objects covering the specified span of time in human-like spacings.- Parameters:
startInterval
- the smallest time interval in millisecondsmaxDelta
- the largest time interval in milliseconds- Returns:
- Age array of intervals in the requested span
-
createAgeArray
Create an array of Age objects covering the specified span of time in human-like spacings.- Parameters:
startInterval
- the smallest time interval in millisecondsmaxDelta
- the largest time interval in millisecondspadToString
- int minimum number of characters in string formatting- Returns:
- Age array of intervals in the requested span
-
toString
Display a human-friendly representation of this Age's time interval. -
toString
Display a human-friendly representation of this Age's time interval.- Parameters:
showBackwardsTime
- if boolean true and age is negative, show it as absolute, otherwise report "???"- Returns:
- the Age in days, hours, minutes, and seconds.
-
toString
Display a delta time (in milliseconds) in a human friendly String.- Parameters:
age
- the delta time in milliseconds- Returns:
- the age in days, hours, minutes, and seconds.
-
toString
Display a delta time (in milliseconds) in a human friendly String.- Parameters:
age
- the delta time in millisecondsshowBackwardsTime
- if boolean true and age is negative, show it as absolute, otherwise report "???"- Returns:
- the age in days, hours, minutes, and seconds.
-
toString
Display a delta time (in milliseconds) in a human friendly String.- Parameters:
age
- the delta time in millisecondsshowBackwardsTime
- if boolean true and age is negative, show it as absolute, otherwise report "???"spellOutUnits
- boolean true if spelled-out localized words for time units should be used instead of single English-unit letters- Returns:
- the age in days, hours, minutes, and seconds.
-
toString
public static String toString(long age, boolean showBackwardsTime, boolean spellOutUnits, int padToString) Display a delta time (in milliseconds) in a human friendly String.- Parameters:
age
- the delta time in millisecondsshowBackwardsTime
- if boolean true and age is negative, show it as absolute, otherwise report "???"spellOutUnits
- boolean true if spelled-out localized words for time units should be used instead of single English-unit letterspadToString
- int minimum number of characters in formatted age- Returns:
- the age in days, hours, minutes, and seconds.
-
equals
Indicates whether some other object is "equal to" this one. -
hashCode
public int hashCode()Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided byjava.util.Hashtable
. -
compareTo
Test if this Age is older than another Age. Note that "permanent" Ages are older than non-permanent ages.- Specified by:
compareTo
in interfaceComparable<Age>
- Parameters:
o
- other Age object to compare to this one- Returns:
- -1 if this Age is older than the other Age, 0 if their ages are the same, or +1 if this Age is newer than the other Age
-
getAge
public long getAge()Get the delta time of this Age in milliseconds.- Returns:
- millisecond delta time of this Age
-
getPadToString
public int getPadToString()Obtain the minimum number of characters to render an Age. Note that some Ages may render longer than this if they have more characters.- Returns:
- int minimum character count
-
setPadToString
public void setPadToString(int padToString) Set the minimum number of characters to render an Age. Note that some Ages may render longer than this if they have more characters.- Parameters:
padToString
- int minimum character count
-