Package adql.search
Class SimpleSearchHandler
java.lang.Object
adql.search.SimpleSearchHandler
- All Implemented Interfaces:
ISearchHandler
,Iterable<ADQLObject>
- Direct Known Subclasses:
SearchColumnHandler
,SimpleReplaceHandler
Lets searching ADQL objects which match with the condition defined in the function match(ADQLObject)
.
- By default, this search handler does not search recursively (that's to say, it does not search in sub-queries).
- By default, this search handler does not stop to the first matching object.
- The matching objects are simply collected in an ArrayList.
- Version:
- 1.2 (12/2013)
- Author:
- Grégory Mantelet (CDS;ARI)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ArrayList<ADQLObject>
List of all matching ADQL objects. -
Constructor Summary
ConstructorsConstructorDescriptionBuilds a SimpleSearchHandler:SimpleSearchHandler
(boolean recursive) Builds a SimpleSearchHandler which does not stop at the first match.SimpleSearchHandler
(boolean recursive, boolean onlyFirstMatch) Builds a SimpleSearchHandler. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addMatch
(ADQLObject matchObj, ADQLIterator it) Adds the given ADQL object as one result of the research.final int
Indicates how many ADQL objects have matched.protected boolean
goInto
(ADQLObject obj) Indicates whether the research must continue inside the given ADQL object or not: by default, it returns always true except if the given object is an ADQL query while the research must not be recursive.protected boolean
Indicates whether the research must finish now or not: by default, the research ends only at the first match if it has been asked (seesetOnlyFirstMatch(boolean)
).final boolean
Tells whether this handler must search also in sub-queries.final Iterator<ADQLObject>
iterator()
Lets to iterate on the list of all the matched ADQL objects.protected abstract boolean
match
(ADQLObject obj) Only tests whether the given ADQL object checks the search conditions.final boolean
Tells whether this handler must stop at the first match.protected void
reset()
Resets this handler before the beginning of the research: by default, the list of results is cleared.final void
search
(ADQLObject startObj) Searches all matching ADQL objects from the given ADQL object (included).final void
setOnlyFirstMatch
(boolean firstMatch) Lets configuring this handler so that it must stop at the first match.final void
setRecursive
(boolean recursive) Lets configuring this handler so that it must search also in sub-queries or not.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
results
List of all matching ADQL objects.
-
-
Constructor Details
-
SimpleSearchHandler
public SimpleSearchHandler()Builds a SimpleSearchHandler:
- not recursive,
- and which does not stop at the first match.
-
SimpleSearchHandler
public SimpleSearchHandler(boolean recursive) Builds a SimpleSearchHandler which does not stop at the first match.- Parameters:
recursive
- true to search also in sub-queries, false otherwise.
-
SimpleSearchHandler
public SimpleSearchHandler(boolean recursive, boolean onlyFirstMatch) Builds a SimpleSearchHandler.- Parameters:
recursive
- true to search also in sub-queries, false otherwise.onlyFirstMatch
- true to stop at the first match, false otherwise.
-
-
Method Details
-
isRecursive
public final boolean isRecursive()Tells whether this handler must search also in sub-queries.- Returns:
- true if recursive, false otherwise.
-
setRecursive
public final void setRecursive(boolean recursive) Lets configuring this handler so that it must search also in sub-queries or not.- Parameters:
recursive
- true to search recursively, false otherwise.
-
onlyFirstMatch
public final boolean onlyFirstMatch()Tells whether this handler must stop at the first match.- Returns:
- true if it stops at the first match, false otherwise.
-
setOnlyFirstMatch
public final void setOnlyFirstMatch(boolean firstMatch) Lets configuring this handler so that it must stop at the first match.- Parameters:
firstMatch
- true if it must stop at the first match, false otherwise.
-
iterator
Description copied from interface:ISearchHandler
Lets to iterate on the list of all the matched ADQL objects.- Specified by:
iterator
in interfaceISearchHandler
- Specified by:
iterator
in interfaceIterable<ADQLObject>
- See Also:
-
getNbMatch
public final int getNbMatch()Description copied from interface:ISearchHandler
Indicates how many ADQL objects have matched.- Specified by:
getNbMatch
in interfaceISearchHandler
- Returns:
- The number of all the matched ADQL objects.
-
isFinished
protected boolean isFinished()Indicates whether the research must finish now or not: by default, the research ends only at the first match if it has been asked (seesetOnlyFirstMatch(boolean)
).- Returns:
- true if the research must end now, false otherwise.
-
goInto
Indicates whether the research must continue inside the given ADQL object or not: by default, it returns always true except if the given object is an ADQL query while the research must not be recursive.- Parameters:
obj
- An ADQL object.- Returns:
- true if the research must continue inside the given ADQL object, false otherwise.
-
addMatch
Adds the given ADQL object as one result of the research.Warning: the second parameter (it) may be null if the given match is the root search object itself.
- Parameters:
matchObj
- An ADQL object which has matched to the research criteria.it
- The iterator from which the matched ADQL object has been extracted.
-
reset
protected void reset()Resets this handler before the beginning of the research: by default, the list of results is cleared. -
search
Description copied from interface:ISearchHandler
Searches all matching ADQL objects from the given ADQL object (included).- Specified by:
search
in interfaceISearchHandler
- Parameters:
startObj
- The ADQL object from which the search must start.
-
match
Only tests whether the given ADQL object checks the search conditions.- Parameters:
obj
- The ADQL object to test. (warning: this object may be null !)- Returns:
- true if the given object checks the search conditions, false otherwise.
-