|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.catalog.CatalogItemGroup<SourceCatalogEntry,SourceGroup,SourceCatalog> edu.nrao.sss.model.source.SourceGroup
public class SourceGroup
A collection of Source
s and SourceLookupTable
s.
A SourceGroup
is normally contained in a
SourceCatalog
and is a way of categorizing sources that
have similar traits.
Version Info:
$Revision: 2313 $ |
$Date: 2009-05-20 15:00:52 -0600 (Wed, 20 May 2009) $ |
$Author: btruitt $ |
Field Summary |
---|
Fields inherited from interface edu.nrao.sss.util.Identifiable |
---|
UNIDENTIFIED |
Constructor Summary | |
---|---|
SourceGroup()
Creates a new group that has a default name and that belongs to no catalog. |
|
SourceGroup(SourceCatalog container,
String nameOfGroup)
Creates a new group that belongs to container . |
Method Summary | |
---|---|
SourceCatalogEntry |
add(SourceCatalogEntry newMember)
Adds a new member to this source group. |
SourceGroup |
clone()
Returns a source group that is a copy of this one. |
boolean |
equals(Object o)
Returns true if o is equal to this source group. |
Source |
findSourceById(long id)
Returns the Source with the given id , if any. |
List<Source> |
findSourceByName(String name)
Returns the Source (s) with the given name , if any. |
SourceLookupTable |
findSourceTableById(long id)
Returns the SourceLookupTable with the given id , if any. |
List<SourceLookupTable> |
findSourceTableByName(String name)
Returns the SourceLookupTable (s) with the given name ,
if any. |
static SourceGroup |
fromXml(Reader reader)
Creates a new group based on the XML data read from reader . |
static SourceGroup |
fromXml(String xmlFile)
Creates a new group from the XML data in the given file. |
protected long |
getIdOfUnidentified()
Returns Identifiable.UNIDENTIFIED . |
static Comparator<SourceGroup> |
getNameComparator()
Returns a comparator that uses the name of the source groups sent to it. |
List<Source> |
getSources()
Returns a set of all sources held by this group. |
List<Source> |
getSources(Filter<Source> filter)
Returns a set of all sources in this group that can pass through filter . |
List<SourceLookupTable> |
getSourceTables()
Returns a set of all source lookup tables held by this group. |
int |
hashCode()
Returns a hash code value for this group. |
SourceCatalogEntry |
remove(int index)
|
SourceCatalogEntry |
remove(SourceCatalogEntry member)
|
List<Source> |
removeAllSources()
Removes all sources from this group. |
List<SourceLookupTable> |
removeAllSourceTables()
Removes all source tables from this group. |
boolean |
setCatalog(SourceCatalog newCatalog)
Sets the catalog to which this source group belongs. |
protected void |
simplySetCatalog(SourceCatalog newCatalog)
Sets this group's catalog to newCatalog without
contacting either the former or new catalog. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface edu.nrao.sss.util.Identifiable |
---|
getId |
Constructor Detail |
---|
public SourceGroup()
public SourceGroup(SourceCatalog container, String nameOfGroup)
container
.
container
- the name of the one catalog to which this group belongs.
This value may be null.nameOfGroup
- the name of this group. If this value is null,
a non-null default name will be used.Method Detail |
---|
protected long getIdOfUnidentified()
Identifiable.UNIDENTIFIED
.
getIdOfUnidentified
in class CatalogItemGroup<SourceCatalogEntry,SourceGroup,SourceCatalog>
public boolean setCatalog(SourceCatalog newCatalog)
CatalogItemGroup.setCatalog(edu.nrao.sss.catalog.Catalog)
for more details.
setCatalog
in class CatalogItemGroup<SourceCatalogEntry,SourceGroup,SourceCatalog>
newCatalog
- the catalog to which this group belongs.
newCatalog
is the new catalog for this
group. Note that this means if newCatalog
is already
the catalog of this group, the return value is true.protected void simplySetCatalog(SourceCatalog newCatalog)
newCatalog
without
contacting either the former or new catalog. This method is
used only by the SourceCatalog class.
simplySetCatalog
in class CatalogItemGroup<SourceCatalogEntry,SourceGroup,SourceCatalog>
public SourceCatalogEntry add(SourceCatalogEntry newMember)
If this group is not part of a catalog, and if the newMember
is
accepted into the group, this group will hold a reference to
newMember
. However, if this group is part of a catalog, and
if the catalog holds an entry that is equal to newMember
,
this group will hold a reference to the equivalent entry in the
catalog.
add
in class CatalogItemGroup<SourceCatalogEntry,SourceGroup,SourceCatalog>
newMember
- a new member of this source group.
newMember
is nullnewMember
is already a member of this grouppublic SourceCatalogEntry remove(SourceCatalogEntry member)
remove
in class CatalogItemGroup<SourceCatalogEntry,SourceGroup,SourceCatalog>
public SourceCatalogEntry remove(int index)
remove
in class CatalogItemGroup<SourceCatalogEntry,SourceGroup,SourceCatalog>
public List<Source> removeAllSources()
public List<SourceLookupTable> removeAllSourceTables()
public List<Source> getSources() throws RepositoryException
If this group is contained in a catalog, it may have references to
sources that are not members of this group. This happens when the
group contains SourceLookupTable
s; the sources in those tables
need not be in this group. In this situation, those sources are
not present in the returned set. Only sources held directly
by this group are returned.
Note that the returned set is not held internally by this gorup. This means that any changes made to the set after calling this method will not be reflected in this object. The sources themselves, however, are the actual sources held in this group, so changes made to them will be reflected in this object. Furthermore, if this group is part of a catalog, then the catalog, and perhaps other groups, will be referring to these same source instances, so changes made to the sources in the returned set will be reflected in all those other containers.
getSources
in interface SourceProvider
RepositoryException
- under no conditions.CatalogItemGroup.getAll()
,
getSourceTables()
,
#getSources(SourceFilter)
public List<Source> getSources(Filter<Source> filter) throws RepositoryException
filter
. If filter
is null, it will be treated
as a wide-open filter, allowing all sources to pass.
See getSources()
for details about the returned set.
getSources
in interface SourceProvider
filter
- a filter to apply to all sources in this group. Only
those sources that may pass through filter
will be in the returned set.
filter
.
RepositoryException
- under no conditions.CatalogItemGroup.getAll()
,
getSources()
,
getSourceTables()
public List<SourceLookupTable> getSourceTables() throws RepositoryException
Note that the returned set is not held internally by this gorup. This means that any changes made to the set after calling this method will not be reflected in this object. The tables themselves, however, are the actual tables held in this group, so changes made to them will be reflected in this object. Furthermore, if this group is part of a catalog, then the catalog, and perhaps other groups, will be referring to these same table instances, so changes made to the tables in the returned set will be reflected in all those other containers.
getSourceTables
in interface SourceProvider
RepositoryException
- under no conditions.CatalogItemGroup.getAll()
,
getSources()
public Source findSourceById(long id) throws RepositoryException
SourceProvider
Source
with the given id
, if any.
If this provider holds no Source
with an ID of id
,
null is returned.
findSourceById
in interface SourceProvider
id
- the identifier (primary key) for a Source
in this
repository.
Source
with the given id
, or
null, if this provider holds no such Source
.
RepositoryException
- if anything goes wrong while trying to fetch
sources from this provider.public SourceLookupTable findSourceTableById(long id) throws RepositoryException
SourceProvider
SourceLookupTable
with the given id
, if any.
If this provider holds no SourceLookupTable
with an ID of
id
, null is returned.
findSourceTableById
in interface SourceProvider
id
- the identifier (primary key) for a SourceLookupTable
in
this repository.
SourceLookupTable
with the given id
, or
null, if this provider holds no such
SourceLookupTable
.
RepositoryException
- if anything goes wrong while trying to fetch
source tables from this provider.public List<Source> findSourceByName(String name) throws RepositoryException
SourceProvider
Source
(s) with the given name
, if any.
Ideally, the returned list will contain only one source. However,
since the name is not usually used as a primary key to a source, it
is possible that the returned list may contain more than one source.
If this provider holds no Source
with a name of name
,
the returned list will be empty.
findSourceByName
in interface SourceProvider
name
- the name of a Source
requested from this provider.
Source
s with the given name
, or
null, if this provider holds no such Source
.
RepositoryException
- if anything goes wrong while trying to fetch
sources from this provider.public List<SourceLookupTable> findSourceTableByName(String name) throws RepositoryException
SourceProvider
SourceLookupTable
(s) with the given name
,
if any.
Ideally, the returned list will contain only one table. However,
since the name is not usually used as a primary key to a table, it
is possible that the returned list may contain more than one table.
If this provider holds no SourceLookupTable
with a name of
name
, the returned list will be empty.
findSourceTableByName
in interface SourceProvider
name
- the name of a SourceLookupTable
requested from
this provider.
SourceLookupTable
s with the given name
,
or null, if this provider holds no such table.
RepositoryException
- if anything goes wrong while trying to fetch
tables from this provider.public static SourceGroup fromXml(String xmlFile) throws JAXBException, XMLStreamException, FileNotFoundException
xmlFile
- the name of an XML file. This method will attempt to locate
the file by using Class.getResource(String)
.
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".public static SourceGroup fromXml(Reader reader) throws JAXBException, XMLStreamException
reader
.
reader
- the source of the XML data.
If this value is null, null is returned.
reader
.
XMLStreamException
- if the XML is not well-formed,
or for some other "unexpected processing conditions".
JAXBException
- if anything else goes wrong during the
transformation.public static Comparator<SourceGroup> getNameComparator()
public SourceGroup clone()
Special Notes on Cloning Methodology
Identifiable.UNIDENTIFIED
.
clone
in class CatalogItemGroup<SourceCatalogEntry,SourceGroup,SourceCatalog>
CatalogItemGroup.cloneIntoSameCatalog()
public boolean equals(Object o)
o
is equal to this source group.
In addition to having the same name, the two groups must have the
same number of members, and for every member of this group their
must be exactly one equal member in o
.
Ordering of Members
The members of the two groups do not have to be in the
same order. However, the sources in each group must be in the
same position relative to all other sources in the group. The
same is true of the tables. Example:
This Group Group o ---------- ------- source1 source1 tableA source2 source2 source3 source3 tableA tableB tableBThe two groups above would be equal because their sources are in the same order, relative only to the other sources, and the tables are also in the same relative order.
equals
in class CatalogItemGroup<SourceCatalogEntry,SourceGroup,SourceCatalog>
public int hashCode()
hashCode
in class CatalogItemGroup<SourceCatalogEntry,SourceGroup,SourceCatalog>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |