|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.zkoss.zk.ui.metainfo.LanguageDefinition
public class LanguageDefinition
A definition of a language, such as xul.
Field Summary | |
---|---|
static java.lang.String |
ANNO_NAMESPACE
The namespace for ZK annotations. |
static java.lang.String |
CLIENT_NAMESPACE
The namespace for ZK client namespace. |
static java.lang.String |
NATIVE_NAMESPACE
The namespace for ZK native namespace. |
static java.lang.String |
NATIVE_NAMESPACE_PREFIX
The namespace for ZK native namespace prefix. |
static java.lang.String |
ZK_NAMESPACE
The namespace for ZK. |
Constructor Summary | |
---|---|
LanguageDefinition(java.lang.String deviceType,
java.lang.String name,
java.lang.String namespace,
java.util.List extensions,
PageRenderer pageRenderer,
boolean ignoreCase,
boolean bNative,
Locator locator)
Constructs a language defintion. |
Method Summary | |
---|---|
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 |
addDeferJavaScriptPackage(java.lang.String pkg)
Adds a deferrable JavaScript package required by this langauge. |
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 |
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 |
getAll()
Returns a readonly list of all language definitions regardless of the device type. |
static java.util.List |
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.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 |
getComponentDefinitions()
Returns a readonly collection of all component definitions in this language. |
java.util.Collection |
getCSSURIs()
Returns a readonly collection of the URIs of CSS files of this language. |
java.util.Collection |
getDeferJavaScriptPackages()
Returns a list of deferrable JavaScript package (String) required by this language. |
java.lang.String |
getDeviceType()
Returns the device type that this definition belongs to. |
static java.util.Collection |
getDeviceTypes()
Returns a readonly collection of all device types. |
ComponentDefinition |
getDynamicTagDefinition()
Returns the component defintion 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 |
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 intial scripts of the specified language, or null if no script. |
java.util.Map |
getJavaScriptModules()
Returns a map of definitions of JavaScript modules, (String name, String version). |
java.util.Collection |
getJavaScripts()
Returns a readonly list of all JavaScript required
by this language. |
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.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. |
java.util.Collection |
getStyleSheets()
Returns a readonly list of all StyleSheet required
by 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 |
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. |
ComponentInfo |
newLabelInfo(ComponentInfo parent,
java.lang.String text)
Constructs and returns an ComponentInfo for
the specified parent and text, |
void |
setDynamicTagInfo(java.lang.String compnm,
java.util.Set 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 klass)
Sets the macro template. |
void |
setNativeTemplate(java.lang.Class klass)
Sets the native template. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ZK_NAMESPACE
public static final java.lang.String ANNO_NAMESPACE
public static final java.lang.String NATIVE_NAMESPACE
public static final java.lang.String CLIENT_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.
Constructor Detail |
---|
public LanguageDefinition(java.lang.String deviceType, java.lang.String name, java.lang.String namespace, java.util.List extensions, PageRenderer pageRenderer, boolean ignoreCase, boolean bNative, Locator locator)
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.Method Detail |
---|
public static boolean exists(java.lang.String name)
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 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 getAll()
getByDeviceType(java.lang.String)
public static final java.util.Collection 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 (aka., 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 getExtensions()
public java.util.Collection getComponentDefinitions()
public ComponentDefinitionMap getComponentDefinitionMap()
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 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 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 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 java.util.Collection getJavaScripts()
JavaScript
required
by this language.
public void addDeferJavaScriptPackage(java.lang.String pkg)
pkg
- the package name, such as "foo.fly"public java.util.Collection getDeferJavaScriptPackages()
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 getJavaScriptModules()
public void addStyleSheet(StyleSheet ss)
StyleSheet
required by this language.
public java.util.Collection getStyleSheets()
StyleSheet
required
by this language.
public boolean isCaseInsensitive()
public PageRenderer getPageRenderer()
public void setMacroTemplate(java.lang.Class klass)
public ComponentDefinition getMacroDefinition(java.lang.String name, java.lang.String macroURI, boolean inline, PageDefinition pgdef)
pgdef
- the page definition the macro definitioin 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 setNativeTemplate(java.lang.Class 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.ComponentInfo, java.lang.String)
.
To be able to call newLabelInfo(org.zkoss.zk.ui.metainfo.ComponentInfo, 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(ComponentInfo parent, java.lang.String text)
ComponentInfo
for
the specified parent and text,
public boolean isRawLabel()
public void setDynamicTagInfo(java.lang.String compnm, java.util.Set 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 getCSSURIs()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |