Package org.zkoss.zats.mimic.impl
Class DefaultComponentAgent
- java.lang.Object
-
- org.zkoss.zats.mimic.impl.DefaultComponentAgent
-
- All Implemented Interfaces:
Agent,ComponentAgent,QueryAgent
public class DefaultComponentAgent extends Object implements ComponentAgent
The default implement of component agent. This performs operations throughOperationAgentManager.- Author:
- pao
-
-
Constructor Summary
Constructors Constructor Description DefaultComponentAgent(PageAgent pageAgent, org.zkoss.zk.ui.Component component)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tas(Class<T> clazz)Try to get a instance of target class for this query agent, the target class is usually aOperationAgentor a nativeComponent
if it cannot get a instance of target class, it will throwAgentException.voidblur()Blur this component, it is a short cut ofFocusAgent.blur()voidcheck(boolean checked)Check this component, it is a short cut ofCheckAgent.check(boolean)voidclick()Click on this component, A short cut ofClickAgent.click()voiddump()booleanequals(Object obj)voidfocus()Focus this component, it is a short cut ofFocusAgent.focus()ObjectgetAttribute(String name)get attribute by specify name.ComponentAgentgetChild(int index)get child by specify index.List<ComponentAgent>getChildren()get children agents.ClientgetClient()get client this agent belonged to.ObjectgetDelegatee()get the delegatee objectDesktopAgentgetDesktop()get desktop agent this component belonged to.ComponentAgentgetFirstChild()Returns the first child, if any.StringgetId()get ID.ComponentAgentgetLastChild()Returns the last child, if any.ComponentAgentgetNextSibling()Returns the next sibling, if any.<T extends org.zkoss.zk.ui.Component>
TgetOwner()Returns the associated owner component of this agentPageAgentgetPage()get page agent this component belonged to.ComponentAgentgetParent()get parent agent.ComponentAgentgetPreviousSibling()Returns the previous sibling, if any.StringgetType()StringgetUuid()get UUID.inthashCode()voidinput(Object value)Input to this component, it is a short cut ofInputAgent.input(Object)<T> booleanis(Class<T> clazz)Can get a instance of target class for this query agent.ComponentAgentquery(String selector)to find the first component agent with the selector in this query agent.List<ComponentAgent>queryAll(String selector)to find the component agents with the selector in this query agent.voidselect()Select this component, it is a short cut ofSelectAgent.select()voidstroke(String key)Stroke a key on this component, it is a short cut ofKeyStrokeAgent.stroke(String)StringtoString()voidtype(String value)Type on this component, it is a short cut ofInputAgent.type(String)
-
-
-
Constructor Detail
-
DefaultComponentAgent
public DefaultComponentAgent(PageAgent pageAgent, org.zkoss.zk.ui.Component component)
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:ComponentAgentget ID. of the component.- Specified by:
getIdin interfaceComponentAgent- Returns:
- ID or null if it hasn't.
-
getType
public String getType()
-
getAttribute
public Object getAttribute(String name)
Description copied from interface:ComponentAgentget attribute by specify name.- Specified by:
getAttributein interfaceComponentAgent- Parameters:
name- attribute name.- Returns:
- attribute value or null if not found or otherwise.
-
getUuid
public String getUuid()
Description copied from interface:ComponentAgentget UUID. of the component.- Specified by:
getUuidin interfaceComponentAgent- Returns:
- UUID.
-
getChildren
public List<ComponentAgent> getChildren()
Description copied from interface:ComponentAgentget children agents.- Specified by:
getChildrenin interfaceComponentAgent- Returns:
- always return a list of children (may be empty).
-
getFirstChild
public ComponentAgent getFirstChild()
Description copied from interface:ComponentAgentReturns the first child, if any.- Specified by:
getFirstChildin interfaceComponentAgent- Returns:
- the first child agent or null.
-
getLastChild
public ComponentAgent getLastChild()
Description copied from interface:ComponentAgentReturns the last child, if any.- Specified by:
getLastChildin interfaceComponentAgent- Returns:
- the last child agent or null.
-
getNextSibling
public ComponentAgent getNextSibling()
Description copied from interface:ComponentAgentReturns the next sibling, if any.- Specified by:
getNextSiblingin interfaceComponentAgent- Returns:
- the next sibling agent or null.
-
getPreviousSibling
public ComponentAgent getPreviousSibling()
Description copied from interface:ComponentAgentReturns the previous sibling, if any.- Specified by:
getPreviousSiblingin interfaceComponentAgent- Returns:
- the previous sibling agent or null.
-
getChild
public ComponentAgent getChild(int index)
Description copied from interface:ComponentAgentget child by specify index.- Specified by:
getChildin interfaceComponentAgent- Returns:
- child agent or null if index is out of boundary.
-
getParent
public ComponentAgent getParent()
Description copied from interface:ComponentAgentget parent agent.- Specified by:
getParentin interfaceComponentAgent- Returns:
- parent agent or null if this is root agent.
-
getClient
public Client getClient()
Description copied from interface:Agentget client this agent belonged to.
-
getDesktop
public DesktopAgent getDesktop()
Description copied from interface:ComponentAgentget desktop agent this component belonged to.- Specified by:
getDesktopin interfaceComponentAgent- Returns:
- desktop agent.
-
getPage
public PageAgent getPage()
Description copied from interface:ComponentAgentget page agent this component belonged to.- Specified by:
getPagein interfaceComponentAgent- Returns:
- page agent.
-
as
public <T> T as(Class<T> clazz)
Description copied from interface:QueryAgentTry to get a instance of target class for this query agent, the target class is usually aOperationAgentor a nativeComponent
if it cannot get a instance of target class, it will throwAgentException.- Specified by:
asin interfaceQueryAgent- Parameters:
clazz- class of specify operation.- Returns:
- operation object.
-
is
public <T> boolean is(Class<T> clazz)
Description copied from interface:QueryAgentCan get a instance of target class for this query agent.- Specified by:
isin interfaceQueryAgent- Parameters:
clazz- the class cast to.- Returns:
- true if can get a instance of target class
-
query
public ComponentAgent query(String selector)
Description copied from interface:QueryAgentto find the first component agent with the selector in this query agent.- Specified by:
queryin interfaceQueryAgent- Parameters:
selector- the selector- Returns:
- the first component agent, null if not found
-
queryAll
public List<ComponentAgent> queryAll(String selector)
Description copied from interface:QueryAgentto find the component agents with the selector in this query agent.- Specified by:
queryAllin interfaceQueryAgent- Parameters:
selector- the selector- Returns:
- the component agents
-
dump
public void dump()
-
getDelegatee
public Object getDelegatee()
Description copied from interface:Agentget the delegatee object- Specified by:
getDelegateein interfaceAgent
-
getOwner
public <T extends org.zkoss.zk.ui.Component> T getOwner()
Description copied from interface:ComponentAgentReturns the associated owner component of this agent- Specified by:
getOwnerin interfaceComponentAgent- Returns:
-
click
public void click()
Description copied from interface:ComponentAgentClick on this component, A short cut ofClickAgent.click()If this component doesn't supportClickAgent, it will throw exception.- Specified by:
clickin interfaceComponentAgent- See Also:
QueryAgent.as(Class),ClickAgent
-
type
public void type(String value)
Description copied from interface:ComponentAgentType on this component, it is a short cut ofInputAgent.type(String)If this component doesn't supportInputAgent, it will throw exception.- Specified by:
typein interfaceComponentAgent- See Also:
QueryAgent.as(Class),InputAgent
-
input
public void input(Object value)
Description copied from interface:ComponentAgentInput to this component, it is a short cut ofInputAgent.input(Object)If this component doesn't supportInputAgent, it will throw exception.- Specified by:
inputin interfaceComponentAgent- See Also:
QueryAgent.as(Class),InputAgent
-
focus
public void focus()
Description copied from interface:ComponentAgentFocus this component, it is a short cut ofFocusAgent.focus()If this component doesn't supportFocusAgent, it will throw exception.- Specified by:
focusin interfaceComponentAgent- See Also:
QueryAgent.as(Class),FocusAgent
-
blur
public void blur()
Description copied from interface:ComponentAgentBlur this component, it is a short cut ofFocusAgent.blur()If this component doesn't supportFocusAgent, it will throw exception.- Specified by:
blurin interfaceComponentAgent- See Also:
QueryAgent.as(Class),FocusAgent
-
check
public void check(boolean checked)
Description copied from interface:ComponentAgentCheck this component, it is a short cut ofCheckAgent.check(boolean)If this component doesn't supportCheckAgent, it will throw exception.- Specified by:
checkin interfaceComponentAgent- See Also:
QueryAgent.as(Class),CheckAgent
-
stroke
public void stroke(String key)
Description copied from interface:ComponentAgentStroke a key on this component, it is a short cut ofKeyStrokeAgent.stroke(String)If this component doesn't supportKeyStrokeAgent, it will throw exception.- Specified by:
strokein interfaceComponentAgent- See Also:
QueryAgent.as(Class),KeyStrokeAgent
-
select
public void select()
Description copied from interface:ComponentAgentSelect this component, it is a short cut ofSelectAgent.select()If this component doesn't supportSelectAgent, it will throw exception.- Specified by:
selectin interfaceComponentAgent- See Also:
QueryAgent.as(Class),SelectAgent
-
-