|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| JPatternsConfigBean.java | 100% | 100% | 100% | 100% |
|
||||||||||||||
| 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 | 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 | 107 | public JPatternsConfigBean() |
| 38 | { | |
| 39 | 107 | super(); |
| 40 | } | |
| 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 | 105 | public void setCastorConfig(final JPatternsConfig config) |
| 50 | { | |
| 51 | 105 | if (null == config) |
| 52 | { | |
| 53 | 1 | throw new IllegalArgumentException("The JPatternsConfig castor object with JPatterns configuration can not be null."); |
| 54 | } | |
| 55 | 104 | m_castorConfig = config; |
| 56 | 104 | if (null == m_castorConfig.getDefaultScope() || "".equals(m_castorConfig.getDefaultScope())) |
| 57 | { | |
| 58 | 43 | m_defaultScope = JPConstants.DEFAULT_SCOPE_NAME; |
| 59 | } | |
| 60 | else | |
| 61 | { | |
| 62 | 61 | m_defaultScope = m_castorConfig.getDefaultScope(); |
| 63 | } | |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * @return the castor object - root configuration storage | |
| 68 | */ | |
| 69 | 22 | public JPatternsConfig getCastorConfig() |
| 70 | { | |
| 71 | 22 | 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 | 103 | public void setDefaultScope(final String scope) |
| 81 | { | |
| 82 | 103 | if (null == scope || "".equals(scope)) |
| 83 | { | |
| 84 | 42 | m_defaultScope = JPConstants.DEFAULT_SCOPE_NAME; |
| 85 | } | |
| 86 | else | |
| 87 | { | |
| 88 | 61 | m_defaultScope = scope; |
| 89 | } | |
| 90 | } | |
| 91 | ||
| 92 | /** | |
| 93 | * @return the value of the default scope | |
| 94 | */ | |
| 95 | 13 | public String getDefaultScope() |
| 96 | { | |
| 97 | 13 | 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 | 1849 | public boolean check() |
| 107 | { | |
| 108 | 1849 | return (null != m_castorConfig && null != m_defaultScope && super.check()); |
| 109 | } | |
| 110 | } |
|
||||||||||