KickJava   Java API By Example, From Geeks To Geeks.

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


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 staticinitialization(typeName)
36   * @child GenTypeName typeName
37   *
38   * XXX this is a KindedPcd, but doesn't match that API
39   */

40 public class StaticInitializerPcd extends Pcd {
41     public String JavaDoc toShortString() {
42         return "staticinitialization(" + getTypeName().toShortString() + ")";
43     }
44     public void checkStatic() { }
45     public int getJpKind() {
46         return JoinPoint.STATIC_INITIALIZER_EXECUTION;
47     }
48     
49     public JpPlanner makePlanner(PlanData planData) {
50         return new JpPlanner() {
51             public FuzzyBoolean fastMatch(JoinPoint jp) {
52                 if (!(jp.getTypeCode() == getJpKind())) return FuzzyBoolean.NO;
53                 return getTypeName().matches(jp.getTargetType()) ?
54                     FuzzyBoolean.YES : FuzzyBoolean.NO;
55             }
56         };
57     }
58     
59     //BEGIN: Generated from @child and @property
60
protected GenTypeName typeName;
61     public GenTypeName getTypeName() { return typeName; }
62     public void setTypeName(GenTypeName _typeName) {
63         if (_typeName != null) _typeName.setParent(this);
64         typeName = _typeName;
65     }
66     
67     public StaticInitializerPcd(SourceLocation location, GenTypeName _typeName) {
68         super(location);
69         setTypeName(_typeName);
70     }
71     protected StaticInitializerPcd(SourceLocation source) {
72         super(source);
73     }
74     
75     public ASTObject copyWalk(CopyWalker walker) {
76         StaticInitializerPcd ret = new StaticInitializerPcd(getSourceLocation());
77         ret.preCopy(walker, this);
78         if (typeName != null) ret.setTypeName( (GenTypeName)walker.process(typeName) );
79         return ret;
80     }
81     
82     public ASTObject getChildAt(int childIndex) {
83         switch(childIndex) {
84         case 0: return typeName;
85         default: return super.getChildAt(childIndex);
86         }
87     }
88      public String JavaDoc getChildNameAt(int childIndex) {
89         switch(childIndex) {
90         case 0: return "typeName";
91         default: return super.getChildNameAt(childIndex);
92         }
93     }
94      public void setChildAt(int childIndex, ASTObject child) {
95         switch(childIndex) {
96         case 0: setTypeName((GenTypeName)child); return;
97         default: super.setChildAt(childIndex, child); return;
98         }
99     }
100      public int getChildCount() {
101         return 1;
102     }
103     
104     public String JavaDoc getDefaultDisplayName() {
105         return "StaticInitializerPcd()";
106     }
107     
108     //END: Generated from @child and @property
109
}
110
111
Popular Tags