public class ZScript
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
ZScript(EvaluatorRef evalr,
java.lang.String zslang,
java.lang.String url,
Locator locator)
Creates a zscript with an URL that is used to load the content.
|
ZScript(java.lang.String zslang,
java.lang.String content)
Creates a zscript with the content directly.
|
ZScript(java.lang.String zslang,
java.net.URL url)
Creates a zscript with an URL that is used to load the content.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getContent(Page page,
Component comp)
Returns the content of zscript.
|
java.lang.String |
getLanguage()
Returns the scripting language, or null if the default scripting language
is preferred.
|
java.lang.String |
getRawContent()
Returns the raw content.
|
static ZScript |
parseContent(java.lang.String content)
Parses the content into a
ZScript instance. |
static ZScript |
parseContent(java.lang.String content,
int lineno)
Parses the content into a
ZScript instance. |
void |
setLanguage(java.lang.String zslang)
Sets the scripting language.
|
java.lang.String |
toString() |
public ZScript(java.lang.String zslang, java.lang.String content)
zslang
- the scripting language. If null, it is the same as
Page.getZScriptLanguage()
.content
- the zscript contentparseContent(java.lang.String)
public ZScript(java.lang.String zslang, java.net.URL url)
public ZScript(EvaluatorRef evalr, java.lang.String zslang, java.lang.String url, Locator locator)
evalr
- the evaluator used to evaluatejava.lang.IllegalArgumentException
- if url or locator is null, or
url contains EL and evalr is null.public static final ZScript parseContent(java.lang.String content)
ZScript
instance.
This method assumes the content is in the following format:
lang:codes
codes
For example, "javascript:var m = 0;" returns "javascript", while "var m = 0;" returns null.
Note: if the language doesn't exist, null is returned. Reason: the above syntax may be conflict with some scripting languages.
Note: no space is allowed.
content
- the content of zscript codespublic static final ZScript parseContent(java.lang.String content, int lineno)
ZScript
instance.
It is similar to parseContent(String)
except it
allows the caller to specify the line number of the first line of the
content.
content
- the content of zscript codeslineno
- the line number of the first line. Ignored if
zero (or negative).public java.lang.String getLanguage()
public void setLanguage(java.lang.String zslang)
zslang
- the scripting language. If null, the default scripting
language is assume.public java.lang.String getRawContent()
ZScript(String, String)
.
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.
public java.lang.String getContent(Page page, Component comp)
page
- the page when this zscript is interpreted.
Used only if this object is constructed with ZScript(EvaluatorRef, String, String, Locator)
.comp
- the component when this zscript is interpreted.
Used only if this object is constructed with ZScript(EvaluatorRef, String, String, Locator)
.UiException
- if failed to load the contentpublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2005-2021 Potix Corporation. All Rights Reserved.