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.

NotTypePattern.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  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. * Contributors:
  10. * Xerox/PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver.patterns;
  13. import java.io.*;
  14. import org.aspectj.util.FuzzyBoolean;
  15. import org.aspectj.weaver.*;
  16. import org.aspectj.weaver.ResolvedTypeX;
  17. /**
  18. * !TypePattern
  19. *
  20. * <p>any binding to formals is explicitly forbidden for any composite, ! is
  21. * just the most obviously wrong case.
  22. *
  23. * @author Erik Hilsdale
  24. * @author Jim Hugunin
  25. */
  26. public class NotTypePattern extends TypePattern {
  27. private TypePattern pattern;
  28. public NotTypePattern(TypePattern pattern) {
  29. super(false); //??? we override all methods that care about includeSubtypes
  30. this.pattern = pattern;
  31. setLocation(pattern.getSourceContext(), pattern.getStart(), pattern.getEnd());
  32. }
  33. public FuzzyBoolean matchesInstanceof(ResolvedTypeX type) {
  34. return pattern.matchesInstanceof(type).not();
  35. }
  36. protected boolean matchesExactly(ResolvedTypeX type) {
  37. return !pattern.matchesExactly(type);
  38. }
  39. public boolean matchesStatically(ResolvedTypeX type) {
  40. return !pattern.matchesStatically(type);
  41. }
  42. public void write(DataOutputStream s) throws IOException {
  43. s.writeByte(TypePattern.NOT);
  44. pattern.write(s);
  45. writeLocation(s);
  46. }
  47. public static TypePattern read(DataInputStream s, ISourceContext context) throws IOException {
  48. TypePattern ret = new NotTypePattern(TypePattern.read(s, context));
  49. ret.readLocation(context, s);
  50. return ret;
  51. }
  52. public TypePattern resolveBindings(
  53. IScope scope,
  54. Bindings bindings,
  55. boolean allowBinding, boolean requireExactType)
  56. {
  57. if (requireExactType) return notExactType(scope);
  58. pattern = pattern.resolveBindings(scope, bindings, false, false);
  59. return this;
  60. }
  61. public String toString() {
  62. return "!" + pattern;
  63. }
  64. }