001    /*
002     * The contents of this file are subject to the terms
003     * of the Common Development and Distribution License
004     * (the "License").  You may not use this file except
005     * in compliance with the License.
006     * 
007     * You can obtain a copy of the license at
008     * http://www.opensource.org/licenses/cddl1.php
009     * See the License for the specific language governing
010     * permissions and limitations under the License.
011     */
012    
013    /*
014     * FormParam.java
015     *
016     * Created on November 16, 2006, 2:04 PM
017     *
018     */
019    
020    package javax.ws.rs;
021    
022    import java.lang.annotation.ElementType;
023    import java.lang.annotation.Retention;
024    import java.lang.annotation.RetentionPolicy;
025    import java.lang.annotation.Target;
026    
027    /**
028     * Binds the value(s) of a form parameter contained within a request entity body
029     * to a resource method parameter. Values are URL decoded unless this is
030     * disabled using the {@link Encoded} annotation. A default value can be
031     * specified using the {@link DefaultValue} annotation.
032     * If the request entity body is absent or is an unsupported media type, the
033     * default value is used.
034     * 
035     * The type <code>T</code> of the annotated parameter must either:
036     * <ol>
037     * <li>Be a primitive type</li>
038     * <li>Have a constructor that accepts a single <code>String</code> argument</li>
039     * <li>Have a static method named <code>valueOf</code> or <code>fromString</code>
040     * that accepts a single 
041     * <code>String</code> argument (see, for example, {@link Integer#valueOf(String)})</li>
042     * <li>Be <code>List&lt;T&gt;</code>, <code>Set&lt;T&gt;</code> or 
043     * <code>SortedSet&lt;T&gt;</code>, where <code>T</code> satisfies 2 or 3 above.
044     * The resulting collection is read-only.</li>
045     * </ol>
046     * 
047     * <p>If the type is not one of those listed in 4 above then the first value 
048     * (lexically) of the parameter is used.</p>
049     * 
050     * <p>Note that, whilst the annotation target permits use on fields and methods,
051     * this annotation is only required to be supported on resource method
052     * parameters.</p>
053     *
054     * @see DefaultValue
055     * @see Encoded
056     */
057    @Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD})
058    @Retention(RetentionPolicy.RUNTIME)
059    public @interface FormParam {
060        /**
061         * Defines the name of the form parameter whose value will be used
062         * to initialize the value of the annotated method argument. The name is 
063         * specified in decoded form, any percent encoded literals within the value
064         * will not be decoded and will instead be treated as literal text. E.g. if
065         * the parameter name is "a b" then the value of the annotation is "a b", 
066         * <i>not</i> "a+b" or "a%20b".
067         */
068        String value();
069    }