1 22 package org.aspectj.tools.ajdoc; 23 24 import org.aspectj.ajdoc.ClassDoc; 25 import org.aspectj.ajdoc.OfClauseDoc; 26 import org.aspectj.ajdoc.OfEachObjectDoc; 27 import org.aspectj.compiler.crosscuts.ast.Pcd; 28 import org.aspectj.compiler.crosscuts.ast.PerCFlow; 29 import org.aspectj.compiler.crosscuts.ast.PerClause; 30 import org.aspectj.compiler.crosscuts.ast.PerObject; 31 import org.aspectj.compiler.crosscuts.ast.PerSingleton; 32 33 import java.util.Collections ; 34 import java.util.List ; 35 36 public class OfClauseDocImpl { 37 38 39 public final static OfClauseDoc getInstance(PerClause clause) { 40 return factory.getInstance(clause); 41 } 42 43 44 private final static Factory factory = new Factory(); 45 46 47 private final static class OfEachObjectDocImpl implements OfEachObjectDoc { 48 private final List instances; 49 private OfEachObjectDocImpl(PerObject eo) { 50 instances = createInstances(eo); 51 } 52 public ClassDoc[] instances() { 53 return (ClassDoc[])instances.toArray(new ClassDoc[instances.size()]); 54 } 55 public OfEachObjectDoc.Kind kind() { 56 return OfClauseDoc.Kind.EACH_OBJECT; 57 } 58 private List createInstances(PerObject eo) { 59 Pcd pc = eo.getPcd(); 60 if (pc == null) { 61 return Collections.EMPTY_LIST; 62 } 63 return Collections.EMPTY_LIST; 64 } 65 } 66 67 68 private static class Factory { 69 70 private final static OfClauseDoc EACH_CFLOW = new OfClauseDoc(){ 71 public OfClauseDoc.Kind kind() { 72 return OfClauseDoc.Kind.EACH_CFLOW; 73 } 74 }; 75 76 private final static OfClauseDoc EACH_JVM = new OfClauseDoc() { 77 public OfClauseDoc.Kind kind() { 78 return OfClauseDoc.Kind.EACH_JVM; 79 } 80 }; 81 82 public final OfClauseDoc getInstance(PerClause clause) { 83 if (clause instanceof PerCFlow) { 84 return EACH_CFLOW; 85 } 86 if (clause instanceof PerSingleton) { 87 return EACH_JVM; 88 } 89 if (clause instanceof PerObject) { 90 return new OfEachObjectDocImpl((PerObject)clause); 91 } 92 return null; } 94 } 95 } 96 | Popular Tags |