Retrieve Annotations"

From Documentation
(ZK 6)
Line 9: Line 9:
 
     ComponentCtrl compCtrl = (ComponentCtrl)comp;
 
     ComponentCtrl compCtrl = (ComponentCtrl)comp;
 
     sb.append(comp.getId()).append(": ")
 
     sb.append(comp.getId()).append(": ")
       .append(compCtrl .getAnnotations()).append('\n');
+
       .append(compCtrl .getAnnotations(null)).append('\n');
  
     for (Iterator it = compCtrl.getAnnotatedProperties().iterator(); it.hasNext();) {
+
     for (String prop: compCtrl.getAnnotatedProperties()) {
        String prop = it.next();
 
 
         sb.append(" with ").append(prop).append(": ")
 
         sb.append(" with ").append(prop).append(": ")
 
             .append(compCtrl .getAnnotations(prop)).append('\n');
 
             .append(compCtrl .getAnnotations(prop)).append('\n');

Revision as of 09:48, 8 February 2012


Retrieve Annotations


The annotations can be retrieved back at the run-time. They are designed to be used by tools or utilities, such as the data-binding manager, rather than applications. In other words, applications annotate a ZUML page to tell the tools how to handle components for a particular purpose.

The following is an example to dump all annotations of a component:

 void dump(StringBuffer sb, Component comp) {
    ComponentCtrl compCtrl = (ComponentCtrl)comp;
     sb.append(comp.getId()).append(": ")
       .append(compCtrl .getAnnotations(null)).append('\n');

     for (String prop: compCtrl.getAnnotatedProperties()) {
         sb.append(" with ").append(prop).append(": ")
             .append(compCtrl .getAnnotations(prop)).append('\n');
     }
 }

Version History

Last Update : 2012/02/08


Version Date Content
     



Last Update : 2012/02/08

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.