01: /*
02: * Javassist, a Java-bytecode translator toolkit.
03: * Copyright (C) 1999-2006 Shigeru Chiba. All Rights Reserved.
04: *
05: * The contents of this file are subject to the Mozilla Public License Version
06: * 1.1 (the "License"); you may not use this file except in compliance with
07: * the License. Alternatively, the contents of this file may be used under
08: * the terms of the GNU Lesser General Public License Version 2.1 or later.
09: *
10: * Software distributed under the License is distributed on an "AS IS" basis,
11: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12: * for the specific language governing rights and limitations under the
13: * License.
14: */
15:
16: package javassist.expr;
17:
18: import javassist.CtClass;
19: import javassist.CtConstructor;
20: import javassist.CtMethod;
21: import javassist.NotFoundException;
22: import javassist.bytecode.CodeIterator;
23: import javassist.bytecode.MethodInfo;
24:
25: /**
26: * Constructor call such as <code>this()</code> and <code>super()</code>
27: * within a constructor body.
28: *
29: * @see NewExpr
30: */
31: public class ConstructorCall extends MethodCall {
32: /**
33: * Undocumented constructor. Do not use; internal-use only.
34: */
35: protected ConstructorCall(int pos, CodeIterator i, CtClass decl,
36: MethodInfo m) {
37: super (pos, i, decl, m);
38: }
39:
40: /**
41: * Returns <code>"super"</code> or "<code>"this"</code>.
42: */
43: public String getMethodName() {
44: return isSuper() ? "super" : "this";
45: }
46:
47: /**
48: * Always throws a <code>NotFoundException</code>.
49: *
50: * @see #getConstructor()
51: */
52: public CtMethod getMethod() throws NotFoundException {
53: throw new NotFoundException(
54: "this is a constructor call. Call getConstructor().");
55: }
56:
57: /**
58: * Returns the called constructor.
59: */
60: public CtConstructor getConstructor() throws NotFoundException {
61: return getCtClass().getConstructor(getSignature());
62: }
63:
64: /**
65: * Returns true if the called constructor is not <code>this()</code>
66: * but <code>super()</code> (a constructor declared in the super class).
67: */
68: public boolean isSuper() {
69: return super.isSuper();
70: }
71: }
|