KickJava   Java API By Example, From Geeks To Geeks.

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


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
28 import org.aspectj.compiler.base.JavaCompiler;
29
30 /** @grammar ...
31   * @child TypeDs trueNames
32   * @child TypeDs falseNames
33   */

34 public class NameTypeDsPattern extends ASTObject {
35     public boolean matches(TypeDs otherNames) {
36         if (otherNames == null) return trueNames.size() == 0;
37
38         int i;
39         final int N1 = trueNames.size();
40         for(i=0; i<N1; i++) {
41             //System.out.println("t: " + trueNames.get(i) + ", " + otherNames.get(0));
42
if (!otherNames.contains(trueNames.get(i))) return false;
43         }
44
45         final int N2 = falseNames.size();
46         for(i=0; i<N2; i++) {
47             //System.out.println("f: " + falseNames.get(i));
48
if (otherNames.contains(falseNames.get(i))) return false;
49         }
50
51         //System.out.println("matches");
52

53         return true;
54     }
55     
56     //BEGIN: Generated from @child and @property
57
protected TypeDs trueNames;
58     public TypeDs getTrueNames() { return trueNames; }
59     public void setTrueNames(TypeDs _trueNames) {
60         if (_trueNames != null) _trueNames.setParent(this);
61         trueNames = _trueNames;
62     }
63     
64     protected TypeDs falseNames;
65     public TypeDs getFalseNames() { return falseNames; }
66     public void setFalseNames(TypeDs _falseNames) {
67         if (_falseNames != null) _falseNames.setParent(this);
68         falseNames = _falseNames;
69     }
70     
71     public NameTypeDsPattern(SourceLocation location, TypeDs _trueNames, TypeDs _falseNames) {
72         super(location);
73         setTrueNames(_trueNames);
74         setFalseNames(_falseNames);
75     }
76     protected NameTypeDsPattern(SourceLocation source) {
77         super(source);
78     }
79     
80     public ASTObject copyWalk(CopyWalker walker) {
81         NameTypeDsPattern ret = new NameTypeDsPattern(getSourceLocation());
82         ret.preCopy(walker, this);
83         if (trueNames != null) ret.setTrueNames( (TypeDs)walker.process(trueNames) );
84         if (falseNames != null) ret.setFalseNames( (TypeDs)walker.process(falseNames) );
85         return ret;
86     }
87     
88     public ASTObject getChildAt(int childIndex) {
89         switch(childIndex) {
90         case 0: return trueNames;
91         case 1: return falseNames;
92         default: return super.getChildAt(childIndex);
93         }
94     }
95      public String JavaDoc getChildNameAt(int childIndex) {
96         switch(childIndex) {
97         case 0: return "trueNames";
98         case 1: return "falseNames";
99         default: return super.getChildNameAt(childIndex);
100         }
101     }
102      public void setChildAt(int childIndex, ASTObject child) {
103         switch(childIndex) {
104         case 0: setTrueNames((TypeDs)child); return;
105         case 1: setFalseNames((TypeDs)child); return;
106         default: super.setChildAt(childIndex, child); return;
107         }
108     }
109      public int getChildCount() {
110         return 2;
111     }
112     
113     public String JavaDoc getDefaultDisplayName() {
114         return "NameTypeDsPattern()";
115     }
116     
117     //END: Generated from @child and @property
118
}
119
120
Popular Tags