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