001: /*******************************************************************************
002: * Copyright (c) 2005, 2007 BEA Systems, Inc.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * tyeung@bea.com - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.apt.tests.annotations.readannotation;
011:
012: @SuppressWarnings("nls")
013: public class CodeExample {
014:
015: public static final String PACKAGE_QUESTION = "question";
016:
017: public static final String ANNOTATION_TEST_CLASS = "AnnotationTest";
018: public static final String ANNOTATION_TEST_CODE = "package question;\n"
019: + "\n"
020: + "@Deprecated\n"
021: + "@RTVisibleAnno(anno=@SimpleAnnotation(\"test\"), clazzes={})\n"
022: + "@RTInvisibleAnno(\"question\")\n"
023: + "public interface AnnotationTest{\n"
024: + "\n"
025: + " @RTVisibleAnno(name = \"Foundation\",\n"
026: + " boolValue = false, \n"
027: + " byteValue = 0x10, \n"
028: + " charValue = 'c', \n"
029: + " doubleValue = 99.0, \n"
030: + " floatValue = (float)9.0, \n"
031: + " intValue = 999, \n"
032: + " longValue = 3333, \n"
033: + " shortValue = 3, \n"
034: + " colors ={ Color.RED, Color.BLUE }, \n"
035: + " anno = @SimpleAnnotation(\"core\"),\n"
036: + " simpleAnnos = {@SimpleAnnotation(\"org\"), \n"
037: + " @SimpleAnnotation(\"eclipse\"),\n"
038: + " @SimpleAnnotation(\"jdt\") }, \n"
039: + " clazzes = {Object.class, String.class},\n "
040: + " clazz = Object.class)\n "
041: + " @RTInvisibleAnno(\"org.eclipse.jdt.core\")\n "
042: + " @Deprecated \n "
043: + " public int field0 = 0; \n"
044: + "\n"
045: + " @Deprecated \n"
046: + " public int field1 = 1; \n"
047: + "\n"
048: + " @RTVisibleAnno(anno=@SimpleAnnotation(\"field\"), clazzes={})\n "
049: + " @RTInvisibleAnno(\"2\") \n "
050: + " public int field2 = 2; \n"
051: + "\n"
052: + " @RTInvisibleAnno(\"3\") \n"
053: + " public int field3 = 3; \n"
054: + "\n"
055: + " @SimpleAnnotation(\"4\") \n"
056: + " public int field4 = 4; \n"
057: + "\n"
058: + " @RTVisibleAnno(anno=@SimpleAnnotation(\"method0\"), clazzes={}) \n"
059: + " @RTInvisibleAnno(\"0\") \n"
060: + " @Deprecated \n "
061: + " public int method0(); \n "
062: + "\n"
063: + " @Deprecated \n "
064: + " public int method1(); \n "
065: + "\n"
066: + " @RTVisibleAnno(anno=@SimpleAnnotation(\"method2\"), clazzes={}) \n "
067: + " @RTInvisibleAnno(\"2\") \n"
068: + " public int method2(); \n"
069: + "\n"
070: + " @RTInvisibleAnno(\"3\") \n"
071: + " public int method3(); \n"
072: + "\n"
073: + " @SimpleAnnotation(\"method4\") \n"
074: + " public int method4(); \n"
075: + "\n"
076: + " public int method5(int p0, \n"
077: + " @Deprecated \n"
078: + " int p1, \n"
079: + " @RTVisibleAnno(anno=@SimpleAnnotation(\"param2\"), clazzes={}) \n"
080: + " @RTInvisibleAnno(\"2\") \n"
081: + " int p2); \n"
082: + "\n"
083: + " public int method6(int p0, int p1, int p2); \n"
084: + "\n }";
085:
086: public static final String COLOR_CLASS = "Color";
087: public static final String COLOR_CODE = "package question;\n"
088: + "\n" + "public enum Color { RED, WHITE, BLUE; } ";
089:
090: public static final String PACKAGE_INFO_CLASS = "package-info";
091: public static final String PACKAGE_INFO_CODE = "@Deprecated package question; ";
092:
093: public static final String RTINVISIBLE_CLASS = "RTInvisibleAnno";
094: public static final String RTINVISIBLE_ANNOTATION_CODE = "package question; \n"
095: + "\n"
096: + " public @interface RTInvisibleAnno{ \n"
097: + " String value(); \n" + " }";
098:
099: public static final String RTVISIBLE_CLASS = "RTVisibleAnno";
100: public static final String RTVISIBLE_ANNOTATION_CODE = "package question; \n"
101: + "\n"
102: + "import java.lang.annotation.*; \n"
103: + "\n"
104: + "@Retention(value=RetentionPolicy.RUNTIME) \n"
105: + "public @interface RTVisibleAnno \n"
106: + "{ \n"
107: + " String name() default \"eclipse\"; \n"
108: + " boolean boolValue() default true; \n"
109: + " byte byteValue() default 0x0001; \n"
110: + " char charValue() default 'e'; \n"
111: + " double doubleValue() default 0.0; \n"
112: + " float floatValue() default 0; \n"
113: + " int intValue() default 17; \n"
114: + " long longValue() default 43; \n"
115: + " short shortValue() default 1; \n"
116: + " Color[] colors() default {Color.RED, Color.WHITE, Color.BLUE}; \n"
117: + " SimpleAnnotation anno(); \n"
118: + " SimpleAnnotation[] simpleAnnos() default { @SimpleAnnotation(\"org.eclipse.org\") }; \n"
119: + " Class<?>[] clazzes(); \n"
120: + " Class<?> clazz() default java.lang.String.class; \n"
121: + "\n }";
122:
123: public static final String SIMPLE_ANNOTATION_CLASS = "SimpleAnnotation";
124: public static final String SIMPLE_ANNOTATION_CODE = "package question; \n"
125: + "\n"
126: + "import java.lang.annotation.Retention; \n"
127: + "import java.lang.annotation.RetentionPolicy; \n"
128: + "\n"
129: + "@Retention(value=RetentionPolicy.RUNTIME) \n"
130: + "public @interface SimpleAnnotation { \n"
131: + "\n"
132: + " String value(); \n" + "}";
133:
134: public static final String PACKAGE_TRIGGER = "trigger";
135: public static final String TRIGGER_CLASS = "Trigger";
136: public static final String TRIGGER_CODE = "package trigger; \n"
137: + "\n" + "@MyMarkerAnnotation \n"
138: + "public class Trigger {}";
139:
140: public static final String MYMARKERANNOTATION_CLASS = "MyMarkerAnnotation";
141: public static final String MYMARKERANNOTATION_CODE = "package trigger; \n"
142: + "\n" + "public @interface MyMarkerAnnotation {}";
143: }
|