org.zkoss.zk.ui.metainfo.impl
Class AnnotationHelper

java.lang.Object
  extended by org.zkoss.zk.ui.metainfo.impl.AnnotationHelper

public class AnnotationHelper
extends java.lang.Object

A helper class used to parse annotations.

How to use:

  1. Invoke one of add(java.lang.String, java.util.Map), addByRawValue(java.lang.String, java.lang.String), or addByCompoundValue(java.lang.String) to add annotations to this helper.
  2. After annotations are all added, invoke applyAnnotations(org.zkoss.zk.ui.metainfo.ComponentInfo, java.lang.String, boolean) to update the annotations to the specified component info.

Since:
3.0.0
Author:
tomyeh

Constructor Summary
AnnotationHelper()
           
 
Method Summary
 void add(java.lang.String annotName, java.util.Map annotAttrs)
          Adds an annotation definition.
 void addByCompoundValue(java.lang.String cval)
          Adds annotation by specifying the content in the compound format: annot-name(att1-name=att1-value, att2-name=att2-value).
 void addByRawValue(java.lang.String annotName, java.lang.String rawValue)
          Adds an annotation by specify the value in the raw format: att1-name=att1-value, att2-name = att2-value.
 void applyAnnotations(ComponentInfo compInfo, java.lang.String propName, boolean clear)
          Applies the annotations defined in this helper to the specified instance definition.
 void applyAnnotations(Component comp, java.lang.String propName, boolean clear)
          Applies the annotations defined in this helper to the specified component.
 boolean clear()
          Clears the annotations defined in this helper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationHelper

public AnnotationHelper()
Method Detail

add

public void add(java.lang.String annotName,
                java.util.Map annotAttrs)
Adds an annotation definition. The annotation's attributes must be parsed into a map (annotAttrs).

Parameters:
annotName - the annotation name.
annotAttrs - a map of attributes of the annotation. If null, it means no attribute at all.
See Also:
addByRawValue(java.lang.String, java.lang.String), addByCompoundValue(java.lang.String)

addByRawValue

public void addByRawValue(java.lang.String annotName,
                          java.lang.String rawValue)
Adds an annotation by specify the value in the raw format: att1-name=att1-value, att2-name = att2-value.


addByCompoundValue

public void addByCompoundValue(java.lang.String cval)
Adds annotation by specifying the content in the compound format: annot-name(att1-name=att1-value, att2-name=att2-value).


applyAnnotations

public void applyAnnotations(ComponentInfo compInfo,
                             java.lang.String propName,
                             boolean clear)
Applies the annotations defined in this helper to the specified instance definition.

Parameters:
compInfo - the instance definition to update
propName - the property name
clear - whether to clear all definitions before returning
See Also:
clear()

applyAnnotations

public void applyAnnotations(Component comp,
                             java.lang.String propName,
                             boolean clear)
Applies the annotations defined in this helper to the specified component.

Parameters:
comp - the component to update
propName - the property name
clear - whether to clear all definitions before returning
See Also:
clear()

clear

public boolean clear()
Clears the annotations defined in this helper.

The annotations are defined by add(java.lang.String, java.util.Map), addByRawValue(java.lang.String, java.lang.String), or addByCompoundValue(java.lang.String).

Returns:
true if one or more annotation definitions are defined (thru add(java.lang.String, java.util.Map)).


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