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 QueryResults.- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<QueryListener>listenersprotected java.lang.Stringnameprotected java.util.HashMap<InterfaceQueryObject,QueryResult>resultsprotected java.util.ArrayList<InterfaceQueryObject>sorted_objects -
Constructor Summary
Constructors Constructor Description InterfaceQuery() -
Method Summary
Modifier and Type Method Description voidaddListener(QueryListener listener)Adds a query listener to this query.protected voidaddResult(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 booleancanQuery(InterfaceQueryObject object)Determines whether this query instance can query the givenInterfaceQueryObject.voidclean()Instructs this object to search its members for any object which has been destroyed, and release the pointer to it.voidclearResults()Clears the results currently stored in this query.voiddestroy()Destroy this object (prepare it to be removed from memory)protected voidfireListeners()QueryResultgetLastResult()Returns the last query result.java.lang.StringgetName()Gets the name for this object.abstract InterfaceQuerygetNewInstance(java.lang.String name)Returns a new instance of this class of query.javax.swing.IcongetObjectIcon()Returns theIconassociated 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.ObjectgetResult(java.lang.String object)Returns the result associated withobject, if it exists; returnsnullotherwise.java.util.ArrayList<QueryResult>getResults()Returns the results stored in this query, in the order they were added.InterfaceTreeNodegetResultTreeNode()Returns a set of tree nodes containing the results of this query.java.lang.StringgetTreeLabel()Returns the label text to appear in a tree node.booleanisDestroyed()Test whether this object has been destroyedInterfaceTreeNodeissueTreeNode()Issues a newInterfaceTreeNodefor this object.abstract voidquery(InterfaceQueryObject object)Performs a query on the specified query object.voidremoveListener(QueryListener listener)Removes a query listener from this query.voidsetName(java.lang.String name)Sets the name for this object.voidsetTreeNode(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:IconObjectReturns theIconassociated with this object.- Specified by:
getObjectIconin interfaceIconObject- Returns:
-
getName
public java.lang.String getName()Description copied from interface:NamedObjectGets the name for this object.- Specified by:
getNamein interfaceNamedObject- Returns:
-
setName
public void setName(java.lang.String name)Description copied from interface:NamedObjectSets the name for this object.- Specified by:
setNamein interfaceNamedObject
-
clean
public void clean()Description copied from interface:CleanableObjectInstructs this object to search its members for any object which has been destroyed, and release the pointer to it.- Specified by:
cleanin interfaceCleanableObject
-
getResult
public java.lang.Object getResult(java.lang.String object)Returns the result associated withobject, if it exists; returnsnullotherwise.- 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:TreeObjectReturns the label text to appear in a tree node.- Specified by:
getTreeLabelin interfaceTreeObject- Returns:
-
issueTreeNode
Description copied from interface:TreeObjectIssues a newInterfaceTreeNodefor 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:
issueTreeNodein interfaceTreeObject- Returns:
-
setTreeNode
Description copied from interface:TreeObjectSets the children for this node'sInterfaceTreeNode.- Specified by:
setTreeNodein interfaceTreeObject
-
destroy
public void destroy()Description copied from interface:InterfaceObjectDestroy this object (prepare it to be removed from memory)- Specified by:
destroyin interfaceInterfaceObject
-
isDestroyed
public boolean isDestroyed()Description copied from interface:InterfaceObjectTest whether this object has been destroyed- Specified by:
isDestroyedin interfaceInterfaceObject- Returns:
-