001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.controls.api.bean;
020:
021: import java.lang.annotation.ElementType;
022: import java.lang.annotation.Retention;
023: import java.lang.annotation.RetentionPolicy;
024: import java.lang.annotation.Target;
025:
026: /**
027: * <p>AnnotationMemberTypes defines a set of annotations meant to used on
028: * annotation members to specify additional syntatic and semantic behaviour
029: * or constraints.</p>
030: *
031: * <p>J2SE 5 annotation members provide a very weak level of syntactic and
032: * semantic enforcement. Annotation members may only be a certain type
033: * (mostly primitives, arrays, plus java.lang.String and a few other classes);
034: * it is often useful to be more specific than those types permit.</p>
035: *
036: * <p>Consider the following example:</p>
037: *
038: * <pre>
039: * public @interface LastChanged
040: * {
041: * @AnnotationMemberTypes.Date()
042: * public String date();
043: * }
044: * </pre>
045: *
046: * <p>The use of <code>@AnnotationMemberTypes.Date</code> means that the
047: * value of the <code>date</code> string must be a date in some standard
048: * form.</p>
049: *
050: * <p>AnnotationMemberTypes defines a set of annotations and their semantics,
051: * but actual enforcement of those semantics is implementation dependent.
052: * An <code>apt</code>-based reference implementation is provided by
053: * {@link org.apache.beehive.controls.runtime.bean.AnnotationConstraintValidator}.</p>
054: *
055: * @see org.apache.beehive.controls.runtime.bean.AnnotationConstraintValidator
056: */
057: public interface AnnotationMemberTypes {
058: public final static String OPTIONAL_STRING = "";
059: public final static double OPTIONAL_DOUBLE = Double.MIN_VALUE;
060: public final static float OPTIONAL_FLOAT = Float.MIN_VALUE;
061: public final static int OPTIONAL_INT = Integer.MIN_VALUE;
062: public final static long OPTIONAL_LONG = Long.MIN_VALUE;
063: public final static short OPTIONAL_SHORT = Short.MIN_VALUE;
064: public final static char OPTIONAL_CHAR = Character.MIN_VALUE;
065: public final static byte OPTIONAL_BYTE = Byte.MIN_VALUE;
066: public final static int UNLIMITED_PLACES = -1;
067:
068: /**
069: * Marks a member as optional. Member must have
070: * a default value.
071: */
072: @Target({ElementType.METHOD})
073: @Retention(RetentionPolicy.RUNTIME)
074: public @interface Optional {
075: }
076:
077: /**
078: * Member must be a String value.
079: */
080: @Target({ElementType.METHOD})
081: @Retention(RetentionPolicy.RUNTIME)
082: public @interface Text {
083: boolean isLong() default false;
084:
085: int maxLength() default Integer.MAX_VALUE;
086: }
087:
088: /**
089: * Member is a Decimal Value.
090: * Can be applied to a member that returns float, double or String.
091: */
092: @Target({ElementType.METHOD})
093: @Retention(RetentionPolicy.RUNTIME)
094: public @interface Decimal {
095: int places() default UNLIMITED_PLACES;
096:
097: double minValue() default Double.MIN_VALUE;
098:
099: double maxValue() default Double.MAX_VALUE;
100: }
101:
102: /**
103: * Member is an Integer value.
104: * Can be applied to a member that returns String or int.
105: */
106: @Target({ElementType.METHOD})
107: @Retention(RetentionPolicy.RUNTIME)
108: public @interface Int {
109: int minValue() default Integer.MIN_VALUE;
110:
111: int maxValue() default Integer.MAX_VALUE;
112: }
113:
114: /**
115: * Member is a Date in the format specified (default is YYYY/MM/DD)
116: * Only valid on a member that returns String
117: * @see java.text.SimpleDateFormat when selecting another date format.
118: * Note: JSR175 does not allow java.util.Date as
119: * a member type.
120: */
121: @Target({ElementType.METHOD})
122: @Retention(RetentionPolicy.RUNTIME)
123: public @interface Date {
124: String format() default "yyyy/MM/dd";
125:
126: String minValue() default "";
127:
128: String maxValue() default "";
129: }
130:
131: /**
132: * Member is a URI
133: * Only valid on a member that returns String
134: */
135: @Target({ElementType.METHOD})
136: @Retention(RetentionPolicy.RUNTIME)
137: public @interface URI {
138: }
139:
140: /**
141: * Member is a URN
142: * Only valid on a member that returns String
143: */
144: @Target({ElementType.METHOD})
145: @Retention(RetentionPolicy.RUNTIME)
146: public @interface URN {
147: }
148:
149: /**
150: * Member is a URL
151: * Only valid on a member that returns String
152: */
153: @Target({ElementType.METHOD})
154: @Retention(RetentionPolicy.RUNTIME)
155: public @interface URL {
156: }
157:
158: /**
159: * Member is a QName
160: * Only valid on a member that returns String
161: */
162: @Target({ElementType.METHOD})
163: @Retention(RetentionPolicy.RUNTIME)
164: public @interface QName {
165: }
166:
167: /**
168: * Member contains well formed XML
169: * Only valid on a member that returns String
170: */
171: @Target({ElementType.METHOD})
172: @Retention(RetentionPolicy.RUNTIME)
173: public @interface XML {
174: }
175:
176: /**
177: * Member is a File Path
178: * Compiler MUST validate that value points
179: * to a <code>readable</code> file.
180: * Only valid on a member that returns String.
181: */
182: @Target({ElementType.METHOD})
183: @Retention(RetentionPolicy.RUNTIME)
184: public @interface FilePath {
185: }
186:
187: /**
188: * Member is a JNDI name.
189: */
190: @Target({ElementType.METHOD})
191: @Retention(RetentionPolicy.RUNTIME)
192: public @interface JndiName {
193: /**
194: * Defines the type of JNDI resource reference by a member.
195: */
196: public enum ResourceType {
197: DATASOURCE, EJB, JMS_TOPIC, JMS_QUEUE, OTHER
198: }
199:
200: ResourceType resourceType();
201: }
202: }
|