1 /*************************************************************************************** 2 * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. * 3 * http://aspectwerkz.codehaus.org * 4 * ---------------------------------------------------------------------------------- * 5 * The software in this package is published under the terms of the LGPL license * 6 * a copy of which has been included with this distribution in the license.txt file. * 7 **************************************************************************************/ 8 package org.codehaus.aspectwerkz.definition; 9 10 import org.codehaus.aspectwerkz.expression.ExpressionInfo; 11 12 import java.util.ArrayList; 13 import java.util.List; 14 15 /*** 16 * Holds the meta-data for the interface introductions. <p/>This definition holds only pure interface introduction. 17 * 18 * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a> 19 * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a> 20 */ 21 public class InterfaceIntroductionDefinition { 22 /*** 23 * The name of the interface introduction. 24 */ 25 protected final String m_name; 26 27 /*** 28 * The introduction expressions. 29 */ 30 protected ExpressionInfo[] m_expressionInfos = new ExpressionInfo[]{}; 31 32 /*** 33 * The attribute for the introduction. 34 */ 35 protected String m_attribute = ""; 36 37 /*** 38 * The interface classes name. 39 */ 40 protected List m_interfaceClassNames = new ArrayList(); 41 42 /*** 43 * Creates a new introduction meta-data instance. 44 * 45 * @param name the name of the expressionInfo 46 * @param interfaceClassName the class name of the interface 47 */ 48 public InterfaceIntroductionDefinition(final String name, final String interfaceClassName) { 49 if (name == null) { 50 throw new IllegalArgumentException("name can not be null"); 51 } 52 if (interfaceClassName == null) { 53 throw new IllegalArgumentException("interface class name can not be null"); 54 } 55 m_name = name; 56 m_interfaceClassNames.add(interfaceClassName); 57 } 58 59 /*** 60 * Returns the name of the introduction. 61 * 62 * @return the name 63 */ 64 public String getName() { 65 return m_name; 66 } 67 68 /*** 69 * Returns the expressions. 70 * 71 * @return the expressions array 72 */ 73 public ExpressionInfo[] getExpressionInfos() { 74 return m_expressionInfos; 75 } 76 77 /*** 78 * Returns the class name of the interface. 79 * 80 * @return the class name of the interface 81 */ 82 public String getInterfaceClassName() { 83 return (String) m_interfaceClassNames.get(0); 84 } 85 86 /*** 87 * Returns the class name of the interface. 88 * 89 * @return the class name of the interface 90 */ 91 public List getInterfaceClassNames() { 92 return m_interfaceClassNames; 93 } 94 95 /*** 96 * Returns the attribute. 97 * 98 * @return the attribute 99 */ 100 public String getAttribute() { 101 return m_attribute; 102 } 103 104 /*** 105 * Sets the attribute. 106 * 107 * @param attribute the attribute 108 */ 109 public void setAttribute(final String attribute) { 110 m_attribute = attribute; 111 } 112 113 /*** 114 * Adds a new expression info. 115 * 116 * @param expression a new expression info 117 */ 118 public void addExpressionInfo(final ExpressionInfo expression) { 119 final ExpressionInfo[] tmpExpressions = new ExpressionInfo[m_expressionInfos.length + 1]; 120 java.lang.System.arraycopy(m_expressionInfos, 0, tmpExpressions, 0, m_expressionInfos.length); 121 tmpExpressions[m_expressionInfos.length] = expression; 122 m_expressionInfos = new ExpressionInfo[m_expressionInfos.length + 1]; 123 java.lang.System.arraycopy(tmpExpressions, 0, 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 + expressions.length]; 133 java.lang.System.arraycopy(m_expressionInfos, 0, tmpExpressions, 0, m_expressionInfos.length); 134 java.lang.System.arraycopy(expressions, 0, tmpExpressions, m_expressionInfos.length, expressions.length); 135 m_expressionInfos = new ExpressionInfo[m_expressionInfos.length + expressions.length]; 136 java.lang.System.arraycopy(tmpExpressions, 0, m_expressionInfos, 0, tmpExpressions.length); 137 } 138 }