KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > expr > ThisOperator


1 /* ThisOperator Copyright (C) 1998-2002 Jochen Hoenicke.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as published by
5  * the Free Software Foundation; either version 2, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; see the file COPYING.LESSER. If not, write to
15  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * $Id: ThisOperator.java,v 1.2.4.1 2002/05/28 17:34:06 hoenicke Exp $
18  */

19
20 package jode.expr;
21 import jode.type.Type;
22 import jode.bytecode.ClassInfo;
23 import jode.decompiler.Scope;
24 import jode.decompiler.TabbedPrintWriter;
25
26 public class ThisOperator extends NoArgOperator {
27     boolean isInnerMost;
28     ClassInfo classInfo;
29
30     public ThisOperator(ClassInfo classInfo, boolean isInnerMost) {
31         super(Type.tClass(classInfo));
32     this.classInfo = classInfo;
33     this.isInnerMost = isInnerMost;
34     }
35
36     public ThisOperator(ClassInfo classInfo) {
37     this(classInfo, false);
38     }
39
40     public ClassInfo getClassInfo() {
41     return classInfo;
42     }
43
44     public int getPriority() {
45         return 1000;
46     }
47
48     public String JavaDoc toString() {
49         return classInfo+".this";
50     }
51
52     public boolean opEquals(Operator o) {
53         return (o instanceof ThisOperator &&
54                 ((ThisOperator) o).classInfo.equals(classInfo));
55     }
56
57     public void dumpExpression(TabbedPrintWriter writer)
58     throws java.io.IOException JavaDoc {
59     if (!isInnerMost) {
60         writer.print(writer.getClassString(classInfo,
61                            Scope.AMBIGUOUSNAME));
62         writer.print(".");
63     }
64     writer.print("this");
65     }
66 }
67
Popular Tags