KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aop > metadata > SimpleClassMetaDataBinding


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

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 JavaDoc;
28 import java.util.regex.Matcher JavaDoc;
29 import java.util.regex.Pattern JavaDoc;
30 /**
31  *
32  *
33  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
34  * @version $Revision: 37406 $
35  *
36  */

37 public class SimpleClassMetaDataBinding extends ClassMetaDataBinding
38 {
39    public class QueuedMetaData
40    {
41       protected Pattern JavaDoc expr;
42       public String JavaDoc tag;
43       public String JavaDoc attr;
44       public Object JavaDoc value;
45
46       public QueuedMetaData(String JavaDoc exp, String JavaDoc tag, String JavaDoc attr, Object JavaDoc 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 JavaDoc getExpr() { return this.expr.toString(); }
57       public boolean matches(String JavaDoc match)
58       {
59          Matcher JavaDoc m = expr.matcher(match);
60          return m.matches();
61       }
62    }
63
64    public class QueuedMethodMetaData
65    {
66       public MethodExpression expr;
67       public String JavaDoc tag;
68       public String JavaDoc attr;
69       public Object JavaDoc value;
70
71       public QueuedMethodMetaData(String JavaDoc expr, String JavaDoc tag, String JavaDoc attr, Object JavaDoc 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 JavaDoc tag;
84       public String JavaDoc attr;
85       public Object JavaDoc value;
86
87       public QueuedConstructorMetaData(String JavaDoc expr, String JavaDoc tag, String JavaDoc attr, Object JavaDoc 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 JavaDoc queuedMethodMetaData = new ArrayList JavaDoc();
99    protected ArrayList JavaDoc queuedFieldMetaData = new ArrayList JavaDoc();
100    protected ArrayList JavaDoc queuedConstructorMetaData = new ArrayList JavaDoc();
101
102    public SimpleClassMetaDataBinding(ClassMetaDataLoader loader, String JavaDoc name, String JavaDoc tag, String JavaDoc expr)
103    {
104       super(loader, name, tag, expr);
105    }
106
107    public void addDefaultMetaData(String JavaDoc tag, String JavaDoc attr, Object JavaDoc value)
108    {
109       defaultMetaData.addMetaData(tag, attr, value);
110    }
111
112    public void addClassMetaData(String JavaDoc tag, String JavaDoc attr, Object JavaDoc value)
113    {
114       classMetaData.addMetaData(tag, attr, value);
115    }
116
117    /**
118     * Queues up binding for method meta data
119     */

120    public void queueMethodMetaData(String JavaDoc methodExpr, String JavaDoc tag, String JavaDoc attr, Object JavaDoc value)
121    {
122       queuedMethodMetaData.add(new QueuedMethodMetaData(methodExpr, tag, attr, value));
123    }
124
125    public ArrayList JavaDoc getQueuedMethodMetaData()
126    {
127       return queuedMethodMetaData;
128    }
129
130    /**
131     * Queues up binding for method meta data
132     */

133    public void queueFieldMetaData(String JavaDoc fieldExpr, String JavaDoc tag, String JavaDoc attr, Object JavaDoc value)
134    {
135       queuedFieldMetaData.add(new QueuedMetaData(fieldExpr, tag, attr, value));
136    }
137
138    public ArrayList JavaDoc getQueuedFieldMetaData()
139    {
140       return queuedFieldMetaData;
141    }
142
143    /**
144     * Queues up binding for method meta data
145     */

146    public void queueConstructorMetaData(String JavaDoc constructorExpr, String JavaDoc tag, String JavaDoc attr, Object JavaDoc value)
147    {
148       queuedConstructorMetaData.add(new QueuedConstructorMetaData(constructorExpr, tag, attr, value));
149    }
150
151    public ArrayList JavaDoc 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