You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DeclareErrorOrWarningImpl.java 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. import org.aspectj.lang.reflect.AjType;
  14. import org.aspectj.lang.reflect.DeclareErrorOrWarning;
  15. import org.aspectj.lang.reflect.PointcutExpression;
  16. /**
  17. * @author colyer
  18. *
  19. */
  20. public class DeclareErrorOrWarningImpl implements DeclareErrorOrWarning {
  21. private PointcutExpression pc;
  22. private String msg;
  23. private boolean isError;
  24. private AjType declaringType;
  25. public DeclareErrorOrWarningImpl(String pointcut, String message, boolean isError, AjType decType) {
  26. this.pc = new PointcutExpressionImpl(pointcut);
  27. this.msg = message;
  28. this.isError = isError;
  29. this.declaringType = decType;
  30. }
  31. public AjType getDeclaringType() { return this.declaringType; }
  32. /* (non-Javadoc)
  33. * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#getPointcutExpression()
  34. */
  35. public PointcutExpression getPointcutExpression() {
  36. return pc;
  37. }
  38. /* (non-Javadoc)
  39. * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#getMessage()
  40. */
  41. public String getMessage() {
  42. return msg;
  43. }
  44. /* (non-Javadoc)
  45. * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#isError()
  46. */
  47. public boolean isError() {
  48. return isError;
  49. }
  50. public String toString() {
  51. StringBuffer sb = new StringBuffer();
  52. sb.append("declare ");
  53. sb.append(isError() ? "error : " : "warning : ");
  54. sb.append(getPointcutExpression().asString());
  55. sb.append(" : ");
  56. sb.append("\"");
  57. sb.append(getMessage());
  58. sb.append("\"");
  59. return sb.toString();
  60. }
  61. }