Clover Coverage Report - Checkstyle
Coverage timestamp: Fri May 9 2008 10:48:13 EST
../../../../../img/srcFileCovDistChart9.png 55% of files have more coverage
7   90   4   1.75
0   30   0.57   4
4     1  
1    
 
  AbstractOption       Line # 32 81.8% 0.8181818
4.1 7 4 4 0.57
 
  ( 10 of 40)
 
1    ////////////////////////////////////////////////////////////////////////////////
2    // checkstyle: Checks Java source code for adherence to a set of rules.
3    // Copyright (C) 2001-2005 Oliver Burn
4    //
5    // This library is free software; you can redistribute it and/or
6    // modify it under the terms of the GNU Lesser General Public
7    // License as published by the Free Software Foundation; either
8    // version 2.1 of the License, or (at your option) any later version.
9    //
10    // This library is distributed in the hope that it will be useful,
11    // but WITHOUT ANY WARRANTY; without even the implied warranty of
12    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    // Lesser General Public License for more details.
14    //
15    // You should have received a copy of the GNU Lesser General Public
16    // License along with this library; if not, write to the Free Software
17    // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18    ////////////////////////////////////////////////////////////////////////////////
19    package com.puppycrawl.tools.checkstyle.checks;
20   
21    import java.io.Serializable;
22    import java.io.ObjectStreamException;
23    import java.util.Map;
24   
25    /**
26    * Abstract class that represents options.
27    *
28    * @author Oliver Burn
29    * @author Rick Giles
30   
31    */
 
32    public abstract class AbstractOption
33    implements Serializable
34    {
35   
36    /** the string representation of the option **/
37    private final String mStrRep;
38   
39    /**
40    * Creates a new <code>AbstractOption</code> instance.
41    * @param aStrRep the string representation
42    */
 
43  18 toggle protected AbstractOption(String aStrRep)
44    {
45  18 mStrRep = aStrRep.trim().toLowerCase();
46  18 final Map strToOpt = getStrToOpt();
47  18 strToOpt.put(mStrRep, this);
48    }
49   
50    /**
51    * Returns the map from string representations to options.
52    * @return <code>Map</code> from strings to options.
53    */
54    protected abstract Map getStrToOpt();
55   
56    /**
57    * Returns the option specified by a string representation. If no
58    * option exists then null is returned.
59    * @param aStrRep the String representation to parse
60    * @return the <code>AbstractOption</code> value represented by
61    * aStrRep, or null if none exists.
62    */
 
63  48 toggle public AbstractOption decode(String aStrRep)
64    {
65  48 final Map strToOpt = getStrToOpt();
66  48 return (AbstractOption) strToOpt.get(aStrRep.trim().toLowerCase());
67    }
68   
69    /**
70    * {@inheritDoc}
71    **/
 
72  42 toggle public String toString()
73    {
74  42 return mStrRep;
75    }
76   
77    /**
78    * Ensures that we don't get multiple instances of one AbstractOption
79    * during deserialization. See Section 3.6 of the Java Object
80    * Serialization Specification for details.
81    *
82    * @return the serialization replacement object
83    * @throws ObjectStreamException if a deserialization error occurs
84    */
 
85  0 toggle protected Object readResolve()
86    throws ObjectStreamException
87    {
88  0 return decode(mStrRep);
89    }
90    }