edu.nrao.sss.model.source
Class SourceLookupTable

java.lang.Object
  extended by edu.nrao.sss.util.LookupTable<Date,Source>
      extended by edu.nrao.sss.model.source.SourceLookupTable
All Implemented Interfaces:
CatalogItem<SourceCatalogEntry>, NameableCatalogItem<SourceCatalogEntry>, SourceCatalogEntry, UserAccountable, Identifiable, Nameable, Cloneable

public class SourceLookupTable
extends LookupTable<Date,Source>
implements SourceCatalogEntry

A lookup table where the index is of type Date and the value is of type Source.

Version Info:

$Revision: 1709 $
$Date: 2008-11-14 11:22:37 -0700 (Fri, 14 Nov 2008) $
$Author: dharland $ (last person to modify)

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

Field Summary
 
Fields inherited from interface edu.nrao.sss.util.Identifiable
UNIDENTIFIED
 
Fields inherited from interface edu.nrao.sss.model.UserAccountable
NULL_USER_ID
 
Constructor Summary
SourceLookupTable()
          Creates a new table with a default name.
SourceLookupTable(String nameOfTable)
          Creates a new table with the given name.
 
Method Summary
 void clear()
           
 void clearId()
          Resets this entry's ID, and the IDs of all its components, to a value that represents the unidentified state.
 SourceLookupTable clone()
          Returns a deep copy of this source lookup table.
 SourceLookupTable cloneAllButSources()
          Returns a copy of this source lookup table that holds references to the same sources as this table.
 boolean equals(Object o)
          Returns true if o is equal to this table.
static SourceLookupTable fromXml(Reader reader)
          Creates a new table based on the XML data read from reader.
static SourceLookupTable fromXml(String xmlFile)
          Creates a new table from the XML data in the given file.
 Long getCreatedBy()
          Returns the ID of the user who created this object.
 Date getCreatedOn()
          Returns the date on which this object was created.
 Long getId()
           
 Long getLastUpdatedBy()
          Returns the ID of the user who most recently updated this object.
 Date getLastUpdatedOn()
          Returns the most recent date on which this object was updated.
 SourceTableListener getListener()
          Returns the object that is listening to this table.
 String getName()
          Returns the name of this table.
 List<String> getNotes()
          Returns a list of notes about this table.
 int hashCode()
          Returns a hash code value for this table.
 Source put(Date key, Source value)
           
 void putAll(Map<Date,Source> map)
           
 Source remove(Date key)
           
 void removeListener(SourceTableListener listener)
          Removes listener as a listener of this table.
 void setCreatedBy(Long userId)
          Sets the ID of the user who created this object.
 void setCreatedOn(Date d)
          Sets the date on which this object was created.
 void setId(Long id)
          Do not use.
 void setLastUpdatedBy(Long userId)
          Sets the ID of the user who most recently updated this object.
 void setLastUpdatedOn(Date d)
          Sets the date on which this object was most recently updated.
 void setListener(SourceTableListener listener)
          Sets the object that will listen to this table.
 void setName(String newName)
          Sets the name of this table.
 String toString()
          Returns a text representation of this table.
 String toXml()
          Returns an XML representation of this table.
 void writeAsXmlTo(Writer writer)
          Writes an XML representation of this table to writer.
 
Methods inherited from class edu.nrao.sss.util.LookupTable
containsKey, containsValue, get, getKeySet, getKeySetFor, removeValue, size, toMap
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.nrao.sss.model.source.SourceCatalogEntry
get
 

Constructor Detail

SourceLookupTable

public SourceLookupTable()
Creates a new table with a default name.


SourceLookupTable

public SourceLookupTable(String nameOfTable)
Creates a new table with the given name.

Parameters:
nameOfTable - the name of this table. If this value is null, this table will be given a default name.
Method Detail

setId

public void setId(Long id)
Description copied from interface: SourceCatalogEntry
Do not use. This method is here for the persistence mechanism. Other clients should not set object identifiers.

Specified by:
setId in interface SourceCatalogEntry

getId

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

clearId

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

This method is useful for preparing an entry 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 entry for the first time, you may need to call this method before performing a save. This is especially true if you have created this source from XML, as the XML unmarshalling brings along the ID property.

Specified by:
clearId in interface SourceCatalogEntry

setName

public void setName(String newName)
Sets the name of this table.

If newName is null or the empty string (""), the request to change the name will be denied and the current name will remain in place.

Specified by:
setName in interface SourceCatalogEntry
Specified by:
setName in interface Nameable
Parameters:
newName - the new name for this table.

getName

public String getName()
Returns the name of this table.

Specified by:
getName in interface SourceCatalogEntry
Specified by:
getName in interface Nameable
Returns:
the name of this table.

getNotes

public List<String> getNotes()
Returns a list of notes about this table. Each note is free-form text with no particular structure.

This method returns the list actually held by this SourceLookuptable, so any list manipulations may be performed by first fetching the list and then operating on it.

Specified by:
getNotes in interface SourceCatalogEntry
Returns:
a list of notes about this table.

setListener

public void setListener(SourceTableListener listener)
Sets the object that will listen to this table.

Parameters:
listener - the object that will listen to this table. If this value is null, a null-like listener will be used instead.

removeListener

public void removeListener(SourceTableListener listener)
Removes listener as a listener of this table.

Parameters:
listener - a listener of this table.

getListener

public SourceTableListener getListener()
Returns the object that is listening to this table.

Returns:
the object that is listening to this table.

setCreatedBy

public void setCreatedBy(Long userId)
Description copied from interface: UserAccountable
Sets the ID of the user who created this object.

If userId is null, this object will be updated not with null but with UserAccountable.NULL_USER_ID instead.

Specified by:
setCreatedBy in interface UserAccountable
Parameters:
userId - the ID of the user who most recently updated this object.

setCreatedOn

public void setCreatedOn(Date d)
Description copied from interface: UserAccountable
Sets the date on which this object was created.

If d is null it will be ignored and this method will do nothing.

Specified by:
setCreatedOn in interface UserAccountable
Parameters:
d - the date on which this object was created.

setLastUpdatedBy

public void setLastUpdatedBy(Long userId)
Description copied from interface: UserAccountable
Sets the ID of the user who most recently updated this object.

If userId is null, this object will be updated not with null but with UserAccountable.NULL_USER_ID instead.

Specified by:
setLastUpdatedBy in interface UserAccountable
Parameters:
userId - the ID of the user who most recently updated this object.

setLastUpdatedOn

public void setLastUpdatedOn(Date d)
Description copied from interface: UserAccountable
Sets the date on which this object was most recently updated.

If d is null it will be ignored and this method will do nothing.

Specified by:
setLastUpdatedOn in interface UserAccountable
Parameters:
d - the date on which this object was most recently updated.

getCreatedBy

public Long getCreatedBy()
Description copied from interface: UserAccountable
Returns the ID of the user who created this object.

If this object does not know the identity of the user who created it, the returned ID will be UserAccountable.NULL_USER_ID.

Specified by:
getCreatedBy in interface UserAccountable
Returns:
the ID of the user who created this object.

getCreatedOn

public Date getCreatedOn()
Description copied from interface: UserAccountable
Returns the date on which this object was created.

Specified by:
getCreatedOn in interface UserAccountable
Returns:
the date on which this object was created.

getLastUpdatedBy

public Long getLastUpdatedBy()
Description copied from interface: UserAccountable
Returns the ID of the user who most recently updated this object.

If this object does not know the identity of the user who lasted updated it, the returned ID will be UserAccountable.NULL_USER_ID.

Specified by:
getLastUpdatedBy in interface UserAccountable
Returns:
the ID of the user who most recently updated this object.

getLastUpdatedOn

public Date getLastUpdatedOn()
Description copied from interface: UserAccountable
Returns the most recent date on which this object was updated.

Specified by:
getLastUpdatedOn in interface UserAccountable
Returns:
the most recent date on which this object was updated.

clear

public void clear()
Overrides:
clear in class LookupTable<Date,Source>

put

public Source put(Date key,
                  Source value)
Overrides:
put in class LookupTable<Date,Source>

putAll

public void putAll(Map<Date,Source> map)
Overrides:
putAll in class LookupTable<Date,Source>

remove

public Source remove(Date key)
Overrides:
remove in class LookupTable<Date,Source>

toString

public String toString()
Returns a text representation of this table. The default form of the text is XML. However, if anything goes wrong during the conversion to XML, an alternate, and much abbreviated, form will be returned.

Overrides:
toString in class LookupTable<Date,Source>
Returns:
a text representation of this table.

toXml

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

Returns:
an XML representation of this table.
Throws:
JAXBException - if anything goes wrong during the conversion to XML.

writeAsXmlTo

public void writeAsXmlTo(Writer writer)
                  throws JAXBException
Writes an XML representation of this table 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 SourceLookupTable fromXml(String xmlFile)
                                 throws JAXBException,
                                        XMLStreamException,
                                        FileNotFoundException
Creates a new table 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 table 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 SourceLookupTable fromXml(Reader reader)
                                 throws JAXBException,
                                        XMLStreamException
Creates a new table based on the XML data read from reader.

Parameters:
reader - the source of the XML data. If this value is null, null is returned.
Returns:
a new table 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 SourceLookupTable clone()
Returns a deep copy of this source lookup table. Both the dates and the sources held in the returned table are clones of those held in this table.

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

Specified by:
clone in interface CatalogItem<SourceCatalogEntry>
Overrides:
clone in class LookupTable<Date,Source>
See Also:
cloneAllButSources()

cloneAllButSources

public SourceLookupTable cloneAllButSources()
Returns a copy of this source lookup table that holds references to the same sources as this table. The dates in the returned table are clones of those in this table, but both tables refer to the same source instances.

Returns:
a copy of this source lookup table.
See Also:
clone()

equals

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

Overrides:
equals in class LookupTable<Date,Source>

hashCode

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

Overrides:
hashCode in class LookupTable<Date,Source>


Copyright © 2009. All Rights Reserved.