Package org.zkoss.zk.ui.metainfo
Class ZScriptInfo
- java.lang.Object
-
- org.zkoss.zk.ui.metainfo.ZScriptInfo
-
public class ZScriptInfo extends java.lang.ObjectRepresents a zscript element.- Since:
- 6.0.0
- Author:
- tomyeh
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ZScriptInfo(NodeInfo parent, java.lang.String zslang, java.lang.String url, org.zkoss.util.resource.Locator locator, ConditionImpl cond)Constructs aZScriptInfowith an URL, which might contain an EL expression.ZScriptInfo(NodeInfo parent, java.lang.String zslang, java.lang.String content, ConditionImpl cond)Creates aZScriptInfowith the content directly.ZScriptInfo(NodeInfo parent, java.lang.String zslang, java.net.URL url, ConditionImpl cond)Create aZScriptInfowith an URL that is used to load the content.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendChild(NodeInfo child)Append a childjava.util.List<NodeInfo>getChildren()Returns a readonly list of children.java.lang.StringgetContent(Page page, Component comp)Returns the content of zscript.EvaluatorgetEvaluator()Returns the evaluator.EvaluatorRefgetEvaluatorRef()Returns the evaluator reference.java.lang.StringgetLanguage()Returns the scripting language, or null if the default scripting language is preferred.PageDefinitiongetPageDefinition()Returns the page definition, i.e., the root node, or null if not available.NodeInfogetParent()Returns the parent, or null if it has no parent.java.lang.StringgetRawContent()Returns the raw content.ZScriptgetZScript()Returns theZScriptobject hold in this info.booleanisDeferred()Returns whether the evaluation of the zscript shall be deferred.booleanisEffective(Component comp)Used to evaluate whether it is effective.booleanisEffective(Page page)Used to evaluate whether it is effective.booleanremoveChild(NodeInfo child)Removes a child.voidsetCondition(ConditionImpl cond)Sets the effectiveness condition.voidsetDeferred(boolean deferred)Sets whether the evaluation of the zscript shall be deferred.voidsetLanguage(java.lang.String zslang)Sets the scripting language.java.lang.StringtoString()booleanwithCondition()Tests if the condition is set
-
-
-
Constructor Detail
-
ZScriptInfo
public ZScriptInfo(NodeInfo parent, java.lang.String zslang, java.lang.String content, ConditionImpl cond)
Creates aZScriptInfowith the content directly.- Parameters:
zslang- the scripting language. If null, it is the same asPage.getZScriptLanguage().content- the zscript content
-
ZScriptInfo
public ZScriptInfo(NodeInfo parent, java.lang.String zslang, java.net.URL url, ConditionImpl cond)
Create aZScriptInfowith an URL that is used to load the content.- Parameters:
url- the URL to load the content of zscript.
-
ZScriptInfo
public ZScriptInfo(NodeInfo parent, java.lang.String zslang, java.lang.String url, org.zkoss.util.resource.Locator locator, ConditionImpl cond)
Constructs aZScriptInfowith an URL, which might contain an EL expression.- Parameters:
url- the URL. It may contain XEL expressions.locator- the locator used to locate the zscript file
-
-
Method Detail
-
getLanguage
public java.lang.String getLanguage()
Returns the scripting language, or null if the default scripting language is preferred.
-
setLanguage
public void setLanguage(java.lang.String zslang)
Sets the scripting language.- Parameters:
zslang- the scripting language. If null, the default scripting language is assume.
-
getRawContent
public java.lang.String getRawContent()
Returns the raw content. It is the content specified in the constructor (ZScriptInfo(NodeInfo, String, String, ConditionImpl). If URL is specified in the constructor, null is returned.On the other hand,
getContent(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component)will load the content automatically if URL is specified.- Returns:
- the raw content specified in the constructor, or null if URL is specified instead.
-
getContent
public java.lang.String getContent(Page page, Component comp)
Returns the content of zscript. If URL is specified, this method loads the content from it. If URL is an EL expression, it will be evaluated first.Note: before evaluating the returned script, you have to invoke
Condition.isEffective(Component)orCondition.isEffective(Page)first.- Parameters:
page- the page when this zscript is interpreted. Used only if this object is constructed withZScriptInfo(NodeInfo, String, String, Locator, ConditionImpl).comp- the component when this zscript is interpreted. Used only if this object is constructed withZScriptInfo(NodeInfo, String, String, Locator, ConditionImpl).- Throws:
UiException- if failed to load the content
-
isDeferred
public boolean isDeferred()
Returns whether the evaluation of the zscript shall be deferred.
-
setDeferred
public void setDeferred(boolean deferred)
Sets whether the evaluation of the zscript shall be deferred.Default: false.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setCondition
public void setCondition(ConditionImpl cond)
Sets the effectiveness condition.
-
withCondition
public boolean withCondition()
Tests if the condition is set
-
isEffective
public boolean isEffective(Component comp)
Description copied from interface:ConditionUsed to evaluate whether it is effective.- Specified by:
isEffectivein interfaceCondition- Parameters:
comp- used as the self variable. Ignored if null.
-
isEffective
public boolean isEffective(Page page)
Description copied from interface:ConditionUsed to evaluate whether it is effective.- Specified by:
isEffectivein interfaceCondition- Parameters:
page- used as the self variable. Ignored if null.
-
getEvaluatorRef
public EvaluatorRef getEvaluatorRef()
Description copied from interface:NodeInfoReturns the evaluator reference.- Specified by:
getEvaluatorRefin interfaceNodeInfo
-
getPageDefinition
public PageDefinition getPageDefinition()
Description copied from interface:NodeInfoReturns the page definition, i.e., the root node, or null if not available.- Specified by:
getPageDefinitionin interfaceNodeInfo
-
getEvaluator
public Evaluator getEvaluator()
Description copied from interface:NodeInfoReturns the evaluator.All nodes in the same ZUML tree has the same evaluator reference (inherited from the root node,
PageDefinition.getEvaluatorRef()).- Specified by:
getEvaluatorin interfaceNodeInfo
-
getParent
public NodeInfo getParent()
Description copied from interface:NodeInfoReturns the parent, or null if it has no parent.
-
getChildren
public java.util.List<NodeInfo> getChildren()
Description copied from interface:NodeInfoReturns a readonly list of children.Note: the returned list is readonly. To modify, please use
NodeInfo.appendChild(org.zkoss.zk.ui.metainfo.NodeInfo)andNodeInfo.removeChild(org.zkoss.zk.ui.metainfo.NodeInfo)instead.- Specified by:
getChildrenin interfaceNodeInfo
-
appendChild
public void appendChild(NodeInfo child)
Description copied from interface:NodeInfoAppend a child- Specified by:
appendChildin interfaceNodeInfo
-
removeChild
public boolean removeChild(NodeInfo child)
Description copied from interface:NodeInfoRemoves a child.- Specified by:
removeChildin interfaceNodeInfo
-
-