1 22 package org.jboss.aop.metadata; 23 24 import org.jboss.aop.expressions.ConstructorExpression; 25 import org.jboss.aop.expressions.MethodExpression; 26 27 import java.util.ArrayList ; 28 import java.util.regex.Matcher ; 29 import java.util.regex.Pattern ; 30 37 public class SimpleClassMetaDataBinding extends ClassMetaDataBinding 38 { 39 public class QueuedMetaData 40 { 41 protected Pattern expr; 42 public String tag; 43 public String attr; 44 public Object value; 45 46 public QueuedMetaData(String exp, String tag, String attr, Object value) 47 { 48 exp = exp.replaceAll("\\.", "\\\\."); 49 exp = exp.replaceAll("\\*", ".*"); 50 this.expr = Pattern.compile(exp); 51 this.tag = tag; 52 this.attr = attr; 53 this.value = value; 54 } 55 56 public String getExpr() { return this.expr.toString(); } 57 public boolean matches(String match) 58 { 59 Matcher m = expr.matcher(match); 60 return m.matches(); 61 } 62 } 63 64 public class QueuedMethodMetaData 65 { 66 public MethodExpression expr; 67 public String tag; 68 public String attr; 69 public Object value; 70 71 public QueuedMethodMetaData(String expr, String tag, String attr, Object value) 72 { 73 this.expr = new MethodExpression(expr); 74 this.tag = tag; 75 this.attr = attr; 76 this.value = value; 77 } 78 } 79 80 public class QueuedConstructorMetaData 81 { 82 public ConstructorExpression expr; 83 public String tag; 84 public String attr; 85 public Object value; 86 87 public QueuedConstructorMetaData(String expr, String tag, String attr, Object value) 88 { 89 this.expr = new ConstructorExpression(expr); 90 this.tag = tag; 91 this.attr = attr; 92 this.value = value; 93 } 94 } 95 96 protected SimpleMetaData defaultMetaData = new SimpleMetaData(); 97 protected SimpleMetaData classMetaData = new SimpleMetaData(); 98 protected ArrayList queuedMethodMetaData = new ArrayList (); 99 protected ArrayList queuedFieldMetaData = new ArrayList (); 100 protected ArrayList queuedConstructorMetaData = new ArrayList (); 101 102 public SimpleClassMetaDataBinding(ClassMetaDataLoader loader, String name, String tag, String expr) 103 { 104 super(loader, name, tag, expr); 105 } 106 107 public void addDefaultMetaData(String tag, String attr, Object value) 108 { 109 defaultMetaData.addMetaData(tag, attr, value); 110 } 111 112 public void addClassMetaData(String tag, String attr, Object value) 113 { 114 classMetaData.addMetaData(tag, attr, value); 115 } 116 117 120 public void queueMethodMetaData(String methodExpr, String tag, String attr, Object value) 121 { 122 queuedMethodMetaData.add(new QueuedMethodMetaData(methodExpr, tag, attr, value)); 123 } 124 125 public ArrayList getQueuedMethodMetaData() 126 { 127 return queuedMethodMetaData; 128 } 129 130 133 public void queueFieldMetaData(String fieldExpr, String tag, String attr, Object value) 134 { 135 queuedFieldMetaData.add(new QueuedMetaData(fieldExpr, tag, attr, value)); 136 } 137 138 public ArrayList getQueuedFieldMetaData() 139 { 140 return queuedFieldMetaData; 141 } 142 143 146 public void queueConstructorMetaData(String constructorExpr, String tag, String attr, Object value) 147 { 148 queuedConstructorMetaData.add(new QueuedConstructorMetaData(constructorExpr, tag, attr, value)); 149 } 150 151 public ArrayList getQueuedConstructorMetaData() 152 { 153 return queuedConstructorMetaData; 154 } 155 156 public SimpleMetaData getDefaultMetaData() 157 { 158 return defaultMetaData; 159 } 160 161 public SimpleMetaData getClassMetaData() 162 { 163 return classMetaData; 164 } 165 166 } 167 | Popular Tags |