Project Report: fawkez

Packagesummary org.jcoderz.commons.config

org.jcoderz.commons.config.ConfigurationServiceCommonImpl

LineHitsNoteSource
1  /*
2   * $Id: ConfigurationServiceCommonImpl.java 1011 2008-06-16 17:57:36Z amandel $
3   *
4   * Copyright 2006, The jCoderZ.org Project. 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
8   * met:
9   *
10   *    * Redistributions of source code must retain the above copyright
11   *      notice, this list of conditions and the following disclaimer.
12   *    * Redistributions in binary form must reproduce the above
13   *      copyright notice, this list of conditions and the following
14   *      disclaimer in the documentation and/or other materials
15   *      provided with the distribution.
16   *    * Neither the name of the jCoderZ.org Project nor the names of
17   *      its contributors may be used to endorse or promote products
18   *      derived from this software without specific prior written
19   *      permission.
20   *
21   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24   * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32   */
33  package org.jcoderz.commons.config;
34  
35  import java.util.logging.Logger;
36  
37  import org.jcoderz.commons.ArgumentMalformedException;
38  import org.jcoderz.commons.util.Assert;
39  import org.jcoderz.commons.util.Constants;
40  
41  
42  /**
43   * Implementation of the common ConfigurationService business methods.
44   *
45   * This class holds all business logic of the service.
46   * Implementing the business interface ConfigurationServiceCommonInterface.
47   *
48   */
490(1)public class ConfigurationServiceCommonImpl
50        implements ConfigurationServiceCommonInterface
51  {
52     /** class name for use in logging. */
530    private static final String CLASSNAME
54             = ConfigurationServiceCommonImpl.class.getName();
55  
56     /** class logger. */
570    private static final Logger logger = Logger.getLogger(CLASSNAME);
58  
59     /**
60      * Name of a parameter in a few get.. methods.
61      * This member exists only for checkstyles's sake.
62      */
63     private static final transient
64        String PARAM_KEY_OF_GET_METHODS = "key";
65  
66  
67 (2)   /**
68      * {@inheritDoc}
69 (3)    * FIXME: activate ejb tag if XDoclet BugFix is available
70      * @XXXejb.interface-method view-type="remote"
71      * @XXXejb.transaction type="Required"
72      */
73 (4)(5)   public boolean getBoolean (ConfigurationKey key)
74           throws ConfigurationValueNotFoundException,
75                 ConfigurationTypeConversionFailedException,
76                 ArgumentMalformedException
77     {
780       Assert.notNull(key, PARAM_KEY_OF_GET_METHODS);
79        boolean bReturn;
80  
810       final String valueAsString = getString(key);
820       final Boolean value = Boolean.valueOf(valueAsString);
830       if (value.booleanValue())
84        {
850          bReturn = true;
86        }
870(6)      else if (valueAsString.toUpperCase(Constants.SYSTEM_LOCALE)
88              .equals("FALSE"))
89        {
900          bReturn = false;
91        }
92        else
93        {
940          throw new ConfigurationTypeConversionFailedException(
95                    valueAsString, key, "Boolean");
96        }
970       return bReturn;
98     }
99  
100  
101 (7)   /**
102      * {@inheritDoc}
103 (8)    * FIXME: activate ejb tag if XDoclet BugFix is available
104      * @XXXejb.interface-method view-type="remote"
105      * @XXXejb.transaction type="Required"
106      */
107 (9)(10)   public int getInt (ConfigurationKey key)
108           throws ConfigurationValueNotFoundException,
109                 ConfigurationTypeConversionFailedException,
110                 ArgumentMalformedException
111     {
1120       Assert.notNull(key, PARAM_KEY_OF_GET_METHODS);
113        int iReturn;
114  
1150       final String valueAsString = getString(key);
116        try
117        {
1180          iReturn = Integer.parseInt(valueAsString);
119        }
1200       catch (NumberFormatException nfe)
121        {
1220          throw new ConfigurationTypeConversionFailedException(
123                    valueAsString, key, "Integer", nfe);
1240       }
1250       return iReturn;
126     }
127  
128  
129 (11)   /**
130      * {@inheritDoc}
131 (12)    * FIXME: activate ejb tag if XDoclet BugFix is available
132      * @XXXejb.interface-method view-type="remote"
133      * @XXXejb.transaction type="Required"
134      */
135 (13)(14)   public long getLong (ConfigurationKey key)
136           throws ConfigurationValueNotFoundException,
137                 ConfigurationTypeConversionFailedException,
138                 ArgumentMalformedException
139     {
1400       Assert.notNull(key, PARAM_KEY_OF_GET_METHODS);
141        long lReturn;
142  
1430       final String valueAsString = getString(key);
144        try
145        {
1460          lReturn = Long.parseLong(valueAsString);
147        }
1480       catch (NumberFormatException nfe)
149        {
1500          throw new ConfigurationTypeConversionFailedException(
151                    valueAsString, key, "Long", nfe);
1520       }
1530       return lReturn;
154     }
155  
156  
157 (15)   /**
158      * {@inheritDoc}
159 (16)    * FIXME: activate ejb tag if XDoclet BugFix is available
160      * @XXXejb.interface-method view-type="remote"
161      * @XXXejb.transaction type="Required"
162      */
163 (17)(18)   public String getString (ConfigurationKey key)
164           throws ConfigurationValueNotFoundException,
165                  ArgumentMalformedException
166     {
1670       Assert.notNull(key, PARAM_KEY_OF_GET_METHODS);
1680       return getConfigurationCacheCurrent().getString(key.toString());
169     }
170  
171     protected ConfigurationCacheInterface getConfigurationCacheCurrent ()
172     {
173        // for database
1740       return ConfigurationCacheByDbReadOnlyImpl.current();
175        // for properties file
176        //return ConfigurationCacheByPropertiesImpl.current();
177     }
178  
179  }

Findings in this File

c (1) 49 : 0 Type Javadoc comment is missing an @author tag.
c (2) 67 : 0 First sentence should end with a period.
i (3) 69 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
d (4) 73 : 0 @XXXejb.interface-method is an unknown tag.
d (5) 73 : 0 @XXXejb.transaction is an unknown tag.
i (6) 87 : 0 method org.jcoderz.commons.config.ConfigurationServiceCommonImpl.getBoolean(ConfigurationKey) makes literal string comparisons passing the literal as an argument
c (7) 101 : 0 First sentence should end with a period.
i (8) 103 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
d (9) 107 : 0 @XXXejb.interface-method is an unknown tag.
d (10) 107 : 0 @XXXejb.transaction is an unknown tag.
c (11) 129 : 0 First sentence should end with a period.
i (12) 131 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
d (13) 135 : 0 @XXXejb.interface-method is an unknown tag.
d (14) 135 : 0 @XXXejb.transaction is an unknown tag.
c (15) 157 : 0 First sentence should end with a period.
i (16) 159 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
d (17) 163 : 0 @XXXejb.interface-method is an unknown tag.
d (18) 163 : 0 @XXXejb.transaction is an unknown tag.