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.

InterTypeDeclarationImpl.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 v1.0
  6. * which accompanies this distribution and is available at
  7. * http://eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Adrian Colyer Initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.internal.lang.reflect;
  13. import org.aspectj.lang.reflect.AjType;
  14. import org.aspectj.lang.reflect.InterTypeDeclaration;
  15. /**
  16. * @author colyer
  17. *
  18. */
  19. public class InterTypeDeclarationImpl implements InterTypeDeclaration {
  20. private AjType<?> declaringType;
  21. protected String targetTypeName;
  22. private AjType<?> targetType;
  23. private int modifiers;
  24. public InterTypeDeclarationImpl(AjType<?> decType, String target, int mods) {
  25. this.declaringType = decType;
  26. this.targetTypeName = target;
  27. this.modifiers = mods;
  28. try {
  29. this.targetType = (AjType<?>) StringToType.stringToType(target, decType.getJavaClass());
  30. } catch (ClassNotFoundException cnf) {
  31. // we'll only report this later if the user asks for the target type.
  32. }
  33. }
  34. public InterTypeDeclarationImpl(AjType<?> decType, AjType<?> targetType, int mods) {
  35. this.declaringType = decType;
  36. this.targetType = targetType;
  37. this.targetTypeName = targetType.getName();
  38. this.modifiers = mods;
  39. }
  40. /* (non-Javadoc)
  41. * @see org.aspectj.lang.reflect.InterTypeDeclaration#getDeclaringType()
  42. */
  43. public AjType<?> getDeclaringType() {
  44. return this.declaringType;
  45. }
  46. /* (non-Javadoc)
  47. * @see org.aspectj.lang.reflect.InterTypeDeclaration#getTargetType()
  48. */
  49. public AjType<?> getTargetType() throws ClassNotFoundException {
  50. if (this.targetType == null) throw new ClassNotFoundException(this.targetTypeName);
  51. return this.targetType;
  52. }
  53. /* (non-Javadoc)
  54. * @see org.aspectj.lang.reflect.InterTypeDeclaration#getModifiers()
  55. */
  56. public int getModifiers() {
  57. return this.modifiers;
  58. }
  59. }