KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > definition > InterfaceIntroductionDefinition


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.aspectwerkz.definition;
5
6
7 import com.tc.aspectwerkz.expression.ExpressionInfo;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.List JavaDoc;
11
12 /**
13  * Holds the meta-data for the interface introductions. <p/>This definition holds only pure interface introduction.
14  *
15  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
16  * @author <a HREF="mailto:alex@gnilux.com">Alexandre Vasseur </a>
17  */

18 public class InterfaceIntroductionDefinition {
19   /**
20    * The name of the interface introduction.
21    */

22   protected final String JavaDoc m_name;
23
24   /**
25    * The introduction expressions.
26    */

27   protected ExpressionInfo[] m_expressionInfos = new ExpressionInfo[]{};
28
29   /**
30    * The attribute for the introduction.
31    */

32   protected String JavaDoc m_attribute = "";
33
34   /**
35    * The interface classes name.
36    */

37   protected List JavaDoc m_interfaceClassNames = new ArrayList JavaDoc();
38
39   /**
40    * Creates a new introduction meta-data instance.
41    *
42    * @param name the name of the expressionInfo
43    * @param interfaceClassName the class name of the interface
44    */

45   public InterfaceIntroductionDefinition(final String JavaDoc name, final String JavaDoc interfaceClassName) {
46     if (name == null) {
47       throw new IllegalArgumentException JavaDoc("name can not be null");
48     }
49     if (interfaceClassName == null) {
50       throw new IllegalArgumentException JavaDoc("interface class name can not be null");
51     }
52     m_name = name;
53     m_interfaceClassNames.add(interfaceClassName);
54   }
55
56   /**
57    * Returns the name of the introduction.
58    *
59    * @return the name
60    */

61   public String JavaDoc getName() {
62     return m_name;
63   }
64
65   /**
66    * Returns the expressions.
67    *
68    * @return the expressions array
69    */

70   public ExpressionInfo[] getExpressionInfos() {
71     return m_expressionInfos;
72   }
73
74   /**
75    * Returns the class name of the interface.
76    *
77    * @return the class name of the interface
78    */

79   public String JavaDoc getInterfaceClassName() {
80     return (String JavaDoc) m_interfaceClassNames.get(0);
81   }
82
83   /**
84    * Returns the class name of the interface.
85    *
86    * @return the class name of the interface
87    */

88   public List JavaDoc getInterfaceClassNames() {
89     return m_interfaceClassNames;
90   }
91
92   /**
93    * Returns the attribute.
94    *
95    * @return the attribute
96    */

97   public String JavaDoc getAttribute() {
98     return m_attribute;
99   }
100
101   /**
102    * Sets the attribute.
103    *
104    * @param attribute the attribute
105    */

106   public void setAttribute(final String JavaDoc attribute) {
107     m_attribute = attribute;
108   }
109
110   /**
111    * Adds a new expression info.
112    *
113    * @param expression a new expression info
114    */

115   public void addExpressionInfo(final ExpressionInfo expression) {
116     final ExpressionInfo[] tmpExpressions = new ExpressionInfo[m_expressionInfos.length + 1];
117     java.lang.System.arraycopy(m_expressionInfos, 0, tmpExpressions, 0, m_expressionInfos.length);
118     tmpExpressions[m_expressionInfos.length] = expression;
119     m_expressionInfos = new ExpressionInfo[m_expressionInfos.length + 1];
120     java.lang.System.arraycopy(tmpExpressions, 0, m_expressionInfos, 0, tmpExpressions.length);
121   }
122
123   /**
124    * Adds an array with new expression infos.
125    *
126    * @param expressions an array with new expression infos
127    */

128   public void addExpressionInfos(final ExpressionInfo[] expressions) {
129     final ExpressionInfo[] tmpExpressions = new ExpressionInfo[m_expressionInfos.length + expressions.length];
130     java.lang.System.arraycopy(m_expressionInfos, 0, tmpExpressions, 0, m_expressionInfos.length);
131     java.lang.System.arraycopy(expressions, 0, tmpExpressions, m_expressionInfos.length, expressions.length);
132     m_expressionInfos = new ExpressionInfo[m_expressionInfos.length + expressions.length];
133     java.lang.System.arraycopy(tmpExpressions, 0, m_expressionInfos, 0, tmpExpressions.length);
134   }
135 }
Popular Tags