KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > eval > CodeSnippetSkeleton


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.eval;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.jdt.core.JavaModelException;
15 import org.eclipse.jdt.core.compiler.CharOperation;
16 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
17 import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
18 import org.eclipse.jdt.internal.compiler.env.IBinaryField;
19 import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
20 import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
21 import org.eclipse.jdt.internal.compiler.env.IBinaryType;
22 import org.eclipse.jdt.internal.core.util.Util;
23
24 /**
25  * The skeleton of the class 'org.eclipse.jdt.internal.eval.target.CodeSnippet'
26  * used at compile time. Note that the method run() is declared to
27  * throw Throwable so that the user can write a code snipet that
28  * throws checked exceptio without having to catch those.
29  */

30 public class CodeSnippetSkeleton implements IBinaryType, EvaluationConstants {
31     IBinaryMethod[] methods = new IBinaryMethod[] {
32         new BinaryMethodSkeleton(
33             "<init>".toCharArray(), //$NON-NLS-1$
34
"()V".toCharArray(), //$NON-NLS-1$
35
new char[][] {},
36             true
37         ),
38         new BinaryMethodSkeleton(
39             "run".toCharArray(), //$NON-NLS-1$
40
"()V".toCharArray(), //$NON-NLS-1$
41
new char[][] {"java/lang/Throwable".toCharArray()}, //$NON-NLS-1$
42
false
43         ),
44         new BinaryMethodSkeleton(
45             "setResult".toCharArray(), //$NON-NLS-1$
46
"(Ljava/lang/Object;Ljava/lang/Class;)V".toCharArray(), //$NON-NLS-1$
47
new char[][] {},
48             false
49         )
50     };
51
52     public static class BinaryMethodSkeleton implements IBinaryMethod {
53         char[][] exceptionTypeNames;
54         char[] methodDescriptor;
55         char[] selector;
56         boolean isConstructor;
57         
58         public BinaryMethodSkeleton(char[] selector, char[] methodDescriptor, char[][] exceptionTypeNames, boolean isConstructor) {
59             this.selector = selector;
60             this.methodDescriptor = methodDescriptor;
61             this.exceptionTypeNames = exceptionTypeNames;
62             this.isConstructor = isConstructor;
63         }
64         public char[][] getExceptionTypeNames() {
65             return this.exceptionTypeNames;
66         }
67         public char[] getMethodDescriptor() {
68             return this.methodDescriptor;
69         }
70         public int getModifiers() {
71             return ClassFileConstants.AccPublic;
72         }
73         public char[] getSelector() {
74             return this.selector;
75         }
76         public boolean isClinit() {
77             return false;
78         }
79         public boolean isConstructor() {
80             return this.isConstructor;
81         }
82         public char[][] getArgumentNames() {
83             return null;
84         }
85         public char[] getGenericSignature() {
86             return null;
87         }
88         public long getTagBits() {
89             return 0;
90         }
91         public IBinaryAnnotation[] getAnnotations() {
92             return null;
93         }
94         public IBinaryAnnotation[] getParameterAnnotations(int index) {
95             return null;
96         }
97         public Object JavaDoc getDefaultValue() {
98             return null;
99         }
100 }
101     
102 /**
103  * CodeSnippetSkeleton constructor comment.
104  */

105 public CodeSnippetSkeleton() {
106     super();
107 }
108 public char[] getEnclosingTypeName() {
109     return null;
110 }
111 public IBinaryField[] getFields() {
112     return null;
113 }
114 /**
115  * @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName()
116  */

117 public char[] getFileName() {
118     return CharOperation.concat(CODE_SNIPPET_NAME, Util.defaultJavaExtension().toCharArray());
119 }
120 public char[] getGenericSignature() {
121     return null;
122 }
123 public char[][] getInterfaceNames() {
124     return null;
125 }
126 public IBinaryNestedType[] getMemberTypes() {
127     return null;
128 }
129 public IBinaryMethod[] getMethods() {
130     return this.methods;
131 }
132 public int getModifiers() {
133     return ClassFileConstants.AccPublic;
134 }
135 public char[] getName() {
136     return CODE_SNIPPET_NAME;
137 }
138 public char[] getSourceName() {
139     return ROOT_CLASS_NAME;
140 }
141 public char[] getSuperclassName() {
142     return null;
143 }
144 public boolean isAnonymous() {
145     return false;
146 }
147 public boolean isBinaryType() {
148     return true;
149 }
150 public boolean isLocal() {
151     return false;
152 }
153 public boolean isMember() {
154     return false;
155 }
156 public char[] sourceFileName() {
157     return null;
158 }
159 public IBinaryAnnotation[] getAnnotations() {
160     return null;
161 }
162 public long getTagBits() {
163     return 0;
164 }
165 public String JavaDoc getJavadocContents(IProgressMonitor monitor, String JavaDoc defaultEncoding) throws JavaModelException {
166     return null;
167 }
168 public String JavaDoc getJavadocContents() {
169     return null;
170 }
171 public String JavaDoc getURLContents(String JavaDoc docUrlValue, String JavaDoc defaultEncoding) {
172     return null;
173 }
174 }
175
Popular Tags