Package mgui.interfaces.queries
Class InterfaceQuery
java.lang.Object
mgui.interfaces.queries.InterfaceQuery
- All Implemented Interfaces:
InterfaceObject
,NamedObject
,TreeObject
,CleanableObject
,IconObject
- Direct Known Subclasses:
InterfaceShapeQuery
public abstract class InterfaceQuery extends java.lang.Object implements InterfaceObject, IconObject
Interface for a class which allows it to query a given
InterfaceQueryObject
. Queries are
classes which obtain information about an object and store it as a set of QueryResult
s.- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<QueryListener>
listeners
protected java.lang.String
name
protected java.util.HashMap<InterfaceQueryObject,QueryResult>
results
protected java.util.ArrayList<InterfaceQueryObject>
sorted_objects
-
Constructor Summary
Constructors Constructor Description InterfaceQuery()
-
Method Summary
Modifier and Type Method Description void
addListener(QueryListener listener)
Adds a query listener to this query.protected void
addResult(QueryResult result)
Adds a result to this query; if a result from this object already exists, it is replaced, and moved to the end of the list.abstract boolean
canQuery(InterfaceQueryObject object)
Determines whether this query instance can query the givenInterfaceQueryObject
.void
clean()
Instructs this object to search its members for any object which has been destroyed, and release the pointer to it.void
clearResults()
Clears the results currently stored in this query.void
destroy()
Destroy this object (prepare it to be removed from memory)protected void
fireListeners()
QueryResult
getLastResult()
Returns the last query result.java.lang.String
getName()
Gets the name for this object.abstract InterfaceQuery
getNewInstance(java.lang.String name)
Returns a new instance of this class of query.javax.swing.Icon
getObjectIcon()
Returns theIcon
associated with this object.java.util.ArrayList<InterfaceQueryObject>
getObjects()
Returns a list of the objects for which this query has results, in the order they were added.java.lang.Object
getResult(java.lang.String object)
Returns the result associated withobject
, if it exists; returnsnull
otherwise.java.util.ArrayList<QueryResult>
getResults()
Returns the results stored in this query, in the order they were added.InterfaceTreeNode
getResultTreeNode()
Returns a set of tree nodes containing the results of this query.java.lang.String
getTreeLabel()
Returns the label text to appear in a tree node.boolean
isDestroyed()
Test whether this object has been destroyedInterfaceTreeNode
issueTreeNode()
Issues a newInterfaceTreeNode
for this object.abstract void
query(InterfaceQueryObject object)
Performs a query on the specified query object.void
removeListener(QueryListener listener)
Removes a query listener from this query.void
setName(java.lang.String name)
Sets the name for this object.void
setTreeNode(InterfaceTreeNode node)
Sets the children for this node'sInterfaceTreeNode
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
results
-
sorted_objects
-
listeners
-
name
protected java.lang.String name
-
-
Constructor Details
-
InterfaceQuery
public InterfaceQuery()
-
-
Method Details
-
getObjectIcon
public javax.swing.Icon getObjectIcon()Description copied from interface:IconObject
Returns theIcon
associated with this object.- Specified by:
getObjectIcon
in interfaceIconObject
- Returns:
-
getName
public java.lang.String getName()Description copied from interface:NamedObject
Gets the name for this object.- Specified by:
getName
in interfaceNamedObject
- Returns:
-
setName
public void setName(java.lang.String name)Description copied from interface:NamedObject
Sets the name for this object.- Specified by:
setName
in interfaceNamedObject
-
clean
public void clean()Description copied from interface:CleanableObject
Instructs this object to search its members for any object which has been destroyed, and release the pointer to it.- Specified by:
clean
in interfaceCleanableObject
-
getResult
public java.lang.Object getResult(java.lang.String object)Returns the result associated withobject
, if it exists; returnsnull
otherwise.- Parameters:
object
-- Returns:
-
getObjects
Returns a list of the objects for which this query has results, in the order they were added.- Returns:
-
getResults
Returns the results stored in this query, in the order they were added.- Returns:
-
clearResults
public void clearResults()Clears the results currently stored in this query. -
canQuery
Determines whether this query instance can query the givenInterfaceQueryObject
.- Parameters:
object
-- Returns:
-
query
Performs a query on the specified query object. Adds a new result to the result list.- Parameters:
object
-- Throws:
ObjectNotQueriableException
-
addListener
Adds a query listener to this query.- Parameters:
listener
-
-
removeListener
Removes a query listener from this query.- Parameters:
listener
-
-
getNewInstance
Returns a new instance of this class of query.- Parameters:
name
-- Returns:
-
addResult
Adds a result to this query; if a result from this object already exists, it is replaced, and moved to the end of the list.- Parameters:
result
-
-
getResultTreeNode
Returns a set of tree nodes containing the results of this query.- Returns:
-
getLastResult
Returns the last query result.- Returns:
-
fireListeners
protected void fireListeners() -
getTreeLabel
public java.lang.String getTreeLabel()Description copied from interface:TreeObject
Returns the label text to appear in a tree node.- Specified by:
getTreeLabel
in interfaceTreeObject
- Returns:
-
issueTreeNode
Description copied from interface:TreeObject
Issues a newInterfaceTreeNode
for this object. The object is responsible for maintaining, updating, and destroying the tree nodes it issues, or notifying containers -- i.e., parent trees -- of changes which require the tree nodes to be modified or destroyed.- Specified by:
issueTreeNode
in interfaceTreeObject
- Returns:
-
setTreeNode
Description copied from interface:TreeObject
Sets the children for this node'sInterfaceTreeNode
.- Specified by:
setTreeNode
in interfaceTreeObject
-
destroy
public void destroy()Description copied from interface:InterfaceObject
Destroy this object (prepare it to be removed from memory)- Specified by:
destroy
in interfaceInterfaceObject
-
isDestroyed
public boolean isDestroyed()Description copied from interface:InterfaceObject
Test whether this object has been destroyed- Specified by:
isDestroyed
in interfaceInterfaceObject
- Returns:
-