edu.nrao.sss.model.resource
Class AntennaSelection

java.lang.Object
  extended by edu.nrao.sss.model.resource.AntennaSelection
All Implemented Interfaces:
Cloneable

public class AntennaSelection
extends Object
implements Cloneable

A selection of antennas.

A selection of antennas can be more than just a collection of antennas. It can be used to make requests such as: "give me at least 5 antennas, preferrably those that result in the longest possible baselines".

Version Info:

$Revision: 1710 $
$Date: 2008-11-14 11:54:07 -0700 (Fri, 14 Nov 2008) $
$Author: dharland $

Since:
2007-03-07
Author:
David M. Harland

Constructor Summary
AntennaSelection()
          Creates a new instance using a default AntennaProvider that returns an empty set of Antennas.
AntennaSelection(AntennaProvider antennaProvider)
          Creates a new instance using antennaProvider as the source of available antennas to select from.
 
Method Summary
 void addUserPick(String antennaId)
          Adds the given antenna ID to this selection.
 AntennaSelection clone()
          Returns a selection that is a copy of this one.
 boolean equals(Object o)
          Returns true if o is equal to this antenna selection.
 AntennaProvider getAntennaProvider()
           
 AntennaSpecifier getIdType()
          Returns the type of identifiers returned by getMatchingAntennas().
 Set<String> getMatchingAntennas()
          Returns a collection of antenna identifiers represented by this selection.
 AntennaSelectionMethod getMethod()
          Returns the manner in which antennas will be selected.
 int getMinimumNumber()
          Returns the minimum number of antennas to select.
 ReceiverBand getRequiredReceiver()
          Returns the receiver band that must be supported on all returned Antennas.
 int hashCode()
          Returns a hash code value for this antenna selection.
 void recalculateMatchingAntennas()
          Selects antennas based on the other properties of this object.
 void removeUserPick(String antennaId)
          Removes the given antenna ID from this selection.
 void reset()
          Puts this selection back in its initial state.
 void setAntennaProvider(AntennaProvider p)
          Sets the AntennaProvider instance used to find the complete set of available Antennas.
 void setIdType(AntennaSpecifier newType)
          Set the type of identifiers returned by getMatchingAntennas().
 void setMethod(AntennaSelectionMethod newMethod)
          Sets the manner in which antennas will be selected.
 void setMinimumNumber(int newMin, AntennaSelectionMethod selectionMethod)
          Sets the minimum number of antennas to select and the selection method to use.
 void setRequiredReceiver(ReceiverBand b)
          Sets a receiver band that must be supported on all returned Antennas.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AntennaSelection

public AntennaSelection(AntennaProvider antennaProvider)
Creates a new instance using antennaProvider as the source of available antennas to select from.


AntennaSelection

public AntennaSelection()
Creates a new instance using a default AntennaProvider that returns an empty set of Antennas.

Method Detail

reset

public void reset()
Puts this selection back in its initial state.


setMethod

public void setMethod(AntennaSelectionMethod newMethod)
Sets the manner in which antennas will be selected.

Depending on the value of newMethod, previously set properties may be cleared.

Parameters:
newMethod - the manner in which antennas will be selected. If this value is null, the default method (see getMethod()) will be used.

getMethod

public AntennaSelectionMethod getMethod()
Returns the manner in which antennas will be selected. The default value for this property is AntennaSelectionMethod.ALL.

Returns:
the manner in which antennas will be selected.

setIdType

public void setIdType(AntennaSpecifier newType)
Set the type of identifiers returned by getMatchingAntennas().

Parameters:
newType - the type of identifiers returned by getMatchingAntennas(). If this value is null, the default type (see getIdType()) will be used.

getIdType

public AntennaSpecifier getIdType()
Returns the type of identifiers returned by getMatchingAntennas(). The default value for this property is AntennaSpecifier.ANTENNA_ID.

Caveat: If this selection holds a collection of user-specified antennas, there is no guarantee that the user-specified IDs are of the type returned here.

Returns:
the type of identifiers returned by getMatchingAntennas().

setMinimumNumber

public void setMinimumNumber(int newMin,
                             AntennaSelectionMethod selectionMethod)
Sets the minimum number of antennas to select and the selection method to use.

Parameters:
newMin - the minimum number of antennas to select.
selectionMethod - the manner in which antennas will be selected.
Throws:
IllegalArgumentException - if newMin is less than one or if selectionMethod does not require specification of a minimum number of antennas.

getMinimumNumber

public int getMinimumNumber()
Returns the minimum number of antennas to select.

Returns:
the minimum number of antennas to select.

addUserPick

public void addUserPick(String antennaId)
Adds the given antenna ID to this selection. The antenna selection method is also set to AntennaSelectionMethod.LIST.

Parameters:
antennaId - the ID of a manually selected antenna.

removeUserPick

public void removeUserPick(String antennaId)
Removes the given antenna ID from this selection. If the current selection method is not AntennaSelectionMethod.LIST, this method does nothing.

Parameters:
antennaId - the ID of antenna to remove from the set of manually selected antennas.

setAntennaProvider

public void setAntennaProvider(AntennaProvider p)
Sets the AntennaProvider instance used to find the complete set of available Antennas. If p is null, then the provider is set to an instance of DefaultAntennaProvider. In either case the selection returned by getMatchingAntennas() is recalculated.


getAntennaProvider

public AntennaProvider getAntennaProvider()
Returns:
the AntennaProvider instance used to find the complete set of available Antennas.

setRequiredReceiver

public void setRequiredReceiver(ReceiverBand b)
Sets a receiver band that must be supported on all returned Antennas. Setting this to null implies that there is no restriction on supported receiver bands.


getRequiredReceiver

public ReceiverBand getRequiredReceiver()
Returns the receiver band that must be supported on all returned Antennas. If this returns null, that implies that there is no restriction on supported receiver bands.


getMatchingAntennas

public Set<String> getMatchingAntennas()
Returns a collection of antenna identifiers represented by this selection. Note that this method will only recalculate the matching antennas if 1 or more of the properties of this object have changed!

The returned set is not held internally by this selection, so any changes made to it will not be reflected in this object. The returned set is guaranteed to be non-null, but it may be empty.

Returns:
a collection of antenna identifiers represented by this selection.
See Also:
recalculateMatchingAntennas()

recalculateMatchingAntennas

public void recalculateMatchingAntennas()
Selects antennas based on the other properties of this object. Calling this method will recalculate the matching antennas even if none of the properties of this object have changed. In contrast, getMatchingAntennas() will always return the same set, with no recalculation, if none of the properties have changed.

TODO: What do we do if the AntennaProvider can not meet the requirements laid out in this object?


clone

public AntennaSelection clone()
Returns a selection that is a copy of this one.

If anything goes wrong during the cloning procedure, a RuntimeException will be thrown.

Overrides:
clone in class Object

equals

public boolean equals(Object o)
Returns true if o is equal to this antenna selection.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for this antenna selection.

Overrides:
hashCode in class Object


Copyright © 2009. All Rights Reserved.