Clover coverage report - ATP library for Java - 3.6.4-stable-060214
Coverage timestamp: Вт фев 14 2006 13:45:22 MSK
file stats: LOC: 156   Methods: 9
NCLOC: 70   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BeanMapAttributed.java 8,3% 12,5% 22,2% 13,3%
coverage coverage
 1    /*
 2    * Copyright (c) 2001-2004,
 3    * RedVerst Group, ISP RAS http://www.ispras.ru
 4    * All rights reserved.
 5    *
 6    * Redistribution and use in source and binary forms, with or without
 7    * modification, are permitted provided that the following conditions are met:
 8    *
 9    * 1. Redistributions of source code must retain the above copyright notice, this
 10    * list of conditions and the following disclaimer.
 11    *
 12    * 2. Redistributions in binary form must reproduce the above copyright notice,
 13    * this list of conditions and the following disclaimer in the documentation
 14    * and/or other materials provided with the distribution.
 15    *
 16    * 3. The names "ATP", "TreeDL", "RedVerst", "ISP RAS"
 17    * may not be used to endorse or promote products derived from this software
 18    * without specific prior written permission.
 19    *
 20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 21    * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 22    * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 23    * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 24    * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 25    * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 26    * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 27    * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 29    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30    */
 31   
 32    package com.unitesk.atp.dynattrs;
 33   
 34    import java.util.HashSet;
 35    import java.util.Map;
 36    import java.util.Set;
 37   
 38    /**
 39    * The implementation of {@link Attributed} interface that accesses attributes
 40    * through <I>getter</I> and <I>setter</I> methods according to JavaBeans
 41    * naming conventions and stores additional attributes in {@link Map}.
 42    *
 43    * @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
 44    * @version $Id: BeanMapAttributed.java,v 1.1 2004/10/09 06:19:04 all-x Exp $
 45    */
 46    public class BeanMapAttributed extends MapAttributed
 47    {
 48    /**
 49    * Class constructor with {@link java.util.HashMap} as the default map.
 50    */
 51  4 public BeanMapAttributed()
 52    {
 53  4 super();
 54    }
 55   
 56    /**
 57    * Class constructor with the specified map.
 58    *
 59    * @param map The map to store attributes.
 60    */
 61  0 public BeanMapAttributed( Map map )
 62    {
 63  0 super( map );
 64    }
 65   
 66    /**
 67    * {@inheritDoc}
 68    */
 69  0 public boolean hasAttribute( String name )
 70    {
 71  0 return Accessor.hasBeanProperty( this, name )
 72    || super.hasAttribute( name );
 73    }
 74   
 75    /**
 76    * {@inheritDoc}
 77    */
 78  0 public boolean isRemovable( String name )
 79    {
 80  0 if( Accessor.hasBeanProperty( this, name ) )
 81    {
 82  0 return false;
 83    }
 84  0 return super.isRemovable( name );
 85    }
 86   
 87    /**
 88    * {@inheritDoc}
 89    */
 90  0 public boolean isWritable( String name )
 91    {
 92  0 if( Accessor.hasBeanProperty( this, name ) )
 93    {
 94  0 return Accessor.isBeanPropertyWritable( this, name );
 95    }
 96  0 return super.isWritable( name );
 97    }
 98   
 99    //------------------------------------------------------------------------------
 100   
 101    /**
 102    * {@inheritDoc}
 103    */
 104  0 public void removeAttribute( String name )
 105    {
 106  0 if( !hasAttribute( name ) ) return;
 107   
 108  0 if( !isRemovable( name ) )
 109    {
 110  0 throw new AttributeException( this, name );
 111    }
 112   
 113  0 super.removeAttribute( name );
 114    }
 115   
 116    //------------------------------------------------------------------------------
 117   
 118    /**
 119    * {@inheritDoc}
 120    */
 121  3 public Object getAttribute( String name )
 122    {
 123  3 if( Accessor.hasBeanProperty( this, name ) )
 124    {
 125  3 return Accessor.getBeanProperty( this, name );
 126    } else {
 127  0 return super.getAttribute( name );
 128    }
 129    }
 130   
 131    /**
 132    * {@inheritDoc}
 133    */
 134  0 public void setAttribute( String name, Object value )
 135    {
 136  0 if( Accessor.hasBeanProperty( this, name ) )
 137    {
 138  0 Accessor.setBeanProperty( this, name, value );
 139    } else {
 140  0 super.setAttribute( name, value );
 141    }
 142    }
 143   
 144    //------------------------------------------------------------------------------
 145   
 146    /**
 147    * {@inheritDoc}
 148    */
 149  0 public Set/*String*/ getAttributeNames()
 150    {
 151  0 Set/*String*/ s = new HashSet/*String*/();
 152  0 s.addAll( super.getAttributeNames() );
 153  0 s.addAll( Accessor.getBeanPropertyNames( this ) );
 154  0 return s;
 155    }
 156    }