Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

NotAnnotationTypePattern.java 4.3KB

15 лет назад
15 лет назад
9 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
9 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
15 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 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. * ******************************************************************/
  10. package org.aspectj.weaver.patterns;
  11. import java.io.IOException;
  12. import java.util.Map;
  13. import org.aspectj.util.FuzzyBoolean;
  14. import org.aspectj.weaver.AnnotatedElement;
  15. import org.aspectj.weaver.CompressingDataOutputStream;
  16. import org.aspectj.weaver.ISourceContext;
  17. import org.aspectj.weaver.ResolvedType;
  18. import org.aspectj.weaver.UnresolvedType;
  19. import org.aspectj.weaver.VersionedDataInputStream;
  20. import org.aspectj.weaver.World;
  21. import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
  22. public class NotAnnotationTypePattern extends AnnotationTypePattern {
  23. AnnotationTypePattern negatedPattern;
  24. public NotAnnotationTypePattern(AnnotationTypePattern pattern) {
  25. this.negatedPattern = pattern;
  26. setLocation(pattern.getSourceContext(), pattern.getStart(), pattern.getEnd());
  27. }
  28. /*
  29. * (non-Javadoc)
  30. *
  31. * @see org.aspectj.weaver.patterns.AnnotationTypePattern#matches(org.aspectj.weaver.AnnotatedElement)
  32. */
  33. public FuzzyBoolean matches(AnnotatedElement annotated) {
  34. return negatedPattern.matches(annotated).not();
  35. }
  36. public FuzzyBoolean matches(AnnotatedElement annotated, ResolvedType[] parameterAnnotations) {
  37. return negatedPattern.matches(annotated, parameterAnnotations).not();
  38. }
  39. /*
  40. * (non-Javadoc)
  41. *
  42. * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolve(org.aspectj.weaver.World)
  43. */
  44. public void resolve(World world) {
  45. negatedPattern.resolve(world);
  46. }
  47. /*
  48. * (non-Javadoc)
  49. *
  50. * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope,
  51. * org.aspectj.weaver.patterns.Bindings, boolean)
  52. */
  53. public AnnotationTypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding) {
  54. negatedPattern = negatedPattern.resolveBindings(scope, bindings, allowBinding);
  55. return this;
  56. }
  57. public AnnotationTypePattern parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) {
  58. AnnotationTypePattern newNegatedPattern = negatedPattern.parameterizeWith(typeVariableMap, w);
  59. NotAnnotationTypePattern ret = new NotAnnotationTypePattern(newNegatedPattern);
  60. ret.copyLocationFrom(this);
  61. if (this.isForParameterAnnotationMatch()) {
  62. ret.setForParameterAnnotationMatch();
  63. }
  64. return ret;
  65. }
  66. /*
  67. * (non-Javadoc)
  68. *
  69. * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream)
  70. */
  71. public void write(CompressingDataOutputStream s) throws IOException {
  72. s.writeByte(AnnotationTypePattern.NOT);
  73. negatedPattern.write(s);
  74. writeLocation(s);
  75. s.writeBoolean(isForParameterAnnotationMatch());
  76. }
  77. public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException {
  78. AnnotationTypePattern ret = new NotAnnotationTypePattern(AnnotationTypePattern.read(s, context));
  79. ret.readLocation(context, s);
  80. if (s.getMajorVersion() >= WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ160) {
  81. if (s.readBoolean()) {
  82. ret.setForParameterAnnotationMatch();
  83. }
  84. }
  85. return ret;
  86. }
  87. public boolean equals(Object obj) {
  88. if (!(obj instanceof NotAnnotationTypePattern)) {
  89. return false;
  90. }
  91. NotAnnotationTypePattern other = (NotAnnotationTypePattern) obj;
  92. return other.negatedPattern.equals(negatedPattern)
  93. && other.isForParameterAnnotationMatch() == isForParameterAnnotationMatch();
  94. }
  95. public int hashCode() {
  96. int result = 17 + 37 * negatedPattern.hashCode();
  97. result = 37 * result + (isForParameterAnnotationMatch() ? 0 : 1);
  98. return result;
  99. }
  100. public String toString() {
  101. return "!" + negatedPattern.toString();
  102. }
  103. public AnnotationTypePattern getNegatedPattern() {
  104. return negatedPattern;
  105. }
  106. public Object accept(PatternNodeVisitor visitor, Object data) {
  107. return visitor.visit(this, data);
  108. }
  109. public Object traverse(PatternNodeVisitor visitor, Object data) {
  110. Object ret = accept(visitor, data);
  111. negatedPattern.traverse(visitor, ret);
  112. return ret;
  113. }
  114. public void setForParameterAnnotationMatch() {
  115. negatedPattern.setForParameterAnnotationMatch();
  116. }
  117. }