KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > compiler > crosscuts > ast > IntersectTypeName


1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the compiler and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  *
22  * Contributor(s):
23  */

24
25 package org.aspectj.compiler.crosscuts.ast;
26 import org.aspectj.compiler.base.ast.*;
27 import org.aspectj.compiler.crosscuts.joinpoints.*;
28
29 import org.aspectj.compiler.base.JavaCompiler;
30
31 import java.util.*;
32 import org.aspectj.util.FuzzyBoolean;
33
34 /**
35  * @grammar name1 && name2
36  * @child GenTypeName name1
37  * @child GenTypeName name2
38  */

39
40 public class IntersectTypeName extends GenTypeName {
41     public String JavaDoc toShortString() {
42         return name1.toShortString() + " && " + name2.toShortString();
43     }
44
45     public boolean matches(Type type) {
46         return name1.matches(type) && name2.matches(type);
47     }
48     
49     public FuzzyBoolean matchesInstance(Type type) {
50         return name1.matchesInstance(type).and(name2.matchesInstance(type));
51     }
52
53     public JpPlan makePlan(JoinPoint jp, Expr expr) {
54         JpPlan plan1 = name1.makePlan(jp, expr);
55         JpPlan plan2 = name2.makePlan(jp, expr);
56         return plan1.and(plan2);
57     }
58     
59     //BEGIN: Generated from @child and @property
60
protected GenTypeName name1;
61     public GenTypeName getName1() { return name1; }
62     public void setName1(GenTypeName _name1) {
63         if (_name1 != null) _name1.setParent(this);
64         name1 = _name1;
65     }
66     
67     protected GenTypeName name2;
68     public GenTypeName getName2() { return name2; }
69     public void setName2(GenTypeName _name2) {
70         if (_name2 != null) _name2.setParent(this);
71         name2 = _name2;
72     }
73     
74     public IntersectTypeName(SourceLocation location, GenTypeName _name1, GenTypeName _name2) {
75         super(location);
76         setName1(_name1);
77         setName2(_name2);
78     }
79     protected IntersectTypeName(SourceLocation source) {
80         super(source);
81     }
82     
83     public ASTObject copyWalk(CopyWalker walker) {
84         IntersectTypeName ret = new IntersectTypeName(getSourceLocation());
85         ret.preCopy(walker, this);
86         if (name1 != null) ret.setName1( (GenTypeName)walker.process(name1) );
87         if (name2 != null) ret.setName2( (GenTypeName)walker.process(name2) );
88         return ret;
89     }
90     
91     public ASTObject getChildAt(int childIndex) {
92         switch(childIndex) {
93         case 0: return name1;
94         case 1: return name2;
95         default: return super.getChildAt(childIndex);
96         }
97     }
98      public String JavaDoc getChildNameAt(int childIndex) {
99         switch(childIndex) {
100         case 0: return "name1";
101         case 1: return "name2";
102         default: return super.getChildNameAt(childIndex);
103         }
104     }
105      public void setChildAt(int childIndex, ASTObject child) {
106         switch(childIndex) {
107         case 0: setName1((GenTypeName)child); return;
108         case 1: setName2((GenTypeName)child); return;
109         default: super.setChildAt(childIndex, child); return;
110         }
111     }
112      public int getChildCount() {
113         return 2;
114     }
115     
116     public String JavaDoc getDefaultDisplayName() {
117         return "IntersectTypeName()";
118     }
119     
120     //END: Generated from @child and @property
121
}
122
123
Popular Tags