Commits

Anonymous committed 0680f9a

WW-1006 annotation docs

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@692e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

tiger/src/java/com/opensymphony/xwork/conversion/annotations/TypeConversion.java

 import java.lang.annotation.*;
 
 /**
- * <code>TypeConversion</code>
- *
- * This annotations is used for class and application wide conversion rules.
- *
+ * <!-- START SNIPPET: description -->
+ * <p/>This annotations is used for class and application wide conversion rules.
  * <p>
  * Class wide conversion:<br/>
  * The conversion rules will be assembled in a file called <code>XXXAction-conversion.properties</code>
  * The conversion rules will be assembled within the <code>xwork-conversion.properties</code> file within the classpath root.
  * Set type to: <code>type = ConversionType.APPLICATION</code>
  * <p/>
+ * <!-- END SNIPPET: description -->
+ *
+ * <p/> <u>Annotation usage:</u>
+ *
+ * <!-- START SNIPPET: usage -->
+ * The TypeConversion annotation can be applied at property and method level.
+ * <!-- END SNIPPET: usage -->
+ *
+ * <p/> <u>Annotation parameters:</u>
+ *
+ * <!-- START SNIPPET: parameters -->
+ * <table>
+ * <thead>
+ * <tr>
+ * <th>Parameter</th>
+ * <th>Required</th>
+ * <th>Default</th>
+ * <th>Description</th>
+ * </tr>
+ * </thead>
+ * <tbody>
+ * <tr>
+ * <td>key</td>
+ * <td>no</td>
+ * <td>The annotated property/key name</td>
+ * <td>The optional property name mostly used within TYPE level annotations.</td>
+ * </tr>
+ * <tr>
+ * <td>type</td>
+ * <td>no</td>
+ * <td>ConversionType.CLASS</td>
+ * <td>Enum value of ConversionType.  Determines whether the conversion should be applied at application or class level.</td>
+ * </tr>
+ * <tr>
+ * <td>rule</td>
+ * <td>no</td>
+ * <td>ConversionRule.PROPERTY</td>
+ * <td>Enum value of ConversionRule. The ConversionRule can be a property, a Collection or a Map.</td>
+ * </tr>
+ * <tr>
+ * <td>converter</td>
+ * <td>either this or value</td>
+ * <td>&nbsp;</td>
+ * <td>The class name of the TypeConverter to be used as converter.</td>
+ * </tr>
+ * <tr>
+ * <td>value</td>
+ * <td>either converter or this</td>
+ * <td>&nbsp;</td>
+ * <td>The value to set for ConversionRule.KEY_PROPERTY.</td>
+ * </tr>
+ * </tbody>
+ * </table>
+ *
+ * <!-- END SNIPPET: parameters -->
+ *
+ * <p/> <u>Example code:</u>
+ *
+ * <pre>
+ * <!-- START SNIPPET: example -->
+ * @Conversion()
+ * public class ConversionAction implements Action {
+ *
+ *  private String convertInt;
+ *
+ * private String convertDouble;
+ * private List users = null;
+ *
+ * private HashMap keyValues = null;
+ *
+ *   @TypeConversion(type = ConversionType.APPLICATION, converter = "com.opensymphony.xwork.util.XWorkBasicConverter")
+ *   public void setConvertInt( String convertInt ) {
+ *       this.convertInt = convertInt;
+ *   }
+ *
+ *   @TypeConversion(converter = "com.opensymphony.xwork.util.XWorkBasicConverter")
+ *   public void setConvertDouble( String convertDouble ) {
+ *       this.convertDouble = convertDouble;
+ *   }
+ *
+ *   @TypeConversion(rule = ConversionRule.COLLECTION, converter = "java.util.String")
+ *   public void setUsers( List users ) {
+ *       this.users = users;
+ *   }
+ *
+ *   @TypeConversion(rule = ConversionRule.MAP, converter = "java.math.BigInteger")
+ *   public void setKeyValues( HashMap keyValues ) {
+ *       this.keyValues = keyValues;
+ *   }
+ *
+ *   @TypeConversion(type = ConversionType.APPLICATION, property = "java.util.Date", converter = "com.opensymphony.xwork.util.XWorkBasicConverter")
+ *   public String execute() throws Exception {
+ *       return SUCCESS;
+ *   }
+ * }
+ * <!-- END SNIPPET: example -->
+ * </pre>
  *
  * @author Rainer Hermanns
  * @version $Id$