org.zkoss.zk.ui.metainfo
Class ShadowInfo

java.lang.Object
  extended by org.zkoss.zk.ui.metainfo.ShadowInfo
All Implemented Interfaces:
java.io.Serializable, NodeInfo, Condition

public class ShadowInfo
extends java.lang.Object

Represent a shadow element.

Since:
8.0.0
Author:
jumperchen
See Also:
Serialized Form

Constructor Summary
ShadowInfo(NodeInfo parent, ComponentDefinition compdef, java.lang.String tag, ConditionImpl cond)
          Creates a shadow.
 
Method Summary
 void addAnnotation(java.lang.String propName, java.lang.String annotName, java.util.Map<java.lang.String,java.lang.String[]> annotAttrs, Location loc)
          Adds an annotation to the specified property of this component info.
 void addProperty(java.lang.String name, java.lang.String value, ConditionImpl cond)
          Adds a property initializer.
 void appendChild(NodeInfo child)
          Adds a child.
 void apply(Component comp)
          Applies the custom attributes.
 void applyProperties(Component comp)
          Applies the event handlers and properties to the specified component.
 void disableBindingAnnotation()
           
 void enableBindingAnnotation()
           
 AnnotationMap getAnnotationMap()
          Returns the annotation map defined in this info, or null if no annotation is ever defined.
 java.util.List<NodeInfo> getChildren()
          Returns a readonly list of children.
 ComponentDefinition getComponentDefinition()
          Returns the component definition, or null if it is PageDefinition.
 ConditionImpl getCondition()
          Returns the effectiveness condition.
 Evaluator getEvaluator()
          Returns the evaluator.
 EvaluatorRef getEvaluatorRef()
          Returns the evaluator reference.
 LanguageDefinition getLanguageDefinition()
          Returns the language definition that getComponentDefinition() belongs to, or null if the component definition is temporary.
 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.util.List<Property> getProperties()
          Returns a readonly list of properties (Property) (never null).
 boolean hasBindingAnnotation()
           
 boolean isEffective(Component comp)
          Used to evaluate whether it is effective.
 boolean isEffective(Page page)
          Used to evaluate whether it is effective.
 Component newInstance(Page page)
          Creates a shadow element based on this info (never null).
 Component newInstance(Page page, Component parent)
          Creates an component based on this info (never null).
 boolean removeChild(NodeInfo child)
          Removes a child.
 void setCondition(ConditionImpl cond)
          Sets the effectiveness condition.
 java.lang.String toString()
           
 boolean withCondition()
          Tests if the condition is set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ShadowInfo

public ShadowInfo(NodeInfo parent,
                  ComponentDefinition compdef,
                  java.lang.String tag,
                  ConditionImpl cond)
Creates a shadow.

Parameters:
parent - the parent node (never null)
compdef - the component definition; never null
tag - the tag name; Note: if component implements DynamicTag, this argument must be specified. If DynamicTag is not implemented, this argument is optional.
Method Detail

getAnnotationMap

public AnnotationMap getAnnotationMap()
Returns the annotation map defined in this info, or null if no annotation is ever defined.


applyProperties

public void applyProperties(Component comp)
Applies the event handlers and properties to the specified component.

It also invokes ComponentDefinition.applyProperties(org.zkoss.zk.ui.Component).

Note: annotations are applied to the component when a component is created. So, this method doesn't and need not to copy them. See also AbstractComponent.AbstractComponent(boolean).


addAnnotation

public void addAnnotation(java.lang.String propName,
                          java.lang.String annotName,
                          java.util.Map<java.lang.String,java.lang.String[]> annotAttrs,
                          Location loc)
Adds an annotation to the specified property of this component info.

Parameters:
propName - the property name. If null, the annotation is associated with the whole component rather than a particular property.
annotName - the annotation name (never null, nor empty).
annotAttrs - a map of attributes, or null if no attribute at all. The attribute must be in a pair of strings (String name, String value), or (String name, String[] value).
loc - the location information of the annotation in the document, or null if not available.

apply

public void apply(Component comp)
Applies the custom attributes.

Note: this method does nothing if isEffective(org.zkoss.zk.ui.Component) returns false.


newInstance

public Component newInstance(Page page)
Creates a shadow element based on this info (never null). It is the same as newInstance(page, null).

If the implementation class doesn't have any EL expression, or its EL expression doesn't have reference to the self variable, the result is the same.

This method is preserved for backward compatibility. It is better to use newInstance(Page, Component).


newInstance

public Component newInstance(Page page,
                             Component parent)
Creates an component based on this info (never null).

Like ComponentDefinition.newInstance(org.zkoss.zk.ui.Page, java.lang.String), this method doesn't invoke applyProperties(org.zkoss.zk.ui.Component). It is caller's job to invoke them if necessary. Since the value of properties might depend on the component tree, it is better to assign the component with a proper parent before calling applyProperties(org.zkoss.zk.ui.Component).


getLanguageDefinition

public LanguageDefinition getLanguageDefinition()
Returns the language definition that getComponentDefinition() belongs to, or null if the component definition is temporary.


getComponentDefinition

public ComponentDefinition getComponentDefinition()
Returns the component definition, or null if it is PageDefinition.


getProperties

public java.util.List<Property> getProperties()
Returns a readonly list of properties (Property) (never null).


addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value,
                        ConditionImpl cond)
Adds a property initializer. It will initialize a component when created with this info.

Parameters:
name - the member name. The component must have a valid setter for it.
value - the value. It might contain expressions (${}).

appendChild

public void appendChild(NodeInfo child)
Adds a child.

Specified by:
appendChild in interface NodeInfo
Throws:
java.lang.IllegalStateException - if this is not an instance of TemplateInfo and ShadowInfo.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hasBindingAnnotation

public boolean hasBindingAnnotation()

enableBindingAnnotation

public void enableBindingAnnotation()

disableBindingAnnotation

public void disableBindingAnnotation()

getCondition

public ConditionImpl getCondition()
Returns the effectiveness condition.


setCondition

public void setCondition(ConditionImpl cond)
Sets the effectiveness condition.


withCondition

public boolean withCondition()
Tests if the condition is set


removeChild

public boolean removeChild(NodeInfo child)
Description copied from interface: NodeInfo
Removes a child.

Specified by:
removeChild in interface NodeInfo

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) and NodeInfo.removeChild(org.zkoss.zk.ui.metainfo.NodeInfo) instead.

Specified by:
getChildren in interface NodeInfo

isEffective

public boolean isEffective(Component comp)
Description copied from interface: Condition
Used to evaluate whether it is effective.

Specified by:
isEffective in interface Condition
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 interface Condition
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 interface NodeInfo

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 interface NodeInfo

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 interface NodeInfo

getParent

public NodeInfo getParent()
Description copied from interface: NodeInfo
Returns the parent, or null if it has no parent.

Specified by:
getParent in interface NodeInfo


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo