001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.aspectwerkz.definition;
005:
006: import com.tc.aspectwerkz.expression.ExpressionInfo;
007:
008: import java.util.ArrayList;
009: import java.util.List;
010:
011: /**
012: * Holds the meta-data for the interface introductions. <p/>This definition holds only pure interface introduction.
013: *
014: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
015: * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
016: */
017: public class InterfaceIntroductionDefinition {
018: /**
019: * The name of the interface introduction.
020: */
021: protected final String m_name;
022:
023: /**
024: * The introduction expressions.
025: */
026: protected ExpressionInfo[] m_expressionInfos = new ExpressionInfo[] {};
027:
028: /**
029: * The attribute for the introduction.
030: */
031: protected String m_attribute = "";
032:
033: /**
034: * The interface classes name.
035: */
036: protected List m_interfaceClassNames = new ArrayList();
037:
038: /**
039: * Creates a new introduction meta-data instance.
040: *
041: * @param name the name of the expressionInfo
042: * @param interfaceClassName the class name of the interface
043: */
044: public InterfaceIntroductionDefinition(final String name,
045: final String interfaceClassName) {
046: if (name == null) {
047: throw new IllegalArgumentException("name can not be null");
048: }
049: if (interfaceClassName == null) {
050: throw new IllegalArgumentException(
051: "interface class name can not be null");
052: }
053: m_name = name;
054: m_interfaceClassNames.add(interfaceClassName);
055: }
056:
057: /**
058: * Returns the name of the introduction.
059: *
060: * @return the name
061: */
062: public String getName() {
063: return m_name;
064: }
065:
066: /**
067: * Returns the expressions.
068: *
069: * @return the expressions array
070: */
071: public ExpressionInfo[] getExpressionInfos() {
072: return m_expressionInfos;
073: }
074:
075: /**
076: * Returns the class name of the interface.
077: *
078: * @return the class name of the interface
079: */
080: public String getInterfaceClassName() {
081: return (String) m_interfaceClassNames.get(0);
082: }
083:
084: /**
085: * Returns the class name of the interface.
086: *
087: * @return the class name of the interface
088: */
089: public List getInterfaceClassNames() {
090: return m_interfaceClassNames;
091: }
092:
093: /**
094: * Returns the attribute.
095: *
096: * @return the attribute
097: */
098: public String getAttribute() {
099: return m_attribute;
100: }
101:
102: /**
103: * Sets the attribute.
104: *
105: * @param attribute the attribute
106: */
107: public void setAttribute(final String attribute) {
108: m_attribute = attribute;
109: }
110:
111: /**
112: * Adds a new expression info.
113: *
114: * @param expression a new expression info
115: */
116: public void addExpressionInfo(final ExpressionInfo expression) {
117: final ExpressionInfo[] tmpExpressions = new ExpressionInfo[m_expressionInfos.length + 1];
118: java.lang.System.arraycopy(m_expressionInfos, 0,
119: tmpExpressions, 0, m_expressionInfos.length);
120: tmpExpressions[m_expressionInfos.length] = expression;
121: m_expressionInfos = new ExpressionInfo[m_expressionInfos.length + 1];
122: java.lang.System.arraycopy(tmpExpressions, 0,
123: m_expressionInfos, 0, tmpExpressions.length);
124: }
125:
126: /**
127: * Adds an array with new expression infos.
128: *
129: * @param expressions an array with new expression infos
130: */
131: public void addExpressionInfos(final ExpressionInfo[] expressions) {
132: final ExpressionInfo[] tmpExpressions = new ExpressionInfo[m_expressionInfos.length
133: + expressions.length];
134: java.lang.System.arraycopy(m_expressionInfos, 0,
135: tmpExpressions, 0, m_expressionInfos.length);
136: java.lang.System.arraycopy(expressions, 0, tmpExpressions,
137: m_expressionInfos.length, expressions.length);
138: m_expressionInfos = new ExpressionInfo[m_expressionInfos.length
139: + expressions.length];
140: java.lang.System.arraycopy(tmpExpressions, 0,
141: m_expressionInfos, 0, tmpExpressions.length);
142: }
143: }
|