|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.model.source.SourceFilter
public class SourceFilter
A filter that operates on sources.
Revision Info:
$Revision: 2314 $ |
$Date: 2009-05-21 11:56:06 -0600 (Thu, 21 May 2009) $ |
$Author: btruitt $ (last person to modify) |
Field Summary | |
---|---|
static Date |
CURRENT_TIME
A constant that indicates the current time should be used when evaluating the information held by a source. |
static boolean |
EXCLUDE_ALIASES
|
static boolean |
INCLUDE_ALIASES
|
Constructor Summary | |
---|---|
SourceFilter()
Creates a new wide-open filter that allows all sources to pass. |
Method Summary | |
---|---|
void |
addBrightnessFilter(SourceBrightnessFilter sbFilter)
Adds the given filter to this filter. |
void |
addForbiddenUserDefinedKey(String udKey)
Adds a user-defined key to this filter's set of forbidden keys. |
void |
addRequiredUserDefinedKey(String udKey)
Adds a user-defined key to this filter's set of required keys. |
void |
addRequiredUserDefinedValues(String udKey,
Set<String> additionalUdvs)
Adds additional values to the set held by this filter for the given user defined key. |
boolean |
allows(Source src)
Returns true if this filter allows the given source to pass through it. |
boolean |
blocks(Source src)
Returns true if this filter blocks the given source. |
void |
clearAll()
Sets this filter to a wide-open state. |
void |
clearBrightnessFilters()
Removes all brightness filters from this filter. |
void |
clearCoordSysAndEpoch()
Sets the coordinate system to equatorial
and the epoch to Epoch.J2000 . |
void |
clearNamePattern()
Sets the name criterion to its wide-open state. |
void |
clearPositionFilter()
Removes the position filter from this filter. |
void |
clearQueryTime()
Sets this filter so that it will use the current time when querying sources sent to the allows(Source) or
blocks(Source) methods. |
void |
clearUserDefinedValues()
Sets the UDV criterion to its wide-open state. |
void |
removeForbiddenUserDefinedKey(String udKey)
Removes udKey from this filter's collection of
UDV keys that passing sources
must not possess. |
void |
removeRequiredUserDefinedValue(String udKey)
Removes udKey from this filter's collection of
UDV keys that passing sources
must possess. |
void |
replaceRequiredUserDefinedValues(String udKey,
Set<String> replacementUdvs)
Replaces the values held by this filter for the given user defined key. |
Collection<Source> |
selectFrom(Collection<?> bag)
Selects those objects in bag that are sources and that can pass
through this filter. |
void |
setCoordSysAndEpoch(CelestialCoordinateSystem newSys,
Epoch newEpoch)
Sets the coordinate system and epoch to use if source positions are to be converted to a common system prior to filtering. |
void |
setNamePattern(Pattern regex,
boolean includeAliases)
Sets a regular expression for matching the names of sources. |
void |
setNamePattern(String regex,
boolean includeAliases)
Sets a regular expression for matching the names of sources. |
void |
setPositionFilter(SkyPositionFilter posFilter)
Sets this filter's position filter. |
void |
setQueryTime(Date time)
Sets the date and time at which the filtered source is queried for its information. |
void |
turnOffPositionConversion()
Prevents this filter from performing conversions of source positions to a common coordinate system and epoch. |
void |
turnOnPositionConversion()
Tells this filter to perform conversions of source positions to a common coordinate system and epoch before filtering on position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Date CURRENT_TIME
public static final boolean INCLUDE_ALIASES
public static final boolean EXCLUDE_ALIASES
Constructor Detail |
---|
public SourceFilter()
Method Detail |
---|
public void clearAll()
public void clearPositionFilter()
public void clearBrightnessFilters()
public void clearNamePattern()
setNamePattern(Pattern, boolean)
,
setNamePattern(String, boolean)
public void clearUserDefinedValues()
public void clearCoordSysAndEpoch()
equatorial
and the epoch to Epoch.J2000
.
This method does not effect the decision to turn
conversions on or off.
turnOffPositionConversion()
,
turnOnPositionConversion()
public void turnOffPositionConversion()
A newly created or cleared filter will have conversion turned on.
public void turnOnPositionConversion()
turnOffPositionConversion()
public void clearQueryTime()
allows(Source)
or
blocks(Source)
methods.
public void setNamePattern(String regex, boolean includeAliases) throws PatternSyntaxException
regex
are allowed
to pass through this filter. If sources should not be filtered
based on their names, call clearNamePattern()
.
regex
- a regular expression for matching the names of sources.includeAliases
- if true, sources with an alias matching regex
will pass this criterion.
PatternSyntaxException
public void setNamePattern(Pattern regex, boolean includeAliases)
regex
are allowed
to pass through this filter. If sources should not be filtered
based on their names, call clearNamePattern()
.
regex
- a regular expression for matching the names of sources.includeAliases
- if true, sources with an alias matching regex
will pass this criterion.public void setPositionFilter(SkyPositionFilter posFilter)
blocks
and allows
methods.
If sources should not be filtered based on their position,
call clearPositionFilter()
or send a null to
this method.
posFilter
- a filter to be used on the position of a source.public void setCoordSysAndEpoch(CelestialCoordinateSystem newSys, Epoch newEpoch)
newSys
- the new coordinate system. If this value is null, an
IllegalArgumentException will be thrown.newEpoch
- the new epoch. If this value is null, it will be
treated as Epoch.UNKNOWN.turnOffPositionConversion()
public void addBrightnessFilter(SourceBrightnessFilter sbFilter)
blocks
and allows
methods.
If sources should not be filtered based on their brightnesses,
call clearBrightnessFilters()
.
sbFilter
- a filter to be used on the brightnesses of
a source.public void setQueryTime(Date time)
time
- the time used by the allows(Source)
and blocks(Source)
methods when
querying a source.public void addRequiredUserDefinedKey(String udKey)
UDV
for udKey
.
The particular value it holds for that key, though, is immaterial.
This is a convenience method that is equivalent to both
addRequiredUserDefinedValues(udKey, null)
and
replaceRequiredUserDefinedValues(udKey, null)
.
udKey
- the key for a user defined value that a source must have in order to
pass through this filter. A value of null will be ignored.public void addRequiredUserDefinedValues(String udKey, Set<String> additionalUdvs)
UDV
for udKey
, and the
value it has for that key must be in the set of values this filter
holds for that key.
The effects of subsequent calls with the same key are cumulative. For example, imagine we have a block of (psuedo-)code like this:
filter.addRequiredUserDefinedValues("stooge", ["Larry", "Moe", "Curly"]); ... filter.addRequiredUserDefinedValues("stooge", ["Shemp", "Curly Joe"]);After such a setup, filter will continue to allow sources with a UDV key of "stooge" and a value of "Curly" to pass, demonstrating that "Shemp" and "Curly Joe" were added to the original values and did not replace them.
If this filter has no entry for udKey
, this method creates one
and sets its values to additionalUdvs
.
This method will remove udKey
from its set of
forbidden
keys, if present.
udKey
- the key for a user defined value that a source must have in order to
pass through this filter. A value of null will be ignored.additionalUdvs
- a set of values for udKey
. In order for a source to pass through
this filter its UDV for udKey
must be contained in this set
(see note above regarding consecutive calls to this method).
A special value of null may be used to indicate that the presence
of the key is required, but the value associated with that key is
immaterial.addForbiddenUserDefinedKey(String)
,
addRequiredUserDefinedKey(String)
,
replaceRequiredUserDefinedValues(String, Set)
public void replaceRequiredUserDefinedValues(String udKey, Set<String> replacementUdvs)
UDV
for udKey
, and the
value it has for that key must be in the replacementUdvs
set.
Contrast the behavior of this method with
addRequiredUserDefinedValues(String, Set)
:
filter.addRequiredUserDefinedValues("stooge", ["Larry", "Moe", "Curly"]); ... filter.addRequiredUserDefinedValues("stooge", ["Larry", "Moe", "Shemp"]);After the second call, sources whose "stooge" is "Curly" will no longer pass through this filter.
If this filter has no entry for udKey
, this method creates one
and sets its values to replacementUdvs
.
This method will remove udKey
from its set of
forbidden
keys, if present.
udKey
- the key for a user defined value that a source must have in order to
pass through this filter. A value of null will be ignored.replacementUdvs
- a set of values for udKey
. In order for a source to pass through
this filter its UDV for udKey
must be contained in this set.
A special value of null may be used to indicate that the presence
of the key is required, but the value associated with that key is
immaterial.addForbiddenUserDefinedKey(String)
,
addRequiredUserDefinedKey(String)
,
addRequiredUserDefinedValues(String, Set)
public void removeRequiredUserDefinedValue(String udKey)
udKey
from this filter's collection of
UDV
keys that passing sources
must possess.
udKey
- a key for a user-defined value
(UDV) of a source.addRequiredUserDefinedKey(String)
,
addRequiredUserDefinedValues(String, Set)
,
clearUserDefinedValues()
,
replaceRequiredUserDefinedValues(String, Set)
public void addForbiddenUserDefinedKey(String udKey)
UDV
for udKey
.
Any source holding such a key, no matter the value associated with
that key, will be blocked by this filter.
This method will remove udKey
from its set of
required
keys, if present.
udKey
- a key for a user-defined value
(UDV) of a source. A value of null will be ignored.addRequiredUserDefinedKey(String)
,
clearUserDefinedValues()
,
removeForbiddenUserDefinedKey(String)
public void removeForbiddenUserDefinedKey(String udKey)
udKey
from this filter's collection of
UDV
keys that passing sources
must not possess.
udKey
- a key for a user-defined value
(UDV) of a source. A value of null will be ignored.clearUserDefinedValues()
,
addForbiddenUserDefinedKey(String)
public boolean blocks(Source src)
The logic for allowing or blocking a source is somewhat complex. Some of the details about which clients should be aware are:
SphericalPositionFilter
and a
SourceBrightnessFilter
each carries its own
query time, this filter will ensure that its component
filters are using the same time as that specified directly
to this filter.central subsource
.
blocks
in interface Filter<Source>
src
- the source to be filtered.
src
.public boolean allows(Source src)
The logic for allowing or blocking a source is somewhat complex.
See blocks(Source)
for details.
allows
in interface Filter<Source>
src
- the source to be filtered.
src
to pass through it.public Collection<Source> selectFrom(Collection<?> bag)
bag
that are sources and that can pass
through this filter. The selections are added to a new collection and
returned. If the bag holds no such objects, the returned collection
will be empty.
The original collection (bag
) is not altered.
bag
- a collection of objects.
bag
that were able to
pass through this filter.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |