edu.nrao.sss.model.resource
Class ResourceSpecification

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

public class ResourceSpecification
extends Object
implements Cloneable

A science view of the hardware needed for an observation.

Version Info:

$Revision: 851 $
$Date: 2007-08-27 13:29:48 -0600 (Mon, 27 Aug 2007) $
$Author: dharland $

Since:
2006-09-08
Author:
David M. Harland

Constructor Summary
ResourceSpecification()
          Creates a new instance.
 
Method Summary
 ResourceSpecification clone()
          Returns a resource specification that is a copy of this one.
 boolean equals(Object o)
          Returns true if o is equal to this specification.
static ResourceSpecification fromXml(Reader reader)
          Creates a new specification based on the XML data read from reader.
static ResourceSpecification fromXml(String xmlFile)
          Creates a new specification from the XML data in the given file.
 List<PulsarSpecification> getPulsarSpecs()
          Returns this specification's list of pulsar specifications.
 List<SkyFrequencySpecification> getSkyFrequencySpecs()
          Returns this specification's list of sky frequency specifications.
 List<SpectralLineSpecification> getSpectralLineSpecs()
          Returns this specification's list of spectral line specifications.
 FrequencySpectrum getSpectrum()
          Returns the portions of the frequency spectrum covered by these specifications.
 int hashCode()
          Returns a hash code value for this specification.
static ResourceSpecification makeFrom(PulsarSpecification specs)
          Creates a new instance based on the given specifications.
static ResourceSpecification makeFrom(SkyFrequencySpecification specs)
          Creates a new instance based on the given specifications.
static ResourceSpecification makeFrom(SpectralLineSpecification specs)
          Creates a new instance based on the given specifications.
 ResourceSpecification modifyToFit(FrequencyRange targetRange)
          Modifies this resource specification to fit the given frequency range.
 ResourceSpecification modifyToFit(FrequencySpectrum targetSpectrum)
          Modifies this resource specification to fit the given frequency spectrum.
 void setPulsarSpecs(List<PulsarSpecification> newSpecs)
          Sets a new list of pulsar specifications.
 void setSkyFrequencySpecs(List<SkyFrequencySpecification> newSpecs)
          Sets a new list of sky frequency specifications.
 void setSpectralLineSpecs(List<SpectralLineSpecification> newSpecs)
          Sets a new list of spectral line specifications.
 String toXml()
          Returns an XML representation of this specification.
 void writeAsXmlTo(Writer writer)
          Writes an XML representation of this specification to writer.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceSpecification

public ResourceSpecification()
Creates a new instance.

Method Detail

makeFrom

public static ResourceSpecification makeFrom(SkyFrequencySpecification specs)
Creates a new instance based on the given specifications.

Parameters:
specs - an entry in this specification's list of spectral specifications.
Returns:
a new instance based on the given specifications.

makeFrom

public static ResourceSpecification makeFrom(SpectralLineSpecification specs)
Creates a new instance based on the given specifications.

Parameters:
specs - an entry in this specification's list of spectral specifications.
Returns:
a new instance based on the given specifications.

makeFrom

public static ResourceSpecification makeFrom(PulsarSpecification specs)
Creates a new instance based on the given specifications.

Parameters:
specs - an entry in this specification's list of pulsar specifications.
Returns:
a new instance based on the given specifications.

setSkyFrequencySpecs

public void setSkyFrequencySpecs(List<SkyFrequencySpecification> newSpecs)
Sets a new list of sky frequency specifications. If newSpecs is null, it will be interpreted as an empty list.

Note that this specification will hold an internal reference to newSpecs (unless it is null). This means that any changes made to newSpecs after this call will be reflected in this object.

Parameters:
newSpecs - a list of sky frequency specifications.

getSkyFrequencySpecs

public List<SkyFrequencySpecification> getSkyFrequencySpecs()
Returns this specification's list of sky frequency specifications. The returned list may be empty, but will never be null.

Note that the returned list is the one held internally by this specification. This means that any changes made to the returned list after this call will be reflected in this object.

Returns:
this specification's list of sky frequency specifications.

setSpectralLineSpecs

public void setSpectralLineSpecs(List<SpectralLineSpecification> newSpecs)
Sets a new list of spectral line specifications. If newSpecs is null, it will be interpreted as an empty list.

Note that this specification will hold an internal reference to newSpecs (unless it is null). This means that any changes made to newSpecs after this call will be reflected in this object.

Parameters:
newSpecs - a list of spectral line specifications.

getSpectralLineSpecs

public List<SpectralLineSpecification> getSpectralLineSpecs()
Returns this specification's list of spectral line specifications. The returned list may be empty, but will never be null.

Note that the returned list is the one held internally by this specification. This means that any changes made to the returned list after this call will be reflected in this object.

Returns:
this specification's list of spectral line specifications.

setPulsarSpecs

public void setPulsarSpecs(List<PulsarSpecification> newSpecs)
Sets a new list of pulsar specifications. If newSpecs is null, it will be interpreted as an empty list.

Note that this specification will hold an internal reference to newSpecs (unless it is null). This means that any changes made to newSpecs after this call will be reflected in this object.

Parameters:
newSpecs - a list of pulsar specifications.

getPulsarSpecs

public List<PulsarSpecification> getPulsarSpecs()
Returns this specification's list of pulsar specifications. The returned list may be empty, but will never be null.

Note that the returned list is the one held internally by this specification. This means that any changes made to the returned list after this call will be reflected in this object.

Returns:
this specification's list of pulsar specifications.

getSpectrum

public FrequencySpectrum getSpectrum()
Returns the portions of the frequency spectrum covered by these specifications.

Returns:
the portions of the frequency spectrum covered by these specifications.

modifyToFit

public ResourceSpecification modifyToFit(FrequencyRange targetRange)
Modifies this resource specification to fit the given frequency range.

Any frequency ranges held by this specification that have no overlap with targetRange are deleted. Those ranges that do overlap the target range are trimmed to the overlapping portions. The net effect is that the frequency ranges of this specification after the modification are the result of intersecting the current ranges with targetRange.

Parameters:
targetRange - the frequency range used to modify this specification. Only the portions of the ranges held by this specification that intersect this parameter are retained.
Returns:
this specification, after modification.

modifyToFit

public ResourceSpecification modifyToFit(FrequencySpectrum targetSpectrum)
Modifies this resource specification to fit the given frequency spectrum.

Any frequency ranges held by this specification that have no overlap with targetSpectrum are deleted. Those ranges that do overlap the target spectrum are trimmed to the overlapping portions. The net effect is that the frequency ranges of this specification after the modification are the result of intersecting the current ranges with targetSpectrum.

Note: one consequence of this method is that the internal lists of subspecifications are replaced with new lists.

Parameters:
targetSpectrum - the frequency speumctr used to modify this specification. Only the portions of the ranges held by this specification that intersect this parameter are retained.
Returns:
this specification, after modification.

toXml

public String toXml()
             throws JAXBException
Returns an XML representation of this specification.

Returns:
an XML representation of this specification.
Throws:
JAXBException - if anything goes wrong during the conversion to XML.
See Also:
writeAsXmlTo(Writer)

writeAsXmlTo

public void writeAsXmlTo(Writer writer)
                  throws JAXBException
Writes an XML representation of this specification to writer.

Parameters:
writer - the device to which XML is written.
Throws:
JAXBException - if anything goes wrong during the conversion to XML.

fromXml

public static ResourceSpecification fromXml(String xmlFile)
                                     throws JAXBException,
                                            XMLStreamException,
                                            FileNotFoundException
Creates a new specification from the XML data in the given file.

Parameters:
xmlFile - the name of an XML file. This method will attempt to locate the file by using Class.getResource(String).
Returns:
a new specification from the XML data in the given file.
Throws:
FileNotFoundException - if the XML file cannot be found.
JAXBException - if the schema file used (if any) is malformed, if the XML file cannot be read, or if the XML file is not schema-valid.
XMLStreamException - if there is a problem opening the XML file, if the XML is not well-formed, or for some other "unexpected processing conditions".

fromXml

public static ResourceSpecification fromXml(Reader reader)
                                     throws JAXBException,
                                            XMLStreamException
Creates a new specification based on the XML data read from reader.

Parameters:
reader - the specification of the XML data. If this value is null, null is returned.
Returns:
a new specification based on the XML data read from reader.
Throws:
XMLStreamException - if the XML is not well-formed, or for some other "unexpected processing conditions".
JAXBException - if anything else goes wrong during the transformation.

clone

public ResourceSpecification clone()
Returns a resource specification 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 specification.

Overrides:
equals in class Object

hashCode

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

Overrides:
hashCode in class Object


Copyright © 2009. All Rights Reserved.