KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.aspectj.lang.reflect.AjType;
15 import org.aspectj.lang.reflect.DeclareErrorOrWarning;
16 import org.aspectj.lang.reflect.PointcutExpression;
17
18 /**
19  * @author colyer
20  *
21  */

22 public class DeclareErrorOrWarningImpl implements DeclareErrorOrWarning {
23
24     private PointcutExpression pc;
25     private String JavaDoc msg;
26     private boolean isError;
27     private AjType declaringType;
28     
29     public DeclareErrorOrWarningImpl(String JavaDoc pointcut, String JavaDoc message, boolean isError, AjType decType) {
30         this.pc = new PointcutExpressionImpl(pointcut);
31         this.msg = message;
32         this.isError = isError;
33         this.declaringType = decType;
34     }
35     
36     public AjType getDeclaringType() { return this.declaringType; }
37     
38     /* (non-Javadoc)
39      * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#getPointcutExpression()
40      */

41     public PointcutExpression getPointcutExpression() {
42         return pc;
43     }
44
45     /* (non-Javadoc)
46      * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#getMessage()
47      */

48     public String JavaDoc getMessage() {
49         return msg;
50     }
51
52     /* (non-Javadoc)
53      * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#isError()
54      */

55     public boolean isError() {
56         return isError;
57     }
58     
59     public String JavaDoc toString() {
60         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
61         sb.append("declare ");
62         sb.append(isError() ? "error : " : "warning : ");
63         sb.append(getPointcutExpression().asString());
64         sb.append(" : ");
65         sb.append("\"");
66         sb.append(getMessage());
67         sb.append("\"");
68         return sb.toString();
69     }
70
71 }
72
Popular Tags