|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AbstractLisa.java | 50% | 75% | 60% | 69% |
|
||||||||||||||
| 1 |
/* ====================================================================
|
|
| 2 |
The Jicarilla Software License
|
|
| 3 |
|
|
| 4 |
Copyright (c) 2003 Leo Simons.
|
|
| 5 |
All rights reserved.
|
|
| 6 |
|
|
| 7 |
Permission is hereby granted, free of charge, to any person obtaining
|
|
| 8 |
a copy of this software and associated documentation files (the
|
|
| 9 |
"Software"), to deal in the Software without restriction, including
|
|
| 10 |
without limitation the rights to use, copy, modify, merge, publish,
|
|
| 11 |
distribute, sublicense, and/or sell copies of the Software, and to
|
|
| 12 |
permit persons to whom the Software is furnished to do so, subject to
|
|
| 13 |
the following conditions:
|
|
| 14 |
|
|
| 15 |
The above copyright notice and this permission notice shall be
|
|
| 16 |
included in all copies or substantial portions of the Software.
|
|
| 17 |
|
|
| 18 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
| 19 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
| 20 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
| 21 |
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
| 22 |
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
| 23 |
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
| 24 |
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
| 25 |
==================================================================== */
|
|
| 26 |
package org.jicarilla.container.tck.components;
|
|
| 27 |
|
|
| 28 |
import org.jicarilla.container.tck.components.interfaces.Homer;
|
|
| 29 |
import org.jicarilla.container.tck.components.interfaces.InvalidChildException;
|
|
| 30 |
import org.jicarilla.container.tck.components.interfaces.Lisa;
|
|
| 31 |
import org.jicarilla.container.tck.components.interfaces.Marge;
|
|
| 32 |
import org.jicarilla.framework.CascadingRuntimeException;
|
|
| 33 |
|
|
| 34 |
import java.lang.reflect.Method;
|
|
| 35 |
|
|
| 36 |
/**
|
|
| 37 |
*
|
|
| 38 |
*
|
|
| 39 |
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
|
|
| 40 |
* @version $Id: AbstractLisa.java,v 1.4 2004/01/14 23:00:25 lsimons Exp $
|
|
| 41 |
*/
|
|
| 42 |
public abstract class AbstractLisa |
|
| 43 |
extends AbstractComponent
|
|
| 44 |
implements Lisa
|
|
| 45 |
{
|
|
| 46 |
private Homer m_homer;
|
|
| 47 |
private Marge m_marge;
|
|
| 48 |
|
|
| 49 |
// ----------------------------------------------------------------------
|
|
| 50 |
// Poor-Man's Invocation Logging
|
|
| 51 |
// ----------------------------------------------------------------------
|
|
| 52 |
public final static Method setHomer; |
|
| 53 |
public final static Method setMarge; |
|
| 54 |
public final static Method actSmart; |
|
| 55 |
static
|
|
| 56 |
{
|
|
| 57 | 12 |
try
|
| 58 |
{
|
|
| 59 | 12 |
setHomer = AbstractLisa.class
|
| 60 |
.getDeclaredMethod( "setHomer", new Class[] { Homer.class } ); |
|
| 61 | 12 |
setMarge = AbstractLisa.class
|
| 62 |
.getDeclaredMethod( "setMarge", new Class[] { Marge.class } ); |
|
| 63 | 12 |
actSmart = AbstractLisa.class
|
| 64 |
.getMethod( "actSmart", new Class[0] ); |
|
| 65 |
} |
|
| 66 |
catch( NoSuchMethodException e )
|
|
| 67 |
{
|
|
| 68 | 0 |
throw new CascadingRuntimeException( e.getMessage(), e ); |
| 69 |
} |
|
| 70 |
} |
|
| 71 |
|
|
| 72 | 12 |
public void actSmart() |
| 73 |
{
|
|
| 74 | 12 |
super.log( actSmart );
|
| 75 |
} |
|
| 76 |
|
|
| 77 | 0 |
protected Homer getHomer()
|
| 78 |
{
|
|
| 79 | 0 |
return m_homer;
|
| 80 |
} |
|
| 81 |
|
|
| 82 | 42 |
protected void setHomer( Homer homer ) |
| 83 |
{
|
|
| 84 | 42 |
super.log( setHomer, homer );
|
| 85 | 42 |
m_homer = homer; |
| 86 |
|
|
| 87 | 42 |
if( m_homer != null ) |
| 88 |
{
|
|
| 89 | 42 |
try // conveniently break IoC :D |
| 90 |
{
|
|
| 91 | 42 |
m_homer.addChild( this );
|
| 92 |
} |
|
| 93 |
catch( InvalidChildException ice )
|
|
| 94 |
{
|
|
| 95 | 0 |
throw new IllegalArgumentException( "Homer does not accept me as a child!" ); |
| 96 |
} |
|
| 97 |
} |
|
| 98 |
} |
|
| 99 |
|
|
| 100 | 0 |
protected Marge getMarge()
|
| 101 |
{
|
|
| 102 | 0 |
return m_marge;
|
| 103 |
} |
|
| 104 |
|
|
| 105 | 42 |
protected void setMarge( Marge marge ) |
| 106 |
{
|
|
| 107 | 42 |
super.log( setMarge, marge );
|
| 108 | 42 |
m_marge = marge; |
| 109 |
|
|
| 110 | 42 |
if( m_marge != null ) |
| 111 |
{
|
|
| 112 | 42 |
try // conveniently break IoC :D |
| 113 |
{
|
|
| 114 | 42 |
m_marge.addChild( this );
|
| 115 |
} |
|
| 116 |
catch( InvalidChildException ice )
|
|
| 117 |
{
|
|
| 118 | 0 |
throw new IllegalArgumentException( "Marge does not accept me as a child!" ); |
| 119 |
} |
|
| 120 |
} |
|
| 121 |
} |
|
| 122 |
} |
|
| 123 |
|
|
||||||||||