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.

NotAnnotationTypePattern.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* *******************************************************************
  2. * Copyright (c) 2004 IBM Corporation.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * ******************************************************************/
  10. package org.aspectj.weaver.patterns;
  11. import java.io.DataOutputStream;
  12. import java.io.IOException;
  13. import org.aspectj.util.FuzzyBoolean;
  14. import org.aspectj.weaver.AnnotatedElement;
  15. import org.aspectj.weaver.ISourceContext;
  16. import org.aspectj.weaver.VersionedDataInputStream;
  17. import org.aspectj.weaver.World;
  18. public class NotAnnotationTypePattern extends AnnotationTypePattern {
  19. private AnnotationTypePattern negatedPattern;
  20. public NotAnnotationTypePattern(AnnotationTypePattern pattern) {
  21. this.negatedPattern = pattern;
  22. setLocation(pattern.getSourceContext(), pattern.getStart(), pattern.getEnd());
  23. }
  24. /* (non-Javadoc)
  25. * @see org.aspectj.weaver.patterns.AnnotationTypePattern#matches(org.aspectj.weaver.AnnotatedElement)
  26. */
  27. public FuzzyBoolean matches(AnnotatedElement annotated) {
  28. return negatedPattern.matches(annotated).not();
  29. }
  30. /* (non-Javadoc)
  31. * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolve(org.aspectj.weaver.World)
  32. */
  33. public void resolve(World world) {
  34. negatedPattern.resolve(world);
  35. }
  36. /* (non-Javadoc)
  37. * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings, boolean)
  38. */
  39. public AnnotationTypePattern resolveBindings(IScope scope,
  40. Bindings bindings, boolean allowBinding) {
  41. negatedPattern = negatedPattern.resolveBindings(scope,bindings,allowBinding);
  42. return this;
  43. }
  44. /* (non-Javadoc)
  45. * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream)
  46. */
  47. public void write(DataOutputStream s) throws IOException {
  48. s.writeByte(AnnotationTypePattern.NOT);
  49. negatedPattern.write(s);
  50. writeLocation(s);
  51. }
  52. public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException {
  53. AnnotationTypePattern ret = new NotAnnotationTypePattern(AnnotationTypePattern.read(s,context));
  54. ret.readLocation(context,s);
  55. return ret;
  56. }
  57. public boolean equals(Object obj) {
  58. if (!(obj instanceof NotAnnotationTypePattern)) return false;
  59. NotAnnotationTypePattern other = (NotAnnotationTypePattern) obj;
  60. return other.negatedPattern.equals(negatedPattern);
  61. }
  62. public int hashCode() {
  63. int result = 17 + 37*negatedPattern.hashCode();
  64. return result;
  65. }
  66. public String toString() {
  67. return "!" + negatedPattern.toString();
  68. }
  69. public AnnotationTypePattern getNegatedPattern() {
  70. return negatedPattern;
  71. }
  72. }