Coverage Report - com.sourceforge.jpatterns.core.configuration.model.JPatternsConfigBean
 
Classes in this File Line Coverage Branch Coverage Complexity
JPatternsConfigBean
100% 
100% 
1,667
 
 1  
 package com.sourceforge.jpatterns.core.configuration.model;
 2  
 
 3  
 import com.sourceforge.jpatterns.core.JPConstants;
 4  
 import com.sourceforge.jpatterns.schema.JPatternsConfig;
 5  
 import org.apache.log4j.Logger;
 6  
 
 7  
 /**
 8  
  * This bean represents the <code>JPatternsConfig</code>, it contains this castor object by itself and also several additional data
 9  
  * storages - representations of the <code>JPatternsConfig</code> from the point of view of logical sections <code>CastorSectionType</code>,
 10  
  * and the business items <code>CastorNameScopePriorityType</code>.<br/>
 11  
  *
 12  
  * $Author:: zmicer             $<br/>
 13  
  * $Rev:: 57                    $<br/> * $Date:: 2007-08-23 09:16:37 #$<br/>
 14  
  * $Date:: 2007-08-23 09:16:37 #$<br/>
 15  
  */
 16  
 public class JPatternsConfigBean extends JPatternsConfigBaseBean
 17  
 {
 18  
     /**
 19  
      * Logger instance.
 20  
      */
 21  5
     final public static Logger LOG = Logger.getLogger(JPatternsConfigBean.class);
 22  
 
 23  
     /**
 24  
      * This member stores the JPatternsConfig by itself, without any modifications
 25  
      */
 26  
     private JPatternsConfig m_castorConfig;
 27  
 
 28  
     /**
 29  
      * The default scope ID of the root castor object, is introduced as the separate member for the facility to operate with the JPatterns
 30  
      * configuration
 31  
      */
 32  
     private String m_defaultScope;
 33  
 
 34  
     /**
 35  
      * Default public constructor.
 36  
      */
 37  
     public JPatternsConfigBean()
 38  
     {
 39  519
         super();
 40  519
     }
 41  
 
 42  
     /**
 43  
      * Set the new value to the class member storing the native castor configuration. This method also changes the value of the
 44  
      * default scope to the one defined at the provided <code>JPatternsConfig</code>.
 45  
      *
 46  
      * @param config JPatternsConfig new value of the castor object to be set.
 47  
      *               Can not be null (otherwise <code>IllegalArgumentException</code> would appear).
 48  
      */
 49  
     public void setCastorConfig(final JPatternsConfig config)
 50  
     {
 51  509
         if (null == config)
 52  
         {
 53  5
             throw new IllegalArgumentException("The JPatternsConfig castor object with JPatterns configuration can not be null.");
 54  
         }
 55  504
         m_castorConfig = config;
 56  504
         if (null == m_castorConfig.getDefaultScope() || "".equals(m_castorConfig.getDefaultScope()))
 57  
         {
 58  199
             m_defaultScope = JPConstants.DEFAULT_SCOPE_NAME;
 59  199
         }
 60  
         else
 61  
         {
 62  305
             m_defaultScope = m_castorConfig.getDefaultScope();
 63  
         }
 64  504
     }
 65  
 
 66  
     /**
 67  
      * @return the castor object - root configuration storage
 68  
      */
 69  
     public JPatternsConfig getCastorConfig()
 70  
     {
 71  110
         return m_castorConfig;
 72  
     }
 73  
 
 74  
     /**
 75  
      * Set the new value for the default scope. In the case it is null/empty -
 76  
      * <code>com.sourceforge.jpatterns.core.JPConstants.DEFAULT_SCOPE_NAME</code> would be set.
 77  
      *
 78  
      * @param scope the new value for the scope varible. Could take any values
 79  
      */
 80  
     public void setDefaultScope(final String scope)
 81  
     {
 82  499
         if (null == scope || "".equals(scope))
 83  
         {
 84  194
             m_defaultScope = JPConstants.DEFAULT_SCOPE_NAME;
 85  194
         }
 86  
         else
 87  
         {
 88  305
             m_defaultScope = scope;
 89  
         }
 90  499
     }
 91  
 
 92  
     /**
 93  
      * @return the value of the default scope
 94  
      */
 95  
     public String getDefaultScope()
 96  
     {
 97  65
         return m_defaultScope;
 98  
     }
 99  
 
 100  
     /**
 101  
      * Perform the check of the composition of the <code>JPatternsConfigBean</code> object. We would just check all the members of the
 102  
      * bean are set.
 103  
      *
 104  
      * @return <code>true</code> if all is ok with the composition of the bean, <code>false</code> otherwise.
 105  
      */
 106  
     public boolean check()
 107  
     {
 108  9149
         return (null != m_castorConfig && null != m_defaultScope && super.check());
 109  
     }
 110  
 }