org.geotools.metadata.iso.identification
Class RepresentativeFractionImpl

java.lang.Object
  extended by java.lang.Number
      extended by org.geotools.metadata.iso.identification.RepresentativeFractionImpl
All Implemented Interfaces:
java.io.Serializable, org.opengis.metadata.identification.RepresentativeFraction

public class RepresentativeFractionImpl
extends java.lang.Number
implements org.opengis.metadata.identification.RepresentativeFraction

A scale where denominator = 1 / scale. This implementation is set up as a number - because it is.

Since:
2.4
Version:
$Id: RepresentativeFractionImpl.java 31557 2008-09-19 20:02:35Z desruisseaux $
Author:
Jody Garnett
See Also:
Serialized Form

Constructor Summary
RepresentativeFractionImpl()
          Default empty constructor.
RepresentativeFractionImpl(long denominator)
          Creates a new representative fraction from the specified denominator.
 
Method Summary
 double doubleValue()
          Returns the scale in a form usable for computation.
 boolean equals(java.lang.Object object)
          Compares this object with the specified value for equality.
 float floatValue()
          Returns the scale as a float type.
static org.opengis.metadata.identification.RepresentativeFraction fromScale(double scale)
          Creates a representative fraction from a scale as a double value.
 long getDenominator()
          Returns the number below the line in a vulgar fraction.
 int hashCode()
          Returns a hash value for this representative fraction.
 int intValue()
          Returns the scale as an integer.
 long longValue()
          Returns the scale as an integer.
 void setDenominator(long denominator)
          Sets the denominator value.
 double toScale()
          Deprecated. This is equivalent to doubleValue().
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepresentativeFractionImpl

public RepresentativeFractionImpl()
Default empty constructor.


RepresentativeFractionImpl

public RepresentativeFractionImpl(long denominator)
Creates a new representative fraction from the specified denominator.

Parameters:
denominator - The denominator.
Method Detail

fromScale

public static org.opengis.metadata.identification.RepresentativeFraction fromScale(double scale)
                                                                            throws java.lang.IllegalArgumentException
Creates a representative fraction from a scale as a double value. The denominator will be set to 1/scale.

Parameters:
scale - The scale as a number between 0 and 1.
Returns:
The representative fraction created from the given scale.
Throws:
java.lang.IllegalArgumentException - if the condition abs(scale) <= 1 is not meet.

toScale

@Deprecated
public double toScale()
Deprecated. This is equivalent to doubleValue().

Specified by:
toScale in interface org.opengis.metadata.identification.RepresentativeFraction

doubleValue

public double doubleValue()
Returns the scale in a form usable for computation.

Specified by:
doubleValue in interface org.opengis.metadata.identification.RepresentativeFraction
Specified by:
doubleValue in class java.lang.Number
Returns:
1.0 / denominator

floatValue

public float floatValue()
Returns the scale as a float type.

Specified by:
floatValue in class java.lang.Number

longValue

public long longValue()
               throws java.lang.ArithmeticException
Returns the scale as an integer. This method returns 0, 1 or throws an exception as specified in intValue().

Specified by:
longValue in class java.lang.Number
Throws:
java.lang.ArithmeticException - if the denominator is 0.

intValue

public int intValue()
             throws java.lang.ArithmeticException
Returns the scale as an integer. If the denominator is 0, then this method throws an ArithmeticException since infinities can not be represented by an integer. Otherwise if the denominator is 1, then this method returns 1. Otherwise returns 0 0 since the scale is a fraction between 0 and 1, and such value can not be represented as an integer.

Specified by:
intValue in class java.lang.Number
Throws:
java.lang.ArithmeticException - if the denominator is 0.

getDenominator

public long getDenominator()
Returns the number below the line in a vulgar fraction.

Specified by:
getDenominator in interface org.opengis.metadata.identification.RepresentativeFraction

setDenominator

public void setDenominator(long denominator)
Sets the denominator value.

Parameters:
denominator - The new denominator value.

equals

public boolean equals(java.lang.Object object)
Compares this object with the specified value for equality.

Specified by:
equals in interface org.opengis.metadata.identification.RepresentativeFraction
Overrides:
equals in class java.lang.Object
Parameters:
object - The object to compare with.
Returns:
true if both objects are equal.

hashCode

public int hashCode()
Returns a hash value for this representative fraction.

Specified by:
hashCode in interface org.opengis.metadata.identification.RepresentativeFraction
Overrides:
hashCode in class java.lang.Object


Copyright © 1996-2010 Geotools. All Rights Reserved.