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.

DefaultMatchingContext.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* *******************************************************************
  2. * Copyright (c) 2005 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  8. *
  9. * Contributors:
  10. * Adrian Colyer Initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver.tools;
  13. import java.util.HashMap;
  14. import java.util.Map;
  15. /**
  16. * Default implementation of MatchingContext, backed
  17. * by a Map.
  18. */
  19. public class DefaultMatchingContext implements MatchingContext {
  20. private Map<String, Object> contextMap = new HashMap<>();
  21. /* (non-Javadoc)
  22. * @see org.aspectj.weaver.tools.MatchingContext#hasContextParameter(java.lang.String)
  23. */
  24. public boolean hasContextBinding(String contextParameterName) {
  25. return this.contextMap.containsKey(contextParameterName);
  26. }
  27. /* (non-Javadoc)
  28. * @see org.aspectj.weaver.tools.MatchingContext#get(java.lang.String)
  29. */
  30. public Object getBinding(String contextParameterName) {
  31. return this.contextMap.get(contextParameterName);
  32. }
  33. /**
  34. * Add a context binding with the given name and value
  35. * @param name
  36. * @param value
  37. */
  38. public void addContextBinding(String name, Object value) {
  39. this.contextMap.put(name, value);
  40. }
  41. /**
  42. * Remove the context binding with the given name
  43. * @param name
  44. */
  45. public void removeContextBinding(String name) {
  46. this.contextMap.remove(name);
  47. }
  48. }