net.agmodel.weatherData
Class MetDuration

java.lang.Object
  extended bynet.agmodel.weatherData.MetDuration
All Implemented Interfaces:
Comparable, Serializable

public class MetDuration
extends Object
implements Comparable, Serializable

A set of type-safe constants for measurement frequencies used in agrometeorology
The ordinal values of these constants are used for persistent storage of metadata, so they should be changed with caution. Use them just like standard int constants eg MetDuration.ONE_HOUR
Follows the style for typed classes described in "Create enumerated constants in Java" by Eric Armstrong JavaWorld July 1997 (Uses net.agmodel.resources.UtilityResources for the duration names).

Author:
Matthew Laurenson
See Also:
Serialized Form

Field Summary
static MetDuration DAILY
           
static MetDuration HOURLY
           
static MetDuration MONTHLY
           
 int ord
           
static MetDuration SUBHOURLY
           
 
Method Summary
static MetDuration categoriseDuration(Duration input)
          Maps the input duration to the nearest MetDuration.
If input < 1 hour, MetDuration is sub_hourly if input < 1 day, MetDuration is hourly if input < 1 month, MetDuration is daily else MetDuration is monthly
 int compareTo(Object another)
           
static MetDuration elementFromOrd(int ordIndex)
          Gets a metduration based on its ordinal index.
static MetDuration first()
           
 Duration getDuration(Duration shortestAvailable)
          Maps this metDuration to the appropriate Duration.
If monthly, duration is ONE_MONTH if daily, duration is ONE_DAY if hourly, duration is ONE_HOUR else duration is shortestAvailable;
 String getName()
           
static Iterator iterator()
           
static MetDuration last()
           
static MetDuration lookup(String name)
          Finds the MetDuration whose .toString() matches the parameter
 MetDuration next()
           
 MetDuration prev()
           
static int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUBHOURLY

public static final MetDuration SUBHOURLY

HOURLY

public static final MetDuration HOURLY

DAILY

public static final MetDuration DAILY

MONTHLY

public static final MetDuration MONTHLY

ord

public final int ord
Method Detail

iterator

public static Iterator iterator()

toString

public String toString()
Returns:
the name of the MetDuration in the language of the default Locale

getName

public String getName()
Returns:
the language independent name of the MetDuration

size

public static int size()

first

public static MetDuration first()

last

public static MetDuration last()

prev

public MetDuration prev()

next

public MetDuration next()

lookup

public static MetDuration lookup(String name)
Finds the MetDuration whose .toString() matches the parameter

Returns:
the duration, or null if none is found.

compareTo

public int compareTo(Object another)
Specified by:
compareTo in interface Comparable

categoriseDuration

public static MetDuration categoriseDuration(Duration input)
Maps the input duration to the nearest MetDuration.
If input < 1 hour, MetDuration is sub_hourly if input < 1 day, MetDuration is hourly if input < 1 month, MetDuration is daily else MetDuration is monthly

Parameters:
input - the Duration to categorise
Returns:
the corresponding MetDuration

elementFromOrd

public static MetDuration elementFromOrd(int ordIndex)
Gets a metduration based on its ordinal index.

Parameters:
ordIndex - the ordinal index of a duration
Returns:
the duration

getDuration

public Duration getDuration(Duration shortestAvailable)
Maps this metDuration to the appropriate Duration.
If monthly, duration is ONE_MONTH if daily, duration is ONE_DAY if hourly, duration is ONE_HOUR else duration is shortestAvailable;

Parameters:
shortestAvailable - the shortest duration available from a station
Returns:
the corresponding Duration


Copyright (C) NARC 2001 All Rights Reserved.