KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.aspectj.util.FuzzyBoolean;
31
32 import java.util.*;
33
34 /**
35   * @grammar *(pattern)
36   * @child DecPattern pattern
37   */

38 public abstract class KindedPcd extends Pcd {
39     public void checkStatic() { }
40     public String JavaDoc toShortString() {
41         return getKind() + "(" + getPattern().toShortString() + ")";
42     }
43
44     public abstract String JavaDoc getKind();
45     public abstract int getJpKind();
46
47     public JpPlanner makePlanner(PlanData planData) {
48         return new JpPlanner() {
49             public FuzzyBoolean fastMatch(JoinPoint jp) {
50                 if (!(jp.getTypeCode() == getJpKind())) return FuzzyBoolean.NO;
51                 
52                 
53                 return getPattern().matches(jp);
54             }
55         };
56     }
57     
58     //BEGIN: Generated from @child and @property
59
protected DecPattern pattern;
60     public DecPattern getPattern() { return pattern; }
61     public void setPattern(DecPattern _pattern) {
62         if (_pattern != null) _pattern.setParent(this);
63         pattern = _pattern;
64     }
65     
66     public KindedPcd(SourceLocation location, DecPattern _pattern) {
67         super(location);
68         setPattern(_pattern);
69     }
70     protected KindedPcd(SourceLocation source) {
71         super(source);
72     }
73     
74     public ASTObject getChildAt(int childIndex) {
75         switch(childIndex) {
76         case 0: return pattern;
77         default: return super.getChildAt(childIndex);
78         }
79     }
80      public String JavaDoc getChildNameAt(int childIndex) {
81         switch(childIndex) {
82         case 0: return "pattern";
83         default: return super.getChildNameAt(childIndex);
84         }
85     }
86      public void setChildAt(int childIndex, ASTObject child) {
87         switch(childIndex) {
88         case 0: setPattern((DecPattern)child); return;
89         default: super.setChildAt(childIndex, child); return;
90         }
91     }
92      public int getChildCount() {
93         return 1;
94     }
95     
96     public String JavaDoc getDefaultDisplayName() {
97         return "KindedPcd()";
98     }
99     
100     //END: Generated from @child and @property
101
}
102
103
Popular Tags