View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   //
3   //                  ObjectLab is sponsoring QALab
4   // 
5   // Based in London, we are world leaders in the design and development 
6   // of bespoke applications for the Securities Financing markets.
7   // 
8   // <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
9   //           ___  _     _           _   _          _
10  //          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
11  //         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
12  //         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
13  //          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
14  //                   |__/
15  //
16  //                   http://www.ObjectLab.co.uk
17  // ---------------------------------------------------------------------------
18  //
19  //QALab is released under the GNU General Public License.
20  //
21  //QALab: Collects QA Statistics from your build over time.
22  //2005+, ObjectLab Ltd
23  //
24  //This library is free software; you can redistribute it and/or
25  //modify it under the terms of the GNU General Public
26  //License as published by the Free Software Foundation; either
27  //version 2.1 of the License, or (at your option) any later version.
28  //
29  //This library is distributed in the hope that it will be useful,
30  //but WITHOUT ANY WARRANTY; without even the implied warranty of
31  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
32  //General Public License for more details.
33  //
34  //You should have received a copy of the GNU General Public
35  //License along with this library; if not, write to the Free Software
36  //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
37  //
38  ////////////////////////////////////////////////////////////////////////////////
39  package net.objectlab.qalab.parser;
40  
41  import net.objectlab.qalab.util.Util;
42  
43  import org.xml.sax.Attributes;
44  
45  /**
46   * This class is able to read the XDOC output from FindBugs and integrate the
47   * violation results into our qalab.xml format.
48   * 
49   * @see <a href="http://findbugs.sourceforge.net/">FindBugs at SourceForge</a>
50   * @author Benoit Xhenseval
51   * @version $Revision: 187 $
52   */
53  public class FindBugsStatMerge extends CheckstyleOrPMDBaseMerge {
54      // ~ Methods
55      // ------------------------------------------------------------------------
56  
57      /**
58       * @return "file"
59       */
60      protected final String getFileTag() {
61          return "file";
62      }
63  
64      /**
65       * @return classname
66       */
67      protected final String getFileNameAttribute() {
68          return "classname";
69      }
70  
71      /**
72       * @return BugInstance
73       */
74      protected final String getViolationTag() {
75          return "BugInstance";
76      }
77  
78      /**
79       * @return findbugs
80       */
81      public final String getType() {
82          return "findbugs";
83      }
84  
85      /**
86       * Given the different ways that files can be stored on file system, this
87       * method will remove anything part of the path up to the 'srcDir' given, it
88       * should only retain the package name in java. For instance, for Findbugs
89       * classname="net.objectlab.X" will be stored in the compiled stats as:
90       * net/objectlab/A.java
91       * 
92       * @param att
93       *            the XML attribute
94       */
95      protected final void setFileName(final Attributes att) {
96          String fileName = Util.getAttributeValue(att, getFileNameAttribute(),
97                  isQuiet(), getTaskLogger());
98  
99          fileName = fileName.replace('.', '/');
100 
101         final int embeddedClass = fileName.indexOf("$");
102 
103         if (embeddedClass > 0) {
104             fileName = fileName.substring(0, embeddedClass);
105         }
106 
107         fileName += ".java";
108 
109         if (!isQuiet()) {
110             getTaskLogger().log("setCurrentFileName FILE [" + fileName + "]");
111         }
112 
113         setCurrentFile(fileName);
114     }
115 }
116 /*
117  *                   ObjectLab is sponsoring QALab
118  * 
119  * Based in London, we are world leaders in the design and development 
120  * of bespoke applications for the securities financing markets.
121  * 
122  * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
123  *           ___  _     _           _   _          _
124  *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
125  *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
126  *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
127  *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
128  *                   |__/
129  *
130  *                     www.ObjectLab.co.uk
131  */