edu.nrao.sss.model.resource
Class CorrelationProductGroupAbs

java.lang.Object
  extended by edu.nrao.sss.model.resource.CorrelationProductGroupAbs
All Implemented Interfaces:
CorrelationProductGroup, Identifiable
Direct Known Subclasses:
WidarCorrelationProductGroup

public abstract class CorrelationProductGroupAbs
extends Object
implements CorrelationProductGroup

Partial implementation of a correlation product group.

Version Info:

$Revision: 2289 $
$Date: 2009-05-07 16:13:41 -0600 (Thu, 07 May 2009) $
$Author: dharland $ (last person to modify)

Since:
2008-11-25
Author:
David M. Harland

Field Summary
protected  SortedMap<StokesParameter,Integer> channels
          A sorted map whose keys are correlation types and whose values are spectral channel counts.
protected  boolean needToRecalcChannels
          Set to true when the previously calculated channels is a stale value.
 
Fields inherited from interface edu.nrao.sss.util.Identifiable
UNIDENTIFIED
 
Constructor Summary
protected CorrelationProductGroupAbs()
          Helps create a new group.
 
Method Summary
 boolean addPolarizationProduct(StokesParameter stokes)
          Attempts to add the given product to this group.
 void clearId()
          Resets this instance's ID, and the IDs of all its components, to a value that represents the unidentified state.
protected  void copyInto(CorrelationProductGroupAbs other)
          Sets other's internal variables to the same values as those of this group.
 boolean equals(Object o)
          Returns true if o is equal to this group.
 SortedSet<StokesParameter> getAllowablePolarizationProducts()
          Returns a set of the polarization products that may be obtained from this group.
protected  CorrelatorSubbandAbs getContainer()
          Primarily for use by persistence mechanism.
 Long getId()
           
 int getSpectralChannels()
          Returns the total number of spectral channels, summed over all correlation products, for this group.
 int getSpectralChannels(StokesParameter stokes)
          Returns the number of spectral channels of this group that are allocated to the given product.
 String getUUID()
          Returns an ID that attempts to be universally unique.
 int hashCode()
           
protected abstract  void recalculateChannels()
          Called when something that can influence the total number of channels, or the distribution of channels among products, has changed.
 void removeAllPolarizationProducts()
          Removes all polarization products from this group.
protected  void removeDisallowedProducts()
          Removes from the channels map any entries for Stokes parameters that are not in the allowable set.
 int removePolarizationProduct(StokesParameter stokes)
          Removes the given product from this group, if present.
protected  void setContainer(CorrelatorSubbandAbs newContainer)
          Primarily for use by persistence mechanism.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.nrao.sss.model.resource.CorrelationProductGroup
getMinimumTotalIntegrationTime, getTotalIntegrationTime, setTotalIntegrationTime
 

Field Detail

channels

protected SortedMap<StokesParameter,Integer> channels
A sorted map whose keys are correlation types and whose values are spectral channel counts. Subclasses must not set this value to null.


needToRecalcChannels

protected boolean needToRecalcChannels
Set to true when the previously calculated channels is a stale value.

Constructor Detail

CorrelationProductGroupAbs

protected CorrelationProductGroupAbs()
Helps create a new group.

Method Detail

getId

public Long getId()
Specified by:
getId in interface Identifiable

clearId

public void clearId()
Description copied from interface: CorrelationProductGroup
Resets this instance's ID, and the IDs of all its components, to a value that represents the unidentified state.

This method is useful for preparing an instance for storage in a database. The ID property (as of now, though this may change in the future) is used by our persistence mechanism to identify objects. If you are persisting this instance for the first time, you may need to call this method before performing a save. This is especially true if you have created this instance from XML, as the XML unmarshalling brings along the ID property.

Specified by:
clearId in interface CorrelationProductGroup

getUUID

public String getUUID()
Description copied from interface: CorrelationProductGroup
Returns an ID that attempts to be universally unique. This ID will be unique for a given group within its containing subband.

Specified by:
getUUID in interface CorrelationProductGroup
Returns:
an ID that attempts to be universally unique.

setContainer

protected void setContainer(CorrelatorSubbandAbs newContainer)
Primarily for use by persistence mechanism. Subclass authors should try to prevent this value from being null.


getContainer

protected CorrelatorSubbandAbs getContainer()
Primarily for use by persistence mechanism.


recalculateChannels

protected abstract void recalculateChannels()
Called when something that can influence the total number of channels, or the distribution of channels among products, has changed. The main job of this method is to update the channels map. Implementations should also set the variable needToRecalcChannels to false upon successful recalculation.


removeDisallowedProducts

protected void removeDisallowedProducts()
Removes from the channels map any entries for Stokes parameters that are not in the allowable set.


getAllowablePolarizationProducts

public SortedSet<StokesParameter> getAllowablePolarizationProducts()
Description copied from interface: CorrelationProductGroup
Returns a set of the polarization products that may be obtained from this group.

Specified by:
getAllowablePolarizationProducts in interface CorrelationProductGroup
Returns:
a set of the polarization products that may be obtained from this group.

addPolarizationProduct

public boolean addPolarizationProduct(StokesParameter stokes)
Description copied from interface: CorrelationProductGroup
Attempts to add the given product to this group. The product will be added only if it is an allowable product. This method returns true if it already contained stokes or if this method successfully added it.

Specified by:
addPolarizationProduct in interface CorrelationProductGroup
Parameters:
stokes - the product to be added to this group.
Returns:
true if this group contains stokes after a call to this method.

removePolarizationProduct

public int removePolarizationProduct(StokesParameter stokes)
Description copied from interface: CorrelationProductGroup
Removes the given product from this group, if present.

Specified by:
removePolarizationProduct in interface CorrelationProductGroup
Parameters:
stokes - the product to be removed to this group.
Returns:
the number of channels that had been allocated to the given product.

removeAllPolarizationProducts

public void removeAllPolarizationProducts()
Description copied from interface: CorrelationProductGroup
Removes all polarization products from this group.

Specified by:
removeAllPolarizationProducts in interface CorrelationProductGroup

getSpectralChannels

public int getSpectralChannels()
Description copied from interface: CorrelationProductGroup
Returns the total number of spectral channels, summed over all correlation products, for this group.

Specified by:
getSpectralChannels in interface CorrelationProductGroup
Returns:
the total number of spectral channels for this group.

getSpectralChannels

public int getSpectralChannels(StokesParameter stokes)
Description copied from interface: CorrelationProductGroup
Returns the number of spectral channels of this group that are allocated to the given product.

Specified by:
getSpectralChannels in interface CorrelationProductGroup
Parameters:
stokes - the product for which a number of channels is requested.
Returns:
the number of channels in this group for stokes.

copyInto

protected void copyInto(CorrelationProductGroupAbs other)
Sets other's internal variables to the same values as those of this group. The exceptions are the ID, which is cleared, and the UUID.

Parameters:
other - a correlation product group whose values should be set to mimic the values in this group.

equals

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

Items not compared in the equality tests:

  1. ID
  2. UUID
  3. Subband
  4. Number of channels

Note that the number and type of correlation products is examined, but not the channels for each. Subclasses may use such a check in their overrides of this method.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2009. All Rights Reserved.