Package org.mozilla.zest.core.v1
Class ZestConditional
- java.lang.Object
-
- org.mozilla.zest.core.v1.ZestElement
-
- org.mozilla.zest.core.v1.ZestStatement
-
- org.mozilla.zest.core.v1.ZestConditional
-
- All Implemented Interfaces:
ZestContainer
public class ZestConditional extends ZestStatement implements ZestContainer
The Class ZestConditional.
-
-
Field Summary
-
Fields inherited from class org.mozilla.zest.core.v1.ZestElement
JSON_ELEMENT_TYPE
-
-
Constructor Summary
Constructors Constructor Description ZestConditional()Instantiates a new zest conditional.ZestConditional(int index)Instantiates a new zest conditional with a statement index.ZestConditional(int index, ZestExpressionElement rootExp)Instantiates a new zest conditional.ZestConditional(ZestExpressionElement rootExp)Instantiates a new zest conditional.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddElse(int index, ZestStatement req)Adds an else.voidaddElse(ZestStatement req)Adds an else.voidaddIf(int index, ZestStatement req)Adds an if.voidaddIf(ZestStatement req)Adds an if statement.ZestStatementdeepCopy()Deep copy.ZestStatementgetChildBefore(ZestStatement child)Gets the child before.List<ZestStatement>getChildren()Returns all of the containers immediate childrenZestStatementgetElseStatement(int index)Gets the else statement in a given index.List<ZestStatement>getElseStatements()Gets the else statements list.ZestStatementgetIfStatement(int index)Gets the if statement.List<ZestStatement>getIfStatements()Gets the if statements list.intgetIndex(ZestStatement child)Gets the index.ZestStatementgetLast()Gets the last.ZestExpressionElementgetRootExpression()Gets the root expression.ZestStatementgetStatement(int index)Gets the statement.Set<String>getVariableNames()Returns all of the variable names defined by this staement and its children.booleanisPassive()Checks if is passive.booleanisSameSubclass(ZestElement ze)Checks if is same subclass.booleanisTrue(ZestRuntime runtime)Checks if the conditional is true.voidmove(int index, ZestStatement stmt)Move.voidmoveElse(int index, ZestStatement req)Moves an else.voidmoveIf(int index, ZestStatement req)Moves if.voidremoveElse(ZestStatement req)Removes an else.voidremoveElseStatement(int index)Removes an else statement.voidremoveIf(ZestStatement req)Removes an if.voidremoveIfStatement(int index)Removes an if statement.voidsetPrefix(String oldPrefix, String newPrefix)protected ZestStatementsetPrev(ZestStatement prev)ZestExpressionElementsetRootExpression(ZestExpressionElement new_root)Sets the root expression.-
Methods inherited from class org.mozilla.zest.core.v1.ZestStatement
getIndex, getNext, getPrevious, init, insertAfter, insertBefore, isEnabled, remove, setEnabled, setNext
-
Methods inherited from class org.mozilla.zest.core.v1.ZestElement
getElementType, setElementType
-
-
-
-
Constructor Detail
-
ZestConditional
public ZestConditional()
Instantiates a new zest conditional.
-
ZestConditional
public ZestConditional(ZestExpressionElement rootExp)
Instantiates a new zest conditional.- Parameters:
rootExp- the root exp
-
ZestConditional
public ZestConditional(int index)
Instantiates a new zest conditional with a statement index.- Parameters:
index- the index
-
ZestConditional
public ZestConditional(int index, ZestExpressionElement rootExp)Instantiates a new zest conditional.- Parameters:
index- the indexrootExp- the root exp
-
-
Method Detail
-
addIf
public void addIf(ZestStatement req)
Adds an if statement.- Parameters:
req- the Statement to add as If
-
addIf
public void addIf(int index, ZestStatement req)Adds an if.- Parameters:
index- the index of the new statement in the if listreq- the statement to add as If at position index
-
moveIf
public void moveIf(int index, ZestStatement req)Moves if.- Parameters:
index- the new indexreq- the statement to move
-
removeIf
public void removeIf(ZestStatement req)
Removes an if.- Parameters:
req- the if statement to remove
-
removeIfStatement
public void removeIfStatement(int index)
Removes an if statement.- Parameters:
index- the index of the statement to remove
-
getIfStatement
public ZestStatement getIfStatement(int index)
Gets the if statement.- Parameters:
index- the index- Returns:
- the if statement at index
- Throws:
IndexOutOfBoundsException- the index out of bounds exception
-
getIfStatements
public List<ZestStatement> getIfStatements()
Gets the if statements list.- Returns:
- the if statements list
-
addElse
public void addElse(ZestStatement req)
Adds an else.- Parameters:
req- the statement to add as else
-
getChildren
public List<ZestStatement> getChildren()
Description copied from interface:ZestContainerReturns all of the containers immediate children- Specified by:
getChildrenin interfaceZestContainer- Returns:
- the children
-
addElse
public void addElse(int index, ZestStatement req)Adds an else.- Parameters:
index- the index where to add the else statementreq- the new else statement
-
moveElse
public void moveElse(int index, ZestStatement req)Moves an else.- Parameters:
index- the destination of the else statementreq- the else statement to move
-
removeElse
public void removeElse(ZestStatement req)
Removes an else.- Parameters:
req- the else statement to remove
-
removeElseStatement
public void removeElseStatement(int index)
Removes an else statement.- Parameters:
index- the index of the else statement to remove
-
getElseStatement
public ZestStatement getElseStatement(int index)
Gets the else statement in a given index.- Parameters:
index- the index- Returns:
- the else statement at the given index
- Throws:
IndexOutOfBoundsException- the index out of bounds exception
-
getElseStatements
public List<ZestStatement> getElseStatements()
Gets the else statements list.- Returns:
- the else statements list
-
getIndex
public int getIndex(ZestStatement child)
Description copied from interface:ZestContainerGets the index.- Specified by:
getIndexin interfaceZestContainer- Parameters:
child- the child- Returns:
- the index
-
move
public void move(int index, ZestStatement stmt)Description copied from interface:ZestContainerMove.- Specified by:
movein interfaceZestContainer- Parameters:
index- the indexstmt- the stmt
-
isSameSubclass
public boolean isSameSubclass(ZestElement ze)
Description copied from class:ZestElementChecks if is same subclass.- Overrides:
isSameSubclassin classZestStatement- Parameters:
ze- the ze- Returns:
- true, if is same subclass
-
setPrefix
public void setPrefix(String oldPrefix, String newPrefix) throws MalformedURLException
- Throws:
MalformedURLException
-
getVariableNames
public Set<String> getVariableNames()
Description copied from interface:ZestContainerReturns all of the variable names defined by this staement and its children.- Specified by:
getVariableNamesin interfaceZestContainer- Returns:
- the tokens
-
getLast
public ZestStatement getLast()
Description copied from interface:ZestContainerGets the last.- Specified by:
getLastin interfaceZestContainer- Returns:
- the last
-
getChildBefore
public ZestStatement getChildBefore(ZestStatement child)
Description copied from interface:ZestContainerGets the child before.- Specified by:
getChildBeforein interfaceZestContainer- Parameters:
child- the child- Returns:
- the child before
-
getStatement
public ZestStatement getStatement(int index)
Description copied from interface:ZestContainerGets the statement.- Specified by:
getStatementin interfaceZestContainer- Parameters:
index- the index- Returns:
- the statement
-
isTrue
public boolean isTrue(ZestRuntime runtime)
Checks if the conditional is true.- Parameters:
runtime- the runtime- Returns:
- true, if the condition is true
-
getRootExpression
public ZestExpressionElement getRootExpression()
Gets the root expression.- Returns:
- the root expression
-
setRootExpression
public ZestExpressionElement setRootExpression(ZestExpressionElement new_root)
Sets the root expression.- Parameters:
new_root- the new_root expression- Returns:
- the zest previous root expression
-
deepCopy
public ZestStatement deepCopy()
Description copied from class:ZestElementDeep copy.- Specified by:
deepCopyin classZestStatement- Returns:
- the zest element
-
isPassive
public boolean isPassive()
Description copied from class:ZestStatementChecks if is passive.- Specified by:
isPassivein classZestStatement- Returns:
- true, if is passive
-
setPrev
protected ZestStatement setPrev(ZestStatement prev)
- Overrides:
setPrevin classZestStatement
-
-