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.

OfClauseDocImpl.java 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * This file is part of the debugger and core tools for the AspectJ(tm)
  4. * programming language; see http://aspectj.org
  5. *
  6. * The contents of this file are subject to the Mozilla Public License
  7. * Version 1.1 (the "License"); you may not use this file except in
  8. * compliance with the License. You may obtain a copy of the License at
  9. * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is AspectJ.
  17. *
  18. * The Initial Developer of the Original Code is Xerox Corporation. Portions
  19. * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
  20. * All Rights Reserved.
  21. */
  22. package org.aspectj.tools.ajdoc;
  23. import org.aspectj.ajdoc.ClassDoc;
  24. import org.aspectj.ajdoc.OfClauseDoc;
  25. import org.aspectj.ajdoc.OfEachObjectDoc;
  26. import org.aspectj.compiler.crosscuts.ast.Pcd;
  27. import org.aspectj.compiler.crosscuts.ast.PerCFlow;
  28. import org.aspectj.compiler.crosscuts.ast.PerClause;
  29. import org.aspectj.compiler.crosscuts.ast.PerObject;
  30. import org.aspectj.compiler.crosscuts.ast.PerSingleton;
  31. import java.util.Collections;
  32. import java.util.List;
  33. public class OfClauseDocImpl {
  34. /** TODO */
  35. public final static OfClauseDoc getInstance(PerClause clause) {
  36. return factory.getInstance(clause);
  37. }
  38. /** The factory used to create the instance. */
  39. private final static Factory factory = new Factory();
  40. /** TODO */
  41. private final static class OfEachObjectDocImpl implements OfEachObjectDoc {
  42. private final List instances;
  43. private OfEachObjectDocImpl(PerObject eo) {
  44. instances = createInstances(eo);
  45. }
  46. public ClassDoc[] instances() {
  47. return (ClassDoc[])instances.toArray(new ClassDoc[instances.size()]);
  48. }
  49. public OfEachObjectDoc.Kind kind() {
  50. return OfClauseDoc.Kind.EACH_OBJECT;
  51. }
  52. private List createInstances(PerObject eo) {
  53. Pcd pc = eo.getPcd();
  54. if (pc == null) {
  55. return Collections.EMPTY_LIST;
  56. }
  57. return Collections.EMPTY_LIST;
  58. }
  59. }
  60. /** TODO */
  61. private static class Factory {
  62. private final static OfClauseDoc EACH_CFLOW = new OfClauseDoc(){
  63. public OfClauseDoc.Kind kind() {
  64. return OfClauseDoc.Kind.EACH_CFLOW;
  65. }
  66. };
  67. private final static OfClauseDoc EACH_JVM = new OfClauseDoc() {
  68. public OfClauseDoc.Kind kind() {
  69. return OfClauseDoc.Kind.EACH_JVM;
  70. }
  71. };
  72. public final OfClauseDoc getInstance(PerClause clause) {
  73. if (clause instanceof PerCFlow) {
  74. return EACH_CFLOW;
  75. }
  76. if (clause instanceof PerSingleton) {
  77. return EACH_JVM;
  78. }
  79. if (clause instanceof PerObject) {
  80. return new OfEachObjectDocImpl((PerObject)clause);
  81. }
  82. return null; //??? error
  83. }
  84. }
  85. }