KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > internal > lang > reflect > DeclarePrecedenceImpl


1 /* *******************************************************************
2  * Copyright (c) 2005 Contributors.
3  * All rights reserved.
4  * This program and the accompanying materials are made available
5  * under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution and is available at
7  * http://eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Adrian Colyer Initial implementation
11  * ******************************************************************/

12 package org.aspectj.internal.lang.reflect;
13
14 import java.util.StringTokenizer JavaDoc;
15
16 import org.aspectj.lang.reflect.AjType;
17 import org.aspectj.lang.reflect.DeclarePrecedence;
18 import org.aspectj.lang.reflect.TypePattern;
19
20 /**
21  * @author colyer
22  *
23  */

24 public class DeclarePrecedenceImpl implements DeclarePrecedence {
25
26     private AjType<?> declaringType;
27     private TypePattern[] precedenceList;
28     private String JavaDoc precedenceString;
29     
30     public DeclarePrecedenceImpl(String JavaDoc precedenceList, AjType declaring) {
31         this.declaringType = declaring;
32         this.precedenceString = precedenceList;
33         String JavaDoc toTokenize = precedenceList;
34         if (toTokenize.startsWith("(")) {
35             toTokenize = toTokenize.substring(1,toTokenize.length() - 1);
36         }
37         StringTokenizer JavaDoc strTok = new StringTokenizer JavaDoc(toTokenize,",");
38         this.precedenceList = new TypePattern[strTok.countTokens()];
39         for (int i = 0; i < this.precedenceList.length; i++) {
40             this.precedenceList[i] = new TypePatternImpl(strTok.nextToken().trim());
41         }
42     }
43
44     /* (non-Javadoc)
45      * @see org.aspectj.lang.reflect.DeclarePrecedence#getDeclaringType()
46      */

47     public AjType getDeclaringType() {
48         return this.declaringType;
49     }
50
51     /* (non-Javadoc)
52      * @see org.aspectj.lang.reflect.DeclarePrecedence#getPrecedenceOrder()
53      */

54     public TypePattern[] getPrecedenceOrder() {
55         return this.precedenceList;
56     }
57     
58     public String JavaDoc toString() {
59         return "declare precedence : " + this.precedenceString;
60     }
61
62 }
63
Popular Tags