|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.measure.LinearVelocity
public class LinearVelocity
A measure of linear velocity.
Version Info:
$Revision: 1707 $ |
$Date $ |
$Author: dharland $ |
Constructor Summary | |
---|---|
LinearVelocity()
Creates a new linear velocity of zero kilometers per second. |
|
LinearVelocity(BigDecimal kms)
Creates a new velocity of kms kilometers per second. |
|
LinearVelocity(BigDecimal value,
LinearVelocityUnits units)
Creates a new linear velocity with the given magnitude and units. |
|
LinearVelocity(String kms)
Creates a new velocity of kms kilometers per second. |
|
LinearVelocity(String value,
LinearVelocityUnits units)
Creates a new linear velocity with the given magnitude and units. |
Method Summary | |
---|---|
LinearVelocity |
add(LinearVelocity other)
Adds other linear velocity to this one. |
LinearVelocity |
clone()
Returns a linear velocity that is equal to this one. |
int |
compareTo(LinearVelocity otherVel)
Compares this linear velocity with the otherVel for order. |
LinearVelocity |
convertTo(LinearVelocityUnits newUnits)
Converts this measure of linear velocity to the new units. |
LinearVelocity |
divideBy(BigDecimal divisor)
Divides this velocity by divisor . |
boolean |
equals(Object o)
Returns true if o is equal to this linear velocity. |
LinearVelocityUnits |
getUnits()
Returns the units of this linear velocity. |
BigDecimal |
getValue()
Returns the magnitude of this linear velocity. |
int |
hashCode()
Returns a hash code value for this linear velocity. |
boolean |
isInDefaultState()
Returns true if this velocity is in its default state, no matter how it got there. |
boolean |
isInfinite()
Returns true if this velocity is infinite. |
LinearVelocity |
multiplyBy(BigDecimal multiplier)
Multiplies this velocity by multiplier . |
static LinearVelocity |
parse(String velocityString)
Returns a new velocity based on velocityString . |
void |
reset()
Resets this linear velocity so that it is equal to one created via the no-argument constructor. |
void |
set(BigDecimal value,
LinearVelocityUnits units)
Sets the magnitude and units of this linear velocity. |
void |
set(String velocityText)
Sets the value and units of this velocity based on velocityText . |
void |
set(String value,
LinearVelocityUnits units)
Sets the magnitude and units of this linear velocity. |
void |
setUnits(LinearVelocityUnits newUnits)
Sets the units of this linear velocity to newUnits . |
void |
setValue(BigDecimal newValue)
Sets the magnitude of this linear velocity to newValue . |
void |
setValue(String newValue)
Sets the magnitude of this linear velocity to newValue . |
LinearVelocity |
subtract(LinearVelocity other)
Subtracts other linear velocity from this one. |
String |
toString()
Returns a text representation of this linear velocity. |
String |
toString(int minFracDigits,
int maxFracDigits)
Returns a text representation of this velocity. |
BigDecimal |
toUnits(LinearVelocityUnits otherUnits)
Returns the magnitude of this linear velocity in otherUnits . |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public LinearVelocity()
public LinearVelocity(BigDecimal kms)
kms
kilometers per second.
See setValue(BigDecimal)
for information
about valid parameter values and exceptions that might
be thrown.
kms
- the magnitude of this velocity in kilometers per second.public LinearVelocity(String kms)
kms
kilometers per second.
See setValue(BigDecimal)
for information
about valid parameter values and exceptions that might
be thrown.
kms
- the magnitude of this velocity in kilometers per second.public LinearVelocity(BigDecimal value, LinearVelocityUnits units)
set(BigDecimal, LinearVelocityUnits)
for information
about valid parameter values and exceptions that might
be thrown.
value
- the magnitude of this velocity.units
- the units in which value
is expressed.public LinearVelocity(String value, LinearVelocityUnits units)
set(BigDecimal, LinearVelocityUnits)
for information
about valid parameter values and exceptions that might
be thrown.
value
- the magnitude of this velocity.units
- the units in which value
is expressed.Method Detail |
---|
public void reset()
public BigDecimal getValue()
public LinearVelocityUnits getUnits()
public void set(String velocityText)
velocityText
.
See parse(String)
for the expected format of
velocityText
.
If the parsing fails, this velocity will be kept in its current state.
velocityText
- a string that will be converted into a velocity.
IllegalArgumentException
- if velocityText
is not in the expected form.public final void set(BigDecimal value, LinearVelocityUnits units)
See setValue(BigDecimal)
for more information on legal
values for value.
value
- the new magnitude of this linear velocity.units
- the units in which value
is expressed.public final void set(String value, LinearVelocityUnits units)
See setValue(String)
for more information on legal
values for value.
value
- the new magnitude of this linear velocity.units
- the units in which value
is expressed.public final void setValue(BigDecimal newValue)
newValue
.
Note that the units of this velocity are unaffected by this method.
newValue
- the new magnitude for this linear velocity.
This value may not be null but may be negative or infinite.
NumberFormatException
- if newValue
is null.public final void setValue(String newValue)
newValue
.
Note that the units of this velocity are unaffected by this method.
newValue
- the new magnitude for this linear velocity.
This value may not be null but may be negative or infinite.
The allowable representations of infinity are
"infinity", "+infinity", and "-infinity";
these values are not case sensitive.
NumberFormatException
- if newValue
is null.public final void setUnits(LinearVelocityUnits newUnits)
newUnits
.
Note that the value of this linear velocity is unaffected by
this method. Contrast this with convertTo(LinearVelocityUnits)
.
newUnits
- the new units for this linear velocity. If newUnits
is
null it will be treated as a default type.public boolean isInDefaultState()
A velocity is in its default state if both its value and
its units are the same as those of a velocity newly created via
the no-argument constructor
.
A velocity whose most recent update came via the
reset
method is also in its default state.
public boolean isInfinite()
public LinearVelocity convertTo(LinearVelocityUnits newUnits)
After this method is complete this linear velocity will have units of
newUnits
and its value will have been converted
accordingly.
newUnits
- the new units for this linear velocity.
If newUnits
is null an
IllegalArgumentException
will be thrown.
double kms =
myLinearVelocity.convertTo(
LinearVelocityUnits.KILOMETERS_PER_SECOND).getValue();
public BigDecimal toUnits(LinearVelocityUnits otherUnits)
otherUnits
.
Note that this method does not alter the state of this linear velocity.
Contrast this with convertTo(LinearVelocityUnits)
.
otherUnits
- the units in which to express this linear velocity's
magnitude.
otherUnits
.
IllegalArgumentException
- if otherUnits
is null.public LinearVelocity add(LinearVelocity other)
other
linear velocity to this one.
other
- the linear velocity to be added to this linear velocity.
public LinearVelocity subtract(LinearVelocity other)
other
linear velocity from this one.
other
- the linear velocity to be subtracted from this angular velocity.
public LinearVelocity multiplyBy(BigDecimal multiplier)
multiplier
.
multiplier
- the number by which this velocity should be multiplied.
public LinearVelocity divideBy(BigDecimal divisor)
divisor
.
divisor
- the number by which this velocity should be divided.
public static LinearVelocity parse(String velocityString)
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 km/s
.
Format Two: wRwSw.
velocityString
- a string that will be converted into
a velocity.
IllegalArgumentException
- if velocityString
is not in
the expected form.public String toString()
toString
in class Object
public String toString(int minFracDigits, int maxFracDigits)
minFracDigits
- the minimum number of places after the decimal point.maxFracDigits
- the maximum number of places after the decimal point.
public LinearVelocity clone()
clone
in class Object
public boolean equals(Object o)
o
is equal to this linear velocity.
equals
in class Object
public int hashCode()
hashCode
in class Object
public int compareTo(LinearVelocity otherVel)
otherVel
for order.
compareTo
in interface Comparable<LinearVelocity>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |