org.zkoss.zk.ui.metainfo
Class Property

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

public class Property
extends java.lang.Object

Information about how to initialize a property (a.k.a., a field of a component). There are two kind of properties: one is a String instance (either a string value or an expression), and the other is a NativeInfo instance. The later is also called the native content.

Author:
tomyeh
See Also:
Serialized Form

Constructor Summary
Property(EvaluatorRef evalr, java.lang.String name, NativeInfo value, ConditionImpl cond)
          Constructs a property with the native content.
Property(EvaluatorRef evalr, java.lang.String name, java.lang.String value, ConditionImpl cond)
          Constructs a property with a class that is known in advance.
 
Method Summary
 void assign(Component comp)
          Assigns the value of this member to the specified component.
static void assign(Component comp, java.lang.String name, java.lang.String value)
          Assigns a property.
 ConditionImpl getCondition()
          Returns the effectiveness condition.
 EvaluatorRef getEvaluatorRef()
          Returns the evaluator reference.
 java.lang.String getName()
          Returns the name of the property.
 java.lang.String getRawValue()
          Returns the raw value of the property.
 java.lang.Object getValue(Component comp)
          Evaluates the value to an Object.
 java.lang.Object getValue(Page page)
          Evaluates the value to an Object.
 boolean isEffective(Component comp)
          Used to evaluate whether it is effective.
 boolean isEffective(Page page)
          Used to evaluate whether it is effective.
static java.lang.reflect.Method resolveMethod(java.lang.Class cls, java.lang.String name)
          Resolves the method for the specified property, or null if DynamicPropertied.setDynamicProperty(java.lang.String, java.lang.Object) shall be used instead.
 void setCondition(ConditionImpl cond)
          Sets the effectiveness condition.
 void setRawValue(java.lang.String value)
          Sets the raw value of the property.
 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

Property

public Property(EvaluatorRef evalr,
                java.lang.String name,
                java.lang.String value,
                ConditionImpl cond)
Constructs a property with a class that is known in advance.

Throws:
java.lang.IllegalArgumentException - if name is null

Property

public Property(EvaluatorRef evalr,
                java.lang.String name,
                NativeInfo value,
                ConditionImpl cond)
Constructs a property with the native content. The native content is represented by NativeInfo, i.e., a XML fragment (a.k.a., a tree of ComponentInfo.

Since:
3.5.0
Method Detail

getName

public java.lang.String getName()
Returns the name of the property.


getRawValue

public java.lang.String getRawValue()
Returns the raw value of the property. Note: it is the original value without evaluation. In other words, it may contain EL expressions.

Throws:
java.lang.UnsupportedOperationException - if value is the native content, i.e., it is constructed by use of Property(EvaluatorRef, String, NativeInfo, ConditionImpl).
Since:
3.0.0

setRawValue

public void setRawValue(java.lang.String value)
Sets the raw value of the property.

Throws:
java.lang.UnsupportedOperationException - if value is the native content, i.e., it is constructed by use of Property(EvaluatorRef, String, NativeInfo, ConditionImpl).
Since:
3.0.0

getValue

public java.lang.Object getValue(Component comp)
Evaluates the value to an Object. Note: it does NOT call isEffective(org.zkoss.zk.ui.Component) and it doesn't coerce the result (i.e., Object.class is assumed).


getValue

public java.lang.Object getValue(Page page)
Evaluates the value to an Object. Note: it does NOT call isEffective(org.zkoss.zk.ui.Component) and it doesn't coerce the result (i.e., Object.class is assumed).

Throws:
java.lang.UnsupportedOperationException - if value is the native content, i.e., it is constructed by use of Property(EvaluatorRef, String, NativeInfo, ConditionImpl).

assign

public void assign(Component comp)
Assigns the value of this member to the specified component.

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


toString

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

resolveMethod

public static final java.lang.reflect.Method resolveMethod(java.lang.Class cls,
                                                           java.lang.String name)
                                                    throws PropertyNotFoundException
Resolves the method for the specified property, or null if DynamicPropertied.setDynamicProperty(java.lang.String, java.lang.Object) shall be used instead.

Use this method to retrieve the method when you want to assign a value to a component's property.

Don't use the reflection directly since this method searches more signatures.

Parameters:
name - the property name, such as "title".
Throws:
PropertyNotFoundException - if the property is not found, i.e., no corresponding method and DynamicPropertied not implemented.
Since:
3.5.0

assign

public static final void assign(Component comp,
                                java.lang.String name,
                                java.lang.String value)
Assigns a property.

Don't use the reflection directly since this method searches more signatures.

Throws:
PropertyNotFoundException - if the property is not found, i.e., no corresponding method and DynamicPropertied not implemented.
UiException - if fail to assign
Since:
3.5.0

getEvaluatorRef

public EvaluatorRef getEvaluatorRef()
Returns the evaluator reference.


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


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.


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