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.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  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. public PointcutExpression getPointcutExpression() {
  33. return pc;
  34. }
  35. public String getMessage() {
  36. return msg;
  37. }
  38. public boolean isError() {
  39. return isError;
  40. }
  41. public String toString() {
  42. StringBuilder sb = new StringBuilder();
  43. sb.append("declare ");
  44. sb.append(isError() ? "error : " : "warning : ");
  45. sb.append(getPointcutExpression().asString());
  46. sb.append(" : ");
  47. sb.append("\"");
  48. sb.append(getMessage());
  49. sb.append("\"");
  50. return sb.toString();
  51. }
  52. }