|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AbstractHomer.java | 50% | 64.7% | 50% | 60% |
|
||||||||||||||
| 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.Bart;
|
|
| 29 |
import org.jicarilla.container.tck.components.interfaces.Homer;
|
|
| 30 |
import org.jicarilla.container.tck.components.interfaces.HotdogBuyer;
|
|
| 31 |
import org.jicarilla.container.tck.components.interfaces.InvalidChildException;
|
|
| 32 |
import org.jicarilla.container.tck.components.interfaces.Lisa;
|
|
| 33 |
import org.jicarilla.container.tck.components.interfaces.Maggie;
|
|
| 34 |
import org.jicarilla.container.tck.components.interfaces.Marge;
|
|
| 35 |
import org.jicarilla.framework.CascadingRuntimeException;
|
|
| 36 |
|
|
| 37 |
import java.lang.reflect.Method;
|
|
| 38 |
import java.util.List;
|
|
| 39 |
|
|
| 40 |
/**
|
|
| 41 |
*
|
|
| 42 |
*
|
|
| 43 |
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
|
|
| 44 |
* @version $Id: AbstractHomer.java,v 1.4 2004/01/14 23:00:25 lsimons Exp $
|
|
| 45 |
*/
|
|
| 46 |
public abstract class AbstractHomer |
|
| 47 |
extends AbstractComponent
|
|
| 48 |
implements Homer, HotdogBuyer
|
|
| 49 |
{
|
|
| 50 |
// ----------------------------------------------------------------------
|
|
| 51 |
// Properties
|
|
| 52 |
// ----------------------------------------------------------------------
|
|
| 53 |
protected Marge m_marge;
|
|
| 54 |
protected List m_children;
|
|
| 55 |
protected List m_hotdogs;
|
|
| 56 |
|
|
| 57 |
// ----------------------------------------------------------------------
|
|
| 58 |
// Poor-Man's Invocation Logging
|
|
| 59 |
// ----------------------------------------------------------------------
|
|
| 60 |
public final static Method setMarge; |
|
| 61 |
public final static Method buyHotdog; |
|
| 62 |
public final static Method burp; |
|
| 63 |
public final static Method addChild; |
|
| 64 |
static
|
|
| 65 |
{
|
|
| 66 | 16 |
try
|
| 67 |
{
|
|
| 68 | 16 |
setMarge = AbstractHomer.class
|
| 69 |
.getDeclaredMethod( "setMarge", new Class[] { Marge.class } ); |
|
| 70 | 16 |
buyHotdog = AbstractHomer.class
|
| 71 |
.getMethod( "buyHotdog", new Class[] { Object.class } ); |
|
| 72 | 16 |
burp = AbstractHomer.class
|
| 73 |
.getMethod( "burp", new Class[0] ); |
|
| 74 | 16 |
addChild = AbstractHomer.class
|
| 75 |
.getMethod( "addChild", new Class[] { Object.class } ); |
|
| 76 |
} |
|
| 77 |
catch( NoSuchMethodException e )
|
|
| 78 |
{
|
|
| 79 | 0 |
throw new CascadingRuntimeException( e.getMessage(), e ); |
| 80 |
} |
|
| 81 |
} |
|
| 82 |
|
|
| 83 |
// ----------------------------------------------------------------------
|
|
| 84 |
// Methods
|
|
| 85 |
// ----------------------------------------------------------------------
|
|
| 86 |
|
|
| 87 | 0 |
public void buyHotdog( Object hotdog ) |
| 88 |
{
|
|
| 89 | 0 |
super.log( buyHotdog, hotdog );
|
| 90 | 0 |
m_hotdogs.add( hotdog ); |
| 91 |
} |
|
| 92 |
|
|
| 93 | 103 |
public void addChild( Object child ) throws InvalidChildException |
| 94 |
{
|
|
| 95 | 103 |
super.log( addChild, child );
|
| 96 | 103 |
if( !(child instanceof Bart || child instanceof Lisa || child instanceof Maggie )) |
| 97 | 0 |
throw new InvalidChildException(); |
| 98 |
|
|
| 99 | 103 |
m_children.add( child ); |
| 100 |
} |
|
| 101 |
|
|
| 102 | 12 |
public void burp() |
| 103 |
{
|
|
| 104 | 12 |
super.log( burp );
|
| 105 |
} |
|
| 106 |
|
|
| 107 |
// ----------------------------------------------------------------------
|
|
| 108 |
// Getters / Setters
|
|
| 109 |
// ----------------------------------------------------------------------
|
|
| 110 |
|
|
| 111 | 0 |
protected List getHotdogs()
|
| 112 |
{
|
|
| 113 | 0 |
return m_hotdogs;
|
| 114 |
} |
|
| 115 |
|
|
| 116 | 62 |
protected void setMarge( Marge marge ) |
| 117 |
{
|
|
| 118 | 62 |
super.log( setMarge, marge );
|
| 119 | 62 |
m_marge = marge; |
| 120 |
} |
|
| 121 |
|
|
| 122 | 0 |
protected Marge getMarge()
|
| 123 |
{
|
|
| 124 | 0 |
return m_marge;
|
| 125 |
} |
|
| 126 |
} |
|
| 127 |
|
|
||||||||||