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 * MatrixParam.java
015 *
016 * Created on January 24, 2007, 2:40 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 URI matrix parameter to a resource method parameter,
029 * resource class field, or resource class bean property.
030 * Values are URL decoded unless this is disabled using the {@link Encoded}
031 * annotation. A default value can be specified using the {@link DefaultValue}
032 * annotation.
033 *
034 * The type <code>T</code> of the annotated parameter, field or property must
035 * 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<T></code>, <code>Set<T></code> or
043 * <code>SortedSet<T></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>Because injection occurs at object creation time, use of this annotation
051 * on resource class fields and bean properties is only supported for the
052 * default per-request resource class lifecycle. Resource classes using
053 * other lifecycles should only use this annotation on resource method
054 * parameters.</p>
055 *
056 * @see DefaultValue
057 * @see Encoded
058 * @see <a href="http://www.w3.org/DesignIssues/MatrixURIs.html">Matrix URIs</a>
059 */
060 @Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD})
061 @Retention(RetentionPolicy.RUNTIME)
062 public @interface MatrixParam {
063 /**
064 * Defines the name of the URI matrix parameter whose value will be used
065 * to initialize the value of the annotated method argument, class field or
066 * bean property. The name is specified in decoded form, any percent encoded
067 * literals within the value will not be decoded and will instead be
068 * treated as literal text. E.g. if the parameter name is "a b" then the
069 * value of the annotation is "a b", <i>not</i> "a+b" or "a%20b".
070 */
071 String value();
072 }