Package org.zkoss.zk.ui.metainfo
Class ZScriptInfo
- java.lang.Object
-
- org.zkoss.zk.ui.metainfo.ZScriptInfo
-
public class ZScriptInfo extends java.lang.Object
Represents 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, Locator locator, ConditionImpl cond)
Constructs aZScriptInfo
with an URL, which might contain an EL expression.ZScriptInfo(NodeInfo parent, java.lang.String zslang, java.lang.String content, ConditionImpl cond)
Creates aZScriptInfo
with the content directly.ZScriptInfo(NodeInfo parent, java.lang.String zslang, java.net.URL url, ConditionImpl cond)
Create aZScriptInfo
with an URL that is used to load the content.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendChild(NodeInfo child)
Append a childjava.util.List<NodeInfo>
getChildren()
Returns a readonly list of children.java.lang.String
getContent(Page page, Component comp)
Returns the content of zscript.Evaluator
getEvaluator()
Returns the evaluator.EvaluatorRef
getEvaluatorRef()
Returns the evaluator reference.java.lang.String
getLanguage()
Returns the scripting language, or null if the default scripting language is preferred.PageDefinition
getPageDefinition()
Returns the page definition, i.e., the root node, or null if not available.NodeInfo
getParent()
Returns the parent, or null if it has no parent.java.lang.String
getRawContent()
Returns the raw content.ZScript
getZScript()
Returns theZScript
object hold in this info.boolean
isDeferred()
Returns whether the evaluation of the zscript shall be deferred.boolean
isEffective(Component comp)
Used to evaluate whether it is effective.boolean
isEffective(Page page)
Used to evaluate whether it is effective.boolean
removeChild(NodeInfo child)
Removes a child.void
setCondition(ConditionImpl cond)
Sets the effectiveness condition.void
setDeferred(boolean deferred)
Sets whether the evaluation of the zscript shall be deferred.void
setLanguage(java.lang.String zslang)
Sets the scripting language.java.lang.String
toString()
boolean
withCondition()
Tests if the condition is set
-
-
-
Constructor Detail
-
ZScriptInfo
public ZScriptInfo(NodeInfo parent, java.lang.String zslang, java.lang.String content, ConditionImpl cond)
Creates aZScriptInfo
with 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 aZScriptInfo
with 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, Locator locator, ConditionImpl cond)
Constructs aZScriptInfo
with 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:
toString
in 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:Condition
Used to evaluate whether it is effective.- Specified by:
isEffective
in interfaceCondition
- Parameters:
comp
- used as the self variable. Ignored if null.
-
isEffective
public boolean isEffective(Page page)
Description copied from interface:Condition
Used to evaluate whether it is effective.- Specified by:
isEffective
in interfaceCondition
- Parameters:
page
- used as the self variable. Ignored if null.
-
getEvaluatorRef
public EvaluatorRef getEvaluatorRef()
Description copied from interface:NodeInfo
Returns the evaluator reference.- Specified by:
getEvaluatorRef
in interfaceNodeInfo
-
getPageDefinition
public PageDefinition getPageDefinition()
Description copied from interface:NodeInfo
Returns the page definition, i.e., the root node, or null if not available.- Specified by:
getPageDefinition
in interfaceNodeInfo
-
getEvaluator
public Evaluator getEvaluator()
Description copied from interface:NodeInfo
Returns the evaluator.All nodes in the same ZUML tree has the same evaluator reference (inherited from the root node,
PageDefinition.getEvaluatorRef()
).- Specified by:
getEvaluator
in interfaceNodeInfo
-
getParent
public NodeInfo getParent()
Description copied from interface:NodeInfo
Returns the parent, or null if it has no parent.
-
getChildren
public java.util.List<NodeInfo> getChildren()
Description copied from interface:NodeInfo
Returns 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:
getChildren
in interfaceNodeInfo
-
appendChild
public void appendChild(NodeInfo child)
Description copied from interface:NodeInfo
Append a child- Specified by:
appendChild
in interfaceNodeInfo
-
removeChild
public boolean removeChild(NodeInfo child)
Description copied from interface:NodeInfo
Removes a child.- Specified by:
removeChild
in interfaceNodeInfo
-
-