org.geotoolkit.metadata.iso.identification
Class DefaultRepresentativeFraction

Object
  extended by Number
      extended by DefaultRepresentativeFraction
All Implemented Interfaces:
Serializable, RepresentativeFraction

@ThreadSafe
public class DefaultRepresentativeFraction
extends Number
implements RepresentativeFraction

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

Since:
2.4
Version:
3.19
Author:
Jody Garnett (Refractions), Cédric Briançon (Geomatys), Martin Desruisseaux (Geomatys)
See Also:
Serialized Form
Module:
metadata/geotk-metadata (download)    View source code for this class

Constructor Summary
DefaultRepresentativeFraction()
          Default empty constructor.
DefaultRepresentativeFraction(long denominator)
          Creates a new representative fraction from the specified denominator.
DefaultRepresentativeFraction(RepresentativeFraction source)
          Constructs a metadata entity initialized with the values from the specified metadata.
 
Method Summary
static DefaultRepresentativeFraction castOrCopy(RepresentativeFraction object)
          Returns a Geotk metadata implementation with the same values than the given arbitrary implementation.
 double doubleValue()
          Returns the scale in a form usable for computation.
 boolean equals(Object object)
          Compares this object with the specified value for equality.
 float floatValue()
          Returns the scale as a float type.
static 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.
 
Methods inherited from class Number
byteValue, shortValue
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRepresentativeFraction

public DefaultRepresentativeFraction()
Default empty constructor.


DefaultRepresentativeFraction

public DefaultRepresentativeFraction(RepresentativeFraction source)
Constructs a metadata entity initialized with the values from the specified metadata.

Parameters:
source - The metadata to copy, or null if none.
Since:
3.18

DefaultRepresentativeFraction

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

Parameters:
denominator - The denominator.
Method Detail

castOrCopy

public static DefaultRepresentativeFraction castOrCopy(RepresentativeFraction object)
Returns a Geotk metadata implementation with the same values than the given arbitrary implementation. If the given object is null, then this method returns null. Otherwise if the given object is already a Geotk implementation, then the given object is returned unchanged. Otherwise a new Geotk implementation is created and initialized to the attribute values of the given object.

Parameters:
object - The object to get as a Geotk implementation, or null if none.
Returns:
A Geotk implementation containing the values of the given object (may be the given object itself), or null if the argument was null.
Since:
3.18

fromScale

public static RepresentativeFraction fromScale(double scale)
                                        throws 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:
IllegalArgumentException - if the condition abs(scale) <= 1 is not meet.

doubleValue

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

Specified by:
doubleValue in interface RepresentativeFraction
Specified by:
doubleValue in class Number
Returns:
1.0 / denominator

floatValue

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

Specified by:
floatValue in class Number

longValue

public long longValue()
               throws 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 Number
Throws:
ArithmeticException - if the denominator is 0.

intValue

public int intValue()
             throws 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 Number
Throws:
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 RepresentativeFraction

setDenominator

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

Parameters:
denominator - The new denominator value.

equals

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

Specified by:
equals in interface RepresentativeFraction
Overrides:
equals in class 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 RepresentativeFraction
Overrides:
hashCode in class Object


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.