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.

AndAnnotationTypePattern.java 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. /**
  19. * @author colyer
  20. *
  21. * TODO To change the template for this generated type comment go to
  22. * Window - Preferences - Java - Code Style - Code Templates
  23. */
  24. public class AndAnnotationTypePattern extends AnnotationTypePattern {
  25. private AnnotationTypePattern left;
  26. private AnnotationTypePattern right;
  27. public AndAnnotationTypePattern(AnnotationTypePattern left, AnnotationTypePattern right) {
  28. this.left = left;
  29. this.right = right;
  30. setLocation(left.getSourceContext(), left.getStart(), right.getEnd());
  31. }
  32. public FuzzyBoolean matches(AnnotatedElement annotated) {
  33. return left.matches(annotated).and(right.matches(annotated));
  34. }
  35. public void resolve(World world) {
  36. left.resolve(world);
  37. right.resolve(world);
  38. }
  39. /* (non-Javadoc)
  40. * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings, boolean)
  41. */
  42. public AnnotationTypePattern resolveBindings(IScope scope,
  43. Bindings bindings, boolean allowBinding) {
  44. left = left.resolveBindings(scope,bindings,allowBinding);
  45. right =right.resolveBindings(scope,bindings,allowBinding);
  46. return this;
  47. }
  48. public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException {
  49. AnnotationTypePattern p = new AndAnnotationTypePattern(
  50. AnnotationTypePattern.read(s,context),
  51. AnnotationTypePattern.read(s,context));
  52. p.readLocation(context,s);
  53. return p;
  54. }
  55. public void write(DataOutputStream s) throws IOException {
  56. s.writeByte(AnnotationTypePattern.AND);
  57. left.write(s);
  58. right.write(s);
  59. writeLocation(s);
  60. }
  61. public boolean equals(Object obj) {
  62. if (!(obj instanceof AndAnnotationTypePattern)) return false;
  63. AndAnnotationTypePattern other = (AndAnnotationTypePattern) obj;
  64. return (left.equals(other.left) && right.equals(other.right));
  65. }
  66. public int hashCode() {
  67. int result = 17;
  68. result = result*37 + left.hashCode();
  69. result = result*37 + right.hashCode();
  70. return result;
  71. }
  72. public String toString() {
  73. return left.toString() + " " + right.toString();
  74. }
  75. public AnnotationTypePattern getLeft() { return left; }
  76. public AnnotationTypePattern getRight() { return right; }
  77. }