public class LanguageDefinition
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ANNOTATION_NAMESPACE
The namespace for annotation.
|
static java.lang.String |
CLIENT_ATTRIBUTE_NAMESPACE
The namespace for ZK client attributes.
|
static java.lang.String |
CLIENT_ATTRIBUTE_PREFIX_NAME
The name for the prefix of ZK client attributes.
|
static java.lang.String |
CLIENT_ATTRIBUTE_PREFIX_NAMESPACE
The namespace for the prefix of ZK client attributes.
|
static java.lang.String |
CLIENT_NAMESPACE
The namespace for ZK client (a.k.a., widget).
|
static java.lang.String |
NATIVE_NAMESPACE
The namespace for ZK native components.
|
static java.lang.String |
NATIVE_NAMESPACE_PREFIX
The namespace for ZK native namespace prefix.
|
static java.lang.String |
SHADOW_NAME
The names of ZK shadow components.
|
static java.lang.String |
SHADOW_NAMESPACE
The namespace for ZK shadow components.
|
static java.lang.String |
ZK_NAMESPACE
The namespace for ZK.
|
Constructor and Description |
---|
LanguageDefinition(java.lang.String deviceType,
java.lang.String name,
java.lang.String namespace,
java.util.List<java.lang.String> extensions,
PageRenderer pageRenderer,
boolean ignoreCase,
boolean bNative,
Locator locator,
java.lang.String treeBuilderClass)
Constructs a language definition.
|
Modifier and Type | Method and Description |
---|---|
void |
addComponentDefinition(ComponentDefinition compdef)
Adds a component definition.
|
void |
addCSSURI(java.lang.String cssURI)
Adds the URI of a CSS file that is part of this language.
|
void |
addEachTimeScript(java.lang.String zslang,
java.lang.String script)
Adds the script that shall execute each time before evaluating
zscript.
|
static void |
addExtension(java.lang.String ext,
java.lang.String lang)
Associates an extension to a language.
|
void |
addInitScript(java.lang.String zslang,
java.lang.String script)
Adds the script that shall execute when a page's interpreter
is initialized.
|
void |
addJavaScript(JavaScript js)
Adds a
JavaScript required by this language. |
void |
addJavaScriptModule(java.lang.String name,
java.lang.String version)
Adds the definition of a JavaScript module to this language.
|
void |
addMessageLoader(MessageLoader loader)
Adds a MessageLoader
|
void |
addShadowDefinition(ComponentDefinition compdef)
Adds a shadow element definition.
|
void |
addStyleSheet(StyleSheet ss)
Adds a
StyleSheet required by this language. |
void |
addTaglib(Taglib taglib)
Adds a tag lib.
|
void |
addWidgetDefinition(WidgetDefinition wgtdef)
Adds a widget definition.
|
static boolean |
exists(java.lang.String name)
Returns whether the specified language exists.
|
static java.util.List<LanguageDefinition> |
getAll()
Returns a readonly list of all language definitions
regardless of the device type.
|
static java.util.List<LanguageDefinition> |
getByDeviceType(java.lang.String deviceType)
Returns a readonly list of language definitions belong to
the specified device type.
|
static LanguageDefinition |
getByExtension(java.lang.String ext)
Returns the language definition by specifying an extension.
|
ComponentDefinition |
getComponentDefinition(java.lang.Class klass)
Returns
ComponentDefinition of the specified class. |
ComponentDefinition |
getComponentDefinition(java.lang.String name)
Returns
ComponentDefinition of the specified name. |
ComponentDefinition |
getComponentDefinitionIfAny(java.lang.Class klass)
Returns
ComponentDefinition of the specified class, or null if not found. |
ComponentDefinition |
getComponentDefinitionIfAny(java.lang.String name)
Returns
ComponentDefinition of the specified name, or null
if not found. |
ComponentDefinitionMap |
getComponentDefinitionMap()
Returns the map of components defined in this language (never null).
|
java.util.Collection<ComponentDefinition> |
getComponentDefinitions()
Returns a readonly collection of all component definitions in this language.
|
java.util.Collection<java.lang.String> |
getCSSURIs()
Returns a readonly collection of the URIs of CSS files of this language.
|
java.lang.String |
getDeviceType()
Returns the device type that this definition belongs to.
|
static java.util.Collection<java.lang.String> |
getDeviceTypes()
Returns a readonly collection of all device types.
|
ComponentDefinition |
getDynamicTagDefinition()
Returns the component definition of the dynamic tag, or null if
this language doesn't support the dynamic tag.
|
java.lang.String |
getEachTimeScript(java.lang.String zslang)
Returns the each-time scripts of
the specified language, or null if no scripts.
|
Evaluator |
getEvaluator()
Returns the evaluator based on this language definition (never null).
|
EvaluatorRef |
getEvaluatorRef()
Returns the evaluator reference (never null).
|
java.util.List<java.lang.String> |
getExtensions()
Returns the readonly list of extensions that this language definition
is associated with (never null).
|
java.lang.String |
getInitScript(java.lang.String zslang)
Returns the initial scripts of
the specified language, or null if no script.
|
java.util.Map<java.lang.String,java.lang.String> |
getJavaScriptModules()
Returns a readonly map of definitions of JavaScript modules,
(String name, String version).
|
java.util.Set<java.lang.String> |
getJavaScriptPackagesWithMerges()
Returns a readonly collection of the packages that will be merged
by other packages.
|
java.util.Collection<JavaScript> |
getJavaScripts()
Returns a readonly list of all
JavaScript required
by this language. |
java.lang.String |
getLabelAttribute()
Returns the label attribute of the label template in the language setting.
|
ComponentDefinition |
getMacroDefinition(java.lang.String name,
java.lang.String macroURI,
boolean inline,
PageDefinition pgdef)
Instantiates and returns the component definition for the specified condition.
|
java.util.Collection<java.lang.String> |
getMergedJavaScriptPackages(java.lang.String pkg)
Returns a list of JavaScript packages that are merged the given
package, such as "zk" and "zul.lang".
|
java.util.Collection<MessageLoader> |
getMessageLoaders()
Returns the message loader for this language.
|
java.lang.String |
getName()
Returns name of this language.
|
java.lang.String |
getNamespace()
Returns the name space.
|
ComponentDefinition |
getNativeDefinition()
Returns the component definition for the native components.
|
PageRenderer |
getPageRenderer()
Returns the page render for this language.
|
ComponentDefinition |
getShadowDefinition(java.lang.Class klass)
Returns
ComponentDefinition of the specified class. |
ComponentDefinition |
getShadowDefinition(java.lang.String name)
Returns
ComponentDefinition of the specified name. |
ComponentDefinition |
getShadowDefinition(java.lang.String name,
PageDefinition pgdef,
java.lang.String templateURI)
Instantiates and returns the component definition for the specified condition.
|
ComponentDefinition |
getShadowDefinitionIfAny(java.lang.Class klass)
Returns
ComponentDefinition of the specified class, or null if not found. |
ComponentDefinition |
getShadowDefinitionIfAny(java.lang.String name)
Returns
ComponentDefinition of the specified name, or null
if not found. |
ComponentDefinitionMap |
getShadowDefinitionMap()
Returns the map of shadow elements defined in this language (never null).
|
java.util.Collection<ComponentDefinition> |
getShadowDefinitions()
Returns a readonly collection of all shadow element definitions in this language.
|
java.util.Collection<StyleSheet> |
getStyleSheets()
Returns a readonly list of all
StyleSheet required
by this language. |
java.lang.String |
getTreeBuilderClass()
Returns the tree builder class for this language
|
WidgetDefinition |
getWidgetDefinition(java.lang.String widgetClass)
Returns the widget of the specified class name.
|
WidgetDefinition |
getWidgetDefinitionIfAny(java.lang.String widgetClass)
Returns the widget of the specified class name, or null if not found.
|
boolean |
hasComponentDefinition(java.lang.String name)
Returns whether the specified component is defined.
|
boolean |
hasShadowDefinition(java.lang.String name)
Returns whether the specified shadow element is defined.
|
boolean |
hasWidgetDefinition(java.lang.String widgetClass)
Returns whether the specified widget is defined.
|
boolean |
isCaseInsensitive()
Returns whether the component names are case-insensitive.
|
boolean |
isDynamicReservedAttributes(java.lang.String attr)
Returns whether a reserved attribute is used by the dynamic tag
(
getDynamicTagDefinition() ). |
boolean |
isNative()
Returns whether this is a native language.
|
boolean |
isRawLabel()
Returns whether this language prefers the raw label.
|
static LanguageDefinition |
lookup(java.lang.String name)
Returns the language definition of the specified name or namespace.
|
void |
mergeJavaScriptPackage(java.lang.String pkgFrom,
java.lang.String pkgTo)
Merge a JavaScript package, say pkgFrom, to another package, say pkgTo,
such that, when loading pkgTo, pkgFrom will be placed in the same WPD file.
|
ComponentInfo |
newLabelInfo(NodeInfo parent,
java.lang.String text)
Constructs and returns an
ComponentInfo for
the specified parent and text. |
void |
removeJavaScript(java.lang.String src)
Removes a
JavaScript of the give source required by this language. |
void |
setDynamicTagInfo(java.lang.String compnm,
java.util.Set<java.lang.String> reservedAttrs)
Adds the definition for the dynamic tag.
|
void |
setLabelTemplate(java.lang.String compName,
java.lang.String propName,
boolean raw)
Sets the component and attribute names used to represent a label.
|
void |
setMacroTemplate(java.lang.Class<? extends Component> klass)
Sets the macro template.
|
void |
setNativeTemplate(java.lang.Class<? extends Component> klass)
Sets the native template.
|
void |
setShadowTemplate(java.lang.Class<? extends Component> klass)
Sets the shadow template.
|
java.lang.String |
toString() |
boolean |
unmergeJavaScriptPackage(java.lang.String pkgFrom,
java.lang.String pkgTo)
Undo the merge of a JavaScript package to another.
|
public static final java.lang.String ZK_NAMESPACE
public static final java.lang.String NATIVE_NAMESPACE
public static final java.lang.String CLIENT_NAMESPACE
Notice that CLIENT_NAMESPACE
specifies the property
or event listener for a widget, while CLIENT_ATTRIBUTE_NAMESPACE
specifies the DOM attributes. In other words, the attribute specified
with CLIENT_ATTRIBUTE_NAMESPACE
are generated directly.
public static final java.lang.String CLIENT_ATTRIBUTE_NAMESPACE
Notice that CLIENT_NAMESPACE
specifies the property
or event listener for a widget, while CLIENT_ATTRIBUTE_NAMESPACE
specifies the DOM attributes. In other words, the attribute specified
with CLIENT_ATTRIBUTE_NAMESPACE
are generated directly.
You can use it to listen DOM events such as onload and specify browser-specific attributes (such as accessibility related attributes).
public static final java.lang.String ANNOTATION_NAMESPACE
public static final java.lang.String NATIVE_NAMESPACE_PREFIX
NATIVE_NAMESPACE_PREFIX
("native:"),
it means it is also a native space (NATIVE_NAMESPACE
but the namespace prefix and uri will be generated.
For example,
<s:svg xmlns:s="native:http://www.w3.org/2000/svg"/>
generates the following output:
<s:svg xmlns:s="http://www.w3.org/2000/svg"/>
where the prefix s
and URI http://www.w3.org/2000/svg
are both generated.public static final java.lang.String SHADOW_NAMESPACE
public static final java.lang.String SHADOW_NAME
public static final java.lang.String CLIENT_ATTRIBUTE_PREFIX_NAMESPACE
public static final java.lang.String CLIENT_ATTRIBUTE_PREFIX_NAME
public LanguageDefinition(java.lang.String deviceType, java.lang.String name, java.lang.String namespace, java.util.List<java.lang.String> extensions, PageRenderer pageRenderer, boolean ignoreCase, boolean bNative, Locator locator, java.lang.String treeBuilderClass)
Note: the name and namespace of any language cannot be the same.
In other words, each language has two names, name and namespace.
You can find the language back by either of them via
lookup(java.lang.String)
.
deviceType
- the device type; never null or emptypageRenderer
- the page renderer used to render a page; never null.ignoreCase
- whether the component name is case-insensitivebNative
- whether it is native (i.e., all tags are
Native
).
If native, the namespaces found in a ZUML page is no longer
used to specified a language. Rather, it is output to the client
directly.treeBuilderClass
- a tree builder class for this language (since 8.0.0)public static boolean exists(java.lang.String name)
public java.lang.String getTreeBuilderClass()
public static final LanguageDefinition lookup(java.lang.String name)
Note: the name and namespace of any language cannot be the same.
name
- the name or the namespace; If null or empty, "xul/html" is assumed.DefinitionNotFoundException
- is thrown if the definition
is not foundpublic static final LanguageDefinition getByExtension(java.lang.String ext)
ext
- the extension, e.g., "zul".
If null, "zul" is assumed.DefinitionNotFoundException
- is thrown if the definition
is not foundpublic static final void addExtension(java.lang.String ext, java.lang.String lang)
lang
- the language name. It cannot be null.ext
- the extension, e.g., "svg". It cannot be null.public static final java.util.List<LanguageDefinition> getByDeviceType(java.lang.String deviceType)
A device type identifies the type of a client. For example, "ajax" represents all Web browsers with Ajax support, while "mil" represents clients that supports Mobile User interface markup Language (on Limited Connected Device, such as mobile phones).
deviceType
- the device type, e.g., "ajax".getDeviceType()
,
getAll()
public static final java.util.List<LanguageDefinition> getAll()
getByDeviceType(java.lang.String)
public static final java.util.Collection<java.lang.String> getDeviceTypes()
getByDeviceType(java.lang.String)
public java.lang.String getDeviceType()
A device type identifies the type of a client. For example, "ajax" represents all HTML compatible clients (a.k.a., browsers), while "mil" represents clients that supports Mobile Interactive markup Language (on Limited Connected Device, such as mobile phones).
public boolean isNative()
public java.lang.String getName()
public java.lang.String getNamespace()
public java.util.List<java.lang.String> getExtensions()
public java.util.Collection<ComponentDefinition> getShadowDefinitions()
public ComponentDefinitionMap getShadowDefinitionMap()
public java.util.Collection<ComponentDefinition> getComponentDefinitions()
public ComponentDefinitionMap getComponentDefinitionMap()
public ComponentDefinition getShadowDefinition(java.lang.String name)
ComponentDefinition
of the specified name.
Note: anonymous shadow element definition won't be returned by this method.
name
- the name of the shadow element definition.DefinitionNotFoundException
- is thrown if the definition
is not foundpublic ComponentDefinition getShadowDefinition(java.lang.Class klass)
ComponentDefinition
of the specified class.
Note: anonymous shadow element definition won't be returned by this method.
klass
- the class that implements the shadow element.DefinitionNotFoundException
- is thrown if the definition
is not foundpublic ComponentDefinition getShadowDefinition(java.lang.String name, PageDefinition pgdef, java.lang.String templateURI)
pgdef
- the page definition the shadow definition belongs to.
If null, it belongs to this language definition.java.lang.UnsupportedOperationException
- if this language doesn't
support the shadowspublic ComponentDefinition getShadowDefinitionIfAny(java.lang.String name)
ComponentDefinition
of the specified name, or null
if not found.
It is the same as getShadowDefinition(java.lang.String)
, except this method
won't throw any exception.name
- the name of the shadow element definition.public ComponentDefinition getShadowDefinitionIfAny(java.lang.Class klass)
ComponentDefinition
of the specified class, or null if not found.
It is the same as getShadowDefinition(Class)
, except this method
won't throw any exception.klass
- the class that implements the shadow element.public boolean hasShadowDefinition(java.lang.String name)
public void addShadowDefinition(ComponentDefinition compdef)
public ComponentDefinition getComponentDefinition(java.lang.String name)
ComponentDefinition
of the specified name.
Note: anonymous component definition won't be returned by this method.
name
- the name of the component definition.DefinitionNotFoundException
- is thrown if the definition
is not foundpublic ComponentDefinition getComponentDefinition(java.lang.Class klass)
ComponentDefinition
of the specified class.
Note: anonymous component definition won't be returned by this method.
klass
- the class that implements the component.DefinitionNotFoundException
- is thrown if the definition
is not foundpublic ComponentDefinition getComponentDefinitionIfAny(java.lang.String name)
ComponentDefinition
of the specified name, or null
if not found.
It is the same as getComponentDefinition(java.lang.String)
, except this method
won't throw any exception.name
- the name of the component definition.public ComponentDefinition getComponentDefinitionIfAny(java.lang.Class klass)
ComponentDefinition
of the specified class, or null if not found.
It is the same as getComponentDefinition(Class)
, except this method
won't throw any exception.klass
- the class that implements the component.public boolean hasComponentDefinition(java.lang.String name)
public void addComponentDefinition(ComponentDefinition compdef)
public boolean hasWidgetDefinition(java.lang.String widgetClass)
widgetClass
- the name of the widget class (JavaScript class),
including the package name.public WidgetDefinition getWidgetDefinition(java.lang.String widgetClass)
widgetClass
- the name of the widget class (JavaScript class),
including the package name.DefinitionNotFoundException
- is thrown if the definition
is not foundpublic WidgetDefinition getWidgetDefinitionIfAny(java.lang.String widgetClass)
getWidgetDefinition(java.lang.String)
, except this method
won't throw any exception.widgetClass
- the name of the widget class (JavaScript class),
including the package name.public void addWidgetDefinition(WidgetDefinition wgtdef)
public void addInitScript(java.lang.String zslang, java.lang.String script)
Note: it doesn't test the existence of the specified language, such that you can add the scripting language later.
zslang
- the scripting language, say, Java.public java.lang.String getInitScript(java.lang.String zslang)
public void addEachTimeScript(java.lang.String zslang, java.lang.String script)
Note: it doesn't test the existence of the specified language, such that you can add the scripting language later.
zslang
- the scripting language, say, Java.public java.lang.String getEachTimeScript(java.lang.String zslang)
The each-time script is evaluated each time before evaluating zscript.
public void addJavaScript(JavaScript js)
JavaScript
required by this language.public void removeJavaScript(java.lang.String src)
JavaScript
of the give source required by this language.addJavaScript(org.zkoss.html.JavaScript)
public java.util.Collection<JavaScript> getJavaScripts()
JavaScript
required
by this language.public void mergeJavaScriptPackage(java.lang.String pkgFrom, java.lang.String pkgTo)
Notice that
pkgFrom
- the package name, such as "foo.fly", that will
be merged to pkgTo
pkgTo
- the target package, such as "zk" and "zul.lang",
that will contain the code from pkgFrom
.public boolean unmergeJavaScriptPackage(java.lang.String pkgFrom, java.lang.String pkgTo)
mergeJavaScriptPackage(java.lang.String, java.lang.String)
public java.util.Collection<java.lang.String> getMergedJavaScriptPackages(java.lang.String pkg)
public java.util.Set<java.lang.String> getJavaScriptPackagesWithMerges()
public void addJavaScriptModule(java.lang.String name, java.lang.String version)
A JavaScript module represents a JavaScript file. This definition is mainly used to define its version, such that ZK could encode its URL such that browsers know when to reload it.
public java.util.Map<java.lang.String,java.lang.String> getJavaScriptModules()
public void addStyleSheet(StyleSheet ss)
StyleSheet
required by this language.public java.util.Collection<StyleSheet> getStyleSheets()
StyleSheet
required
by this language.public boolean isCaseInsensitive()
public PageRenderer getPageRenderer()
public void addMessageLoader(MessageLoader loader)
public java.util.Collection<MessageLoader> getMessageLoaders()
public void setMacroTemplate(java.lang.Class<? extends Component> klass)
public ComponentDefinition getMacroDefinition(java.lang.String name, java.lang.String macroURI, boolean inline, PageDefinition pgdef)
pgdef
- the page definition the macro definition belongs to.
If null, it belongs to this language definition.macroURI
- the ZUML page's URI that is used to render
instances of this macro definition.java.lang.UnsupportedOperationException
- if this language doesn't
support the macrospublic void setShadowTemplate(java.lang.Class<? extends Component> klass)
public void setNativeTemplate(java.lang.Class<? extends Component> klass)
public ComponentDefinition getNativeDefinition()
java.lang.UnsupportedOperationException
- if this language doesn't
support the native namespacepublic void setLabelTemplate(java.lang.String compName, java.lang.String propName, boolean raw)
ComponentInfo
by calling newLabelInfo(org.zkoss.zk.ui.metainfo.NodeInfo, java.lang.String)
.
To be able to call newLabelInfo(org.zkoss.zk.ui.metainfo.NodeInfo, java.lang.String)
, this method must
be called to define the component and attribute names used to create
an ComponentInfo
for a label.
public ComponentInfo newLabelInfo(NodeInfo parent, java.lang.String text)
ComponentInfo
for
the specified parent and text.public boolean isRawLabel()
public java.lang.String getLabelAttribute()
public void setDynamicTagInfo(java.lang.String compnm, java.util.Set<java.lang.String> reservedAttrs)
compnm
- the component name used to represent any of dynamic
tags for this language. If null, it means this language definition
doesn't support the dynamic tag.reservedAttrs
- a set of reserved attributes that
the dynamic tag support. The reserved attributes are the if, unless
and use attributes.public ComponentDefinition getDynamicTagDefinition()
DefinitionNotFoundException
- is thrown if the definition
is not foundpublic boolean isDynamicReservedAttributes(java.lang.String attr)
getDynamicTagDefinition()
).public void addTaglib(Taglib taglib)
public Evaluator getEvaluator()
public EvaluatorRef getEvaluatorRef()
This method is used only for implementation only.
public void addCSSURI(java.lang.String cssURI)
cssURI
- the URI of a CSS filepublic java.util.Collection<java.lang.String> getCSSURIs()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2005-2023 Potix Corporation. All Rights Reserved.