|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| BeanDescriptor.java | 50% | 85.7% | 100% | 87% |
|
||||||||||||||
| 1 | /** | |
| 2 | * EasyBeans | |
| 3 | * Copyright (C) 2006 Bull S.A.S. | |
| 4 | * Contact: easybeans@objectweb.org | |
| 5 | * | |
| 6 | * This library is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU Lesser General Public | |
| 8 | * License as published by the Free Software Foundation; either | |
| 9 | * version 2.1 of the License, or any later version. | |
| 10 | * | |
| 11 | * This library is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | * Lesser General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU Lesser General Public | |
| 17 | * License along with this library; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
| 19 | * USA | |
| 20 | * | |
| 21 | * -------------------------------------------------------------------------- | |
| 22 | * $Id: BeanDescriptor.java 288 2006-03-29 13:06:58Z studzine $ | |
| 23 | * -------------------------------------------------------------------------- | |
| 24 | */ | |
| 25 | package org.objectweb.easybeans.tests.common.interceptors.invocationcontext; | |
| 26 | ||
| 27 | import java.io.Serializable; | |
| 28 | ||
| 29 | /** | |
| 30 | * This class is used to store a bean reference and an intercepted method. | |
| 31 | * @author Eduardo Studzinski Estima de Castro | |
| 32 | * @author Gisele Pinheiro Souza | |
| 33 | */ | |
| 34 | public class BeanDescriptor implements Serializable { | |
| 35 | ||
| 36 | /** | |
| 37 | * Serial ID. | |
| 38 | */ | |
| 39 | private static final long serialVersionUID = -1807144244407143163L; | |
| 40 | ||
| 41 | /** | |
| 42 | * Referenced bean. | |
| 43 | */ | |
| 44 | private int intHashCode; | |
| 45 | ||
| 46 | /** | |
| 47 | * Intercepted method. | |
| 48 | */ | |
| 49 | private String mtIntercepted; | |
| 50 | ||
| 51 | /** | |
| 52 | * Default constructor. | |
| 53 | */ | |
| 54 | 10 | public BeanDescriptor() { |
| 55 | 10 | setHashCode(0); |
| 56 | 10 | setInterceptedMethod(""); |
| 57 | } | |
| 58 | ||
| 59 | /** | |
| 60 | * Default args-constructor. | |
| 61 | * @param hashCode the bean hash code. | |
| 62 | * @param methodSignature intercepted method signature. | |
| 63 | */ | |
| 64 | 8 | public BeanDescriptor(final int hashCode, final String methodSignature) { |
| 65 | 8 | setHashCode(hashCode); |
| 66 | 8 | setInterceptedMethod(methodSignature); |
| 67 | } | |
| 68 | ||
| 69 | /** | |
| 70 | * Gets the bean hash code. | |
| 71 | * @return Returns the bean hash code. | |
| 72 | */ | |
| 73 | 8 | public int getHashCode() { |
| 74 | 8 | return intHashCode; |
| 75 | } | |
| 76 | ||
| 77 | /** | |
| 78 | * Sets the bean hash code. | |
| 79 | * @param hashCode The bean hash code to set. | |
| 80 | */ | |
| 81 | 20 | public void setHashCode(final int hashCode) { |
| 82 | 20 | this.intHashCode = hashCode; |
| 83 | } | |
| 84 | ||
| 85 | /** | |
| 86 | * Gets the intercepted method. | |
| 87 | * @return Returns the intercepted method. | |
| 88 | */ | |
| 89 | 6 | public String getInterceptedMethod() { |
| 90 | 6 | return mtIntercepted; |
| 91 | } | |
| 92 | ||
| 93 | /** | |
| 94 | * Sets the intercepted method. | |
| 95 | * @param m The intercepted method to set. | |
| 96 | */ | |
| 97 | 20 | public void setInterceptedMethod(final String m) { |
| 98 | 20 | this.mtIntercepted = m; |
| 99 | ||
| 100 | } | |
| 101 | ||
| 102 | /** | |
| 103 | * Indicates whether some other object is "equal to" this one. | |
| 104 | * @param obj object to compare. | |
| 105 | * @return true, if equals. | |
| 106 | * @throws if a problem occurs. | |
| 107 | */ | |
| 108 | 2 | public boolean equalsWithException(final Object obj) throws Exception { |
| 109 | 2 | boolean bResult = false; |
| 110 | ||
| 111 | 2 | BeanDescriptor refExt = (BeanDescriptor) obj; |
| 112 | ||
| 113 | 2 | if (refExt.getHashCode() == intHashCode){ |
| 114 | 0 | bResult = true; |
| 115 | }else{ | |
| 116 | 2 | throw new Exception("The bean hashcodes aren't equal."); |
| 117 | } | |
| 118 | ||
| 119 | 0 | return bResult; |
| 120 | } | |
| 121 | } |
|
||||||||||