edu.nrao.sss.measure
Class AngularVelocity

java.lang.Object
  extended by edu.nrao.sss.measure.AngularVelocity
All Implemented Interfaces:
Cloneable, Comparable<AngularVelocity>

public class AngularVelocity
extends Object
implements Cloneable, Comparable<AngularVelocity>

A measure of angular velocity.

Version Info:

$Revision: 1816 $
$Date: 2008-12-23 10:21:00 -0700 (Tue, 23 Dec 2008) $
$Author: dharland $

Since:
2006-05-30
Author:
David M. Harland

Constructor Summary
AngularVelocity()
          Creates a new angular velocity of zero milliarcseconds per year.
AngularVelocity(BigDecimal masPerYear)
          Creates a new angular velocity of masPerYear milliarcseconds per year.
AngularVelocity(BigDecimal magnitude, AngularVelocityUnits units)
          Creates a new angular velocity with the given magnitude and units.
AngularVelocity(String masPerYear)
          Creates a new angular velocity of masPerYear milliarcseconds per year.
AngularVelocity(String magnitude, AngularVelocityUnits units)
          Creates a new angular velocity with the given magnitude and units.
 
Method Summary
 AngularVelocity add(AngularVelocity other)
          Adds other angular velocity to this one.
 AngularVelocity clone()
          Returns a angular velocity that is equal to this one.
 int compareTo(AngularVelocity otherDist)
          Compares this angular velocity with the otherDist for order.
 AngularVelocity convertTo(AngularVelocityUnits newUnits)
          Converts this measure of angular velocity to the new units.
 boolean equals(Object o)
          Returns true if o is equal to this angular velocity.
 AngularVelocityUnits getUnits()
          Returns the units of this angular velocity.
 BigDecimal getValue()
          Returns the magnitude of this angular velocity.
 int hashCode()
          Returns a hash code value for this angular velocity.
 boolean isInDefaultState()
          Returns true if this angular velocity is in its default state, no matter how it got there.
 boolean isInfinite()
          Returns true if the magnitude of this frequency approaches infinity.
static AngularVelocity parse(String velocityString)
          Returns a new velocity based on velocityString.
 void reset()
          Resets this angular velocity so that it is equal to an angular velocity created via the no-argument constructor.
 void set(BigDecimal value, AngularVelocityUnits units)
          Sets the magnitude and units of this angular velocity.
 void set(String velocityText)
          Sets the value and units of this velocity based on velocityText.
 void set(String value, AngularVelocityUnits units)
          Sets the magnitude and units of this angular velocity.
 void setUnits(AngularVelocityUnits newUnits)
          Sets the units of this angular velocity to newUnits.
 void setValue(BigDecimal newValue)
          Sets the magnitude of this angular velocity to newValue.
 void setValue(String newValue)
          Sets the magnitude of this angular velocity to newValue.
 AngularVelocity subtract(AngularVelocity other)
          Subtracts other angular velocity from this one.
 String toString()
          Returns a text representation of this angular velocity.
 BigDecimal toUnits(AngularVelocityUnits otherUnits)
          Returns the magnitude of this angular velocity in otherUnits.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AngularVelocity

public AngularVelocity()
Creates a new angular velocity of zero milliarcseconds per year.


AngularVelocity

public AngularVelocity(BigDecimal masPerYear)
Creates a new angular velocity of masPerYear milliarcseconds per year.


AngularVelocity

public AngularVelocity(String masPerYear)
Creates a new angular velocity of masPerYear milliarcseconds per year.


AngularVelocity

public AngularVelocity(BigDecimal magnitude,
                       AngularVelocityUnits units)
Creates a new angular velocity with the given magnitude and units.


AngularVelocity

public AngularVelocity(String magnitude,
                       AngularVelocityUnits units)
Creates a new angular velocity with the given magnitude and units.

Method Detail

reset

public void reset()
Resets this angular velocity so that it is equal to an angular velocity created via the no-argument constructor.


getValue

public BigDecimal getValue()
Returns the magnitude of this angular velocity.

Returns:
the magnitude of this angular velocity.

getUnits

public AngularVelocityUnits getUnits()
Returns the units of this angular velocity.

Returns:
the units of this angular velocity.

set

public void set(String velocityText)
Sets the value and units of this velocity based on velocityText. See parse(String) for the expected format of velocityText.

If the parsing fails, this velocity will be kept in its current state.

Parameters:
velocityText - a string that will be converted into a velocity.
Throws:
IllegalArgumentException - if velocityText is not in the expected form.
Since:
2008-09-22

set

public final void set(BigDecimal value,
                      AngularVelocityUnits units)
Sets the magnitude and units of this angular velocity.

Parameters:
value - the new magnitude for this angular velocity.
units - the new units for this angular velocity.

set

public final void set(String value,
                      AngularVelocityUnits units)
Sets the magnitude and units of this angular velocity.

Parameters:
value - the new magnitude for this angular velocity.
units - the new units for this angular velocity.

setValue

public final void setValue(BigDecimal newValue)
Sets the magnitude of this angular velocity to newValue.

Note that the units of this angular velocity are unaffected by this method.

Parameters:
newValue - the new magnitude for this angular velocity.

setValue

public final void setValue(String newValue)
Sets the magnitude of this angular velocity to newValue.

Note that the units of this angular velocity are unaffected by this method.

Parameters:
newValue - the new magnitude for this angular velocity.
Throws:
NumberFormatException - if newValue is null.

setUnits

public final void setUnits(AngularVelocityUnits newUnits)
Sets the units of this angular velocity to newUnits.

Note that the value of this angular velocity is unaffected by this method. Contrast this with convertTo(AngularVelocityUnits).

Parameters:
newUnits - the new units for this angular velocity. If newUnits is null it will be replaced with a non-null default type.

isInDefaultState

public boolean isInDefaultState()
Returns true if this angular velocity is in its default state, no matter how it got there.

An angular velocity is in its default state if both its value and its units are the same as those of an angular velocity newly created via the no-argument constructor. An angular velocity whose most recent update came via the reset method is also in its default state.

Returns:
true if this angular velocity is in its default state.

isInfinite

public boolean isInfinite()
Returns true if the magnitude of this frequency approaches infinity.

Returns:
true if the magnitude of this frequency approaches infinity.

convertTo

public AngularVelocity convertTo(AngularVelocityUnits newUnits)
Converts this measure of angular velocity to the new units.

After this method is complete this angular velocity will have units of newUnits and its value will have been converted accordingly.

Parameters:
newUnits - the new units for this angular velocity. If newUnits is null an IllegalArgumentException will be thrown.
Returns:
this angular velocity. The reason for this return type is to allow code of this nature: double kilometers = myAngularVelocity.convertTo(AngularVelocityUnits.KILOMETERS).getValue();

toUnits

public BigDecimal toUnits(AngularVelocityUnits otherUnits)
Returns the magnitude of this angular velocity in otherUnits.

Note that this method does not alter the state of this angular velocity. Contrast this with convertTo(AngularVelocityUnits).

Parameters:
otherUnits - the units in which to express this angular velocity's magnitude.
Returns:
this angular velocity's value converted to otherUnits.
Throws:
IllegalArgumentException - if otherUnits is null.

add

public AngularVelocity add(AngularVelocity other)
Adds other angular velocity to this one.

Parameters:
other - the angular velocity to be added to this angular velocity.
Returns:
this angular velocity, after the addition.

subtract

public AngularVelocity subtract(AngularVelocity other)
Subtracts other angular velocity from this one.

Parameters:
other - the angular velocity to be subtracted from this angular velocity.
Returns:
this angular velocity, after the subtraction.

parse

public static AngularVelocity parse(String velocityString)
Returns a new velocity based on velocityString.

Valid Formats
Let R be the text representation of a real number.
Let w represent zero or more whitespace characters.
Let S be a valid units symbol.

Format One: wRw. The given number will be defined to be in units of mas/yr.

Format Two: wRwSw.

If velocityString is null or the empty string (""), the returned velocity will be equal to one created via the no-argument constructor.

Parameters:
velocityString - a string that will be converted into a velocity.
Returns:
a new velocity.
Throws:
IllegalArgumentException - if velocityString is not in the expected form.

toString

public String toString()
Returns a text representation of this angular velocity.

Overrides:
toString in class Object

clone

public AngularVelocity clone()
Returns a angular velocity that is equal to this one.

Overrides:
clone in class Object

equals

public boolean equals(Object o)
Returns true if o is equal to this angular velocity.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for this angular velocity.

Overrides:
hashCode in class Object

compareTo

public int compareTo(AngularVelocity otherDist)
Compares this angular velocity with the otherDist for order.

Specified by:
compareTo in interface Comparable<AngularVelocity>


Copyright © 2009. All Rights Reserved.