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.

IRelationship.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* *******************************************************************
  2. * Copyright (c) 2003 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://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Mik Kersten initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.asm;
  13. import java.io.ObjectStreamException;
  14. import java.io.Serializable;
  15. import java.util.List;
  16. /**
  17. * A relationship has a name (e.g. 'declare warning') and some set of affected targets.
  18. *
  19. * @author Mik Kersten
  20. * @author Andy Clement
  21. */
  22. public interface IRelationship extends Serializable {
  23. public String getName();
  24. public Kind getKind();
  25. public void addTarget(String handle);
  26. public List<String> getTargets();
  27. public String getSourceHandle();
  28. public boolean hasRuntimeTest();
  29. public boolean isAffects();
  30. public static class Kind implements Serializable { // typesafe enum
  31. private static final long serialVersionUID = -2691351740214705220L;
  32. public static final Kind DECLARE_WARNING = new Kind("declare warning");
  33. public static final Kind DECLARE_ERROR = new Kind("declare error");
  34. public static final Kind ADVICE_AROUND = new Kind("around advice");
  35. public static final Kind ADVICE_AFTERRETURNING = new Kind("after returning advice");
  36. public static final Kind ADVICE_AFTERTHROWING = new Kind("after throwing advice");
  37. public static final Kind ADVICE_AFTER = new Kind("after advice");
  38. public static final Kind ADVICE_BEFORE = new Kind("before advice");
  39. public static final Kind ADVICE = new Kind("advice");
  40. public static final Kind DECLARE = new Kind("declare");
  41. public static final Kind DECLARE_INTER_TYPE = new Kind("inter-type declaration");
  42. public static final Kind USES_POINTCUT = new Kind("uses pointcut");
  43. public static final Kind DECLARE_SOFT = new Kind("declare soft");
  44. public static final Kind[] ALL = { DECLARE_WARNING, DECLARE_ERROR, ADVICE_AROUND, ADVICE_AFTERRETURNING,
  45. ADVICE_AFTERTHROWING, ADVICE_AFTER, ADVICE_BEFORE, ADVICE, DECLARE, DECLARE_INTER_TYPE, USES_POINTCUT, DECLARE_SOFT };
  46. private final String name;
  47. public boolean isDeclareKind() {
  48. return this == DECLARE_WARNING || this == DECLARE_ERROR || this == DECLARE || this == DECLARE_INTER_TYPE
  49. || this == DECLARE_SOFT;
  50. }
  51. public String getName() {
  52. return name;
  53. }
  54. /**
  55. * Return the Kind of the relationship that is passed in by name.
  56. *
  57. * @param stringFormOfRelationshipKind the relationship name, eg. 'declare warning', 'declare error', etc.
  58. * @return the Kind instance
  59. */
  60. public static Kind getKindFor(String stringFormOfRelationshipKind) {
  61. for (Kind kind : ALL) {
  62. if (kind.name.equals(stringFormOfRelationshipKind)) {
  63. return kind;
  64. }
  65. }
  66. return null;
  67. }
  68. private Kind(String name) {
  69. this.name = name;
  70. }
  71. public String toString() {
  72. return name;
  73. }
  74. // The 4 declarations below are necessary for serialization
  75. private static int nextOrdinal = 0;
  76. private final int ordinal = nextOrdinal++;
  77. private Object readResolve() throws ObjectStreamException {
  78. return ALL[ordinal];
  79. }
  80. }
  81. }