Class ShadowInfo
- java.lang.Object
-
- org.zkoss.zk.ui.metainfo.ShadowInfo
-
public class ShadowInfo extends java.lang.ObjectRepresent a shadow element.- Since:
- 8.0.0
- Author:
- jumperchen
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ShadowInfo(NodeInfo parent, ComponentDefinition compdef, java.lang.String tag, ConditionImpl cond)Creates a shadow.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotation(java.lang.String propName, java.lang.String annotName, java.util.Map<java.lang.String,java.lang.String[]> annotAttrs, org.zkoss.util.resource.Location loc)Adds an annotation to the specified property of this component info.voidaddProperty(java.lang.String name, java.lang.String value, ConditionImpl cond)Adds a property initializer.voidappendChild(NodeInfo child)Adds a child.voidapply(Component comp)Applies the custom attributes.voidapplyProperties(Component comp)Applies the event handlers and properties to the specified component.voiddisableBindingAnnotation()voidenableBindingAnnotation()AnnotationMapgetAnnotationMap()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.ComponentDefinitiongetComponentDefinition()Returns the component definition, or null if it is PageDefinition.ConditionImplgetCondition()Returns the effectiveness condition.EvaluatorgetEvaluator()Returns the evaluator.EvaluatorRefgetEvaluatorRef()Returns the evaluator reference.LanguageDefinitiongetLanguageDefinition()Returns the language definition thatgetComponentDefinition()belongs to, or null if the component definition is temporary.PageDefinitiongetPageDefinition()Returns the page definition, i.e., the root node, or null if not available.NodeInfogetParent()Returns the parent, or null if it has no parent.java.util.List<Property>getProperties()Returns a readonly list of properties (Property) (never null).booleanhasBindingAnnotation()booleanisAnnotationNamespacedRoot()booleanisEffective(Component comp)Used to evaluate whether it is effective.booleanisEffective(Page page)Used to evaluate whether it is effective.ComponentnewInstance(Page page)Creates a shadow element based on this info (never null).ComponentnewInstance(Page page, Component parent)Creates an component based on this info (never null).booleanremoveChild(NodeInfo child)Removes a child.voidsetAnnotationNamespacedRoot(boolean annotationNamespacedRoot)Sets whether this ShadowInfo is the first ShadowInfo that has annotation namespace or binding annotation.voidsetCondition(ConditionImpl cond)Sets the effectiveness condition.java.lang.StringtoString()booleanwithCondition()Tests if the condition is set
-
-
-
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 nulltag- the tag name; Note: if component implementsDynamicTag, this argument must be specified. IfDynamicTagis 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(boolean).
-
addAnnotation
public void addAnnotation(java.lang.String propName, java.lang.String annotName, java.util.Map<java.lang.String,java.lang.String[]> annotAttrs, org.zkoss.util.resource.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
Condition.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 invokeapplyProperties(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 callingapplyProperties(org.zkoss.zk.ui.Component).
-
getLanguageDefinition
public LanguageDefinition getLanguageDefinition()
Returns the language definition thatgetComponentDefinition()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:
appendChildin interfaceNodeInfo- Throws:
java.lang.IllegalStateException- if this is not an instance ofTemplateInfoandShadowInfo.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hasBindingAnnotation
public boolean hasBindingAnnotation()
-
enableBindingAnnotation
public void enableBindingAnnotation()
-
disableBindingAnnotation
public void disableBindingAnnotation()
-
isAnnotationNamespacedRoot
public boolean isAnnotationNamespacedRoot()
- Returns:
- whether this ShadowInfo is the first ShadowInfo that has annotation namespace or binding annotation.
- Since:
- 8.5.2
-
setAnnotationNamespacedRoot
public void setAnnotationNamespacedRoot(boolean annotationNamespacedRoot)
Sets whether this ShadowInfo is the first ShadowInfo that has annotation namespace or binding annotation.- Parameters:
annotationNamespacedRoot-- Since:
- 8.5.2
-
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:NodeInfoRemoves a child.- Specified by:
removeChildin interfaceNodeInfo
-
getChildren
public java.util.List<NodeInfo> getChildren()
Description copied from interface:NodeInfoReturns 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:
getChildrenin interfaceNodeInfo
-
isEffective
public boolean isEffective(Component comp)
Description copied from interface:ConditionUsed to evaluate whether it is effective.- Specified by:
isEffectivein interfaceCondition- Parameters:
comp- used as the self variable. Ignored if null.
-
isEffective
public boolean isEffective(Page page)
Description copied from interface:ConditionUsed to evaluate whether it is effective.- Specified by:
isEffectivein interfaceCondition- Parameters:
page- used as the self variable. Ignored if null.
-
getEvaluatorRef
public EvaluatorRef getEvaluatorRef()
Description copied from interface:NodeInfoReturns the evaluator reference.- Specified by:
getEvaluatorRefin interfaceNodeInfo
-
getPageDefinition
public PageDefinition getPageDefinition()
Description copied from interface:NodeInfoReturns the page definition, i.e., the root node, or null if not available.- Specified by:
getPageDefinitionin interfaceNodeInfo
-
getEvaluator
public Evaluator getEvaluator()
Description copied from interface:NodeInfoReturns the evaluator.All nodes in the same ZUML tree has the same evaluator reference (inherited from the root node,
PageDefinition.getEvaluatorRef()).- Specified by:
getEvaluatorin interfaceNodeInfo
-
-