[Japi-cvs] SF.net SVN: japi:[1400] tools/archStat/trunk/src/prj/net/sf/japi/archstat
Status: Beta
                
                Brought to you by:
                
                    christianhujer
                    
                
            | 
     
      
      
      From: <chr...@us...> - 2010-04-11 10:12:19
      
     
   | 
Revision: 1400
          http://japi.svn.sourceforge.net/japi/?rev=1400&view=rev
Author:   christianhujer
Date:     2010-04-11 10:12:10 +0000 (Sun, 11 Apr 2010)
Log Message:
-----------
Rename LineCheck to RegexLineCheck.
Modified Paths:
--------------
    tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java
    tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java
Added Paths:
-----------
    tools/archStat/trunk/src/prj/net/sf/japi/archstat/RegexLineCheck.java
Removed Paths:
-------------
    tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java
Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java
===================================================================
--- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java	2010-04-01 13:03:16 UTC (rev 1399)
+++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java	2010-04-11 10:12:10 UTC (rev 1400)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009  Christian Hujer
+ * Copyright (C) 2009 - 2010  Christian Hujer
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,6 +17,17 @@
 
 package net.sf.japi.archstat;
 
+import net.sf.japi.io.args.ArgParser;
+import net.sf.japi.io.args.BasicCommand;
+import net.sf.japi.io.args.Option;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
@@ -27,16 +38,6 @@
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.jetbrains.annotations.NotNull;
-import org.xml.sax.SAXException;
-import net.sf.japi.io.args.BasicCommand;
-import net.sf.japi.io.args.ArgParser;
-import net.sf.japi.io.args.Option;
 
 /** A Command for performing recursive source code file statistics.
  * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
@@ -128,7 +129,7 @@
     }
 
     /** The checks that should be performed. */
-    private final List<LineCheck> checkers = new ArrayList<LineCheck>();
+    private final List<RegexLineCheck> checkers = new ArrayList<RegexLineCheck>();
 
     /** Reads a file.
      * @param file File to read.
@@ -234,12 +235,12 @@
     private void readCheckers(final Document doc) {
         final NodeList nl = doc.getElementsByTagName("pattern");
         for (int i = 0; i < nl.getLength(); i++) {
-            final LineCheck check = new LineCheck((Element) nl.item(i));
-            if (checkers.contains(check)) {
+            final RegexLineCheck regexLineCheck = new RegexLineCheck((Element) nl.item(i));
+            if (checkers.contains(regexLineCheck)) {
                 // TODO:2009-02-18:christianhujer:Improve.
-                throw new RuntimeException("Duplicate Checker " + check.getName());
+                throw new RuntimeException("Duplicate Checker " + regexLineCheck.getName());
             }
-            checkers.add(check);
+            checkers.add(regexLineCheck);
         }
     }
 
Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java
===================================================================
--- tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java	2010-04-01 13:03:16 UTC (rev 1399)
+++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java	2010-04-11 10:12:10 UTC (rev 1400)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009  Christian Hujer
+ * Copyright (C) 2009 - 2010  Christian Hujer
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -35,10 +35,10 @@
 public class FileStat {
 
     /** The checks that should be performed. */
-    private final List<LineCheck> checkers;
+    private final List<RegexLineCheck> checkers;
 
     /** The warnings that occurred in that individual check. */
-    private final Map<LineCheck, Integer> checkWarnings = new HashMap<LineCheck, Integer>();
+    private final Map<RegexLineCheck, Integer> checkWarnings = new HashMap<RegexLineCheck, Integer>();
 
     /** The children of this statistic. */
     private final Map<File, FileStat> children = new HashMap<File, FileStat>();
@@ -71,14 +71,14 @@
     private int warnings;
 
     @SuppressWarnings({"AssignmentToCollectionOrArrayFieldFromParameter"})
-    FileStat(final List<LineCheck> checkers) {
+    FileStat(final List<RegexLineCheck> checkers) {
         this.checkers = checkers;
         title = "<SUM>";
         file = null;
     }
 
     @SuppressWarnings({"AssignmentToCollectionOrArrayFieldFromParameter"})
-    FileStat(final List<LineCheck> checkers, @NotNull final File file, final boolean printSummaries) {
+    FileStat(final List<RegexLineCheck> checkers, @NotNull final File file, final boolean printSummaries) {
         this.checkers = checkers;
         this.file = file;
         title = file.toString();
@@ -112,10 +112,10 @@
         }
     }
     void treeWarnings() {
-        for (final LineCheck lineCheck : checkers) {
-            final Integer i = checkWarnings.get(lineCheck);
+        for (final RegexLineCheck regexLineCheck : checkers) {
+            final Integer i = checkWarnings.get(regexLineCheck);
             if (i != null && i > 0) {
-                System.err.println(file + ": " + lineCheck.getMessageType() + ": " + i + " " + lineCheck.getPlural());
+                System.err.println(file + ": " + regexLineCheck.getMessageType() + ": " + i + " " + regexLineCheck.getPlural());
             }
         }
         if (getWarnings() > 0) {
@@ -123,20 +123,21 @@
         }
     }
     void checkLine(final String line, final int lineNumber) {
-        for (final LineCheck lineCheck : checkers) {
-            if (lineCheck.hasProblem(file, line, lineNumber)) {
-                incWarning(lineCheck);
+        for (final RegexLineCheck regexLineCheck : checkers) {
+            if (regexLineCheck.hasProblem(file, line, lineNumber)) {
+                incWarning(regexLineCheck);
             }
         }
     }
-    public void incWarning(final LineCheck lineCheck) {
+    public void incWarning(final RegexLineCheck regexLineCheck) {
         warnings = getWarnings() + 1;
-        final Integer i = checkWarnings.get(lineCheck);
-        checkWarnings.put(lineCheck, i != null ? i + 1 : 1);
+        final Integer i = checkWarnings.get(regexLineCheck);
+        checkWarnings.put(regexLineCheck, i != null ? i + 1 : 1);
     }
 
     /** Adds a child with the specified filename.
      * @param filename Filename of the child to add.
+     * @param printSummaries Whether or not to print summaries.
      */
     public void addChild(final String filename, final boolean printSummaries) {
         addChild(new File(filename), printSummaries);
@@ -144,6 +145,7 @@
 
     /** Adds a child with the specified file.
      * @param file File of the child to add.
+     * @param printSummaries Whether or not to print summaries.
      */
     public void addChild(final File file, final boolean printSummaries) {
         if (!isIgnored(file)) {
@@ -171,11 +173,11 @@
         sourceLines += child.sourceLines;
         commentLines += child.commentLines;
         warnings = getWarnings() + child.getWarnings();
-        for (final LineCheck lineCheck : checkers) {
-            final Integer childI = child.checkWarnings.get(lineCheck);
+        for (final RegexLineCheck regexLineCheck : checkers) {
+            final Integer childI = child.checkWarnings.get(regexLineCheck);
             if (childI != null) {
-                final Integer i = checkWarnings.get(lineCheck);
-                checkWarnings.put(lineCheck, i != null ? i + childI : childI);
+                final Integer i = checkWarnings.get(regexLineCheck);
+                checkWarnings.put(regexLineCheck, i != null ? i + childI : childI);
             }
         }
     }
Deleted: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java
===================================================================
--- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java	2010-04-01 13:03:16 UTC (rev 1399)
+++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java	2010-04-11 10:12:10 UTC (rev 1400)
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2009  Christian Hujer
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.sf.japi.archstat;
-
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.io.File;
-import org.w3c.dom.Element;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/** A Line-based Check.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- * @since 0.1
- */
-public class LineCheck {
-
-    /** The message type to emit if this check found something. */
-    @NotNull private final MessageType messageType;
-
-    /** The name of this check. */
-    @NotNull private final String name;
-
-    /** The regular expression for this check.
-     * If it matches, the check found something to report.
-     */
-    @NotNull private final Pattern regex;
-
-    /** The message to emit if this check found something. */
-    @NotNull private final String message;
-
-    /** Create a line check.
-     * @param elem XML Element with the check information.
-     */
-    public LineCheck(@NotNull final Element elem) {
-        this(Enum.valueOf(MessageType.class, elem.getAttribute("messageType")), elem.getAttribute("name"), Pattern.compile(elem.getAttribute("regex")), elem.getAttribute("message"));
-    }
-
-    /** Create a line check.
-     * @param messageType The message type to emit if this check found something.
-     * @param name The name of this check.
-     * @param regex The regular expression for this check.
-     * @param message The message to emit if this check found something.
-     */
-    public LineCheck(@NotNull final MessageType messageType, @NotNull final String name, @NotNull final Pattern regex, @NotNull final String message) {
-        this.messageType = messageType;
-        this.name = name;
-        this.regex = regex;
-        this.message = message;
-    }
-
-    /** Returns whether or not this line check finds something.
-     * @param file File to check (informational purpose only, e.g. for error message).
-     * @param line Line to check.
-     * @param lineNumber Line number of the line that's checked.
-     * @return true if this check found a problem, otherwise false.
-     */
-    boolean hasProblem(@NotNull final File file, @NotNull final String line, final int lineNumber) {
-        boolean ret = false;
-        final Matcher matcher = regex.matcher(line);
-        if (matcher.find()) {
-            final int column = matcher.start();
-            ret = true;
-            LogSystem.log(new LogEntry(file, line, lineNumber, column + 1, messageType, name, message));
-        }
-        return ret;
-    }
-
-    /** Returns the name of this check.
-     * @return The name of this check.
-     */
-    @NotNull public String getName() {
-        return name;
-    }
-
-    /** Returns the message type of this check.
-     * @return The message type of this check.
-     */
-    @NotNull public MessageType getMessageType() {
-        return messageType;
-    }
-
-    /** Returns the plural name of this check.
-     * @return The plural name of this check.
-     */
-    @NotNull public String getPlural() {
-        return name; // TODO:2009-02-18:christianhujer:Implement proper plural support.
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public boolean equals(@Nullable final Object obj) {
-        return obj != null && obj instanceof LineCheck && ((LineCheck) obj).name.equals(name);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public int hashCode() {
-        return name.hashCode();
-    }
-
-}
Copied: tools/archStat/trunk/src/prj/net/sf/japi/archstat/RegexLineCheck.java (from rev 1397, tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java)
===================================================================
--- tools/archStat/trunk/src/prj/net/sf/japi/archstat/RegexLineCheck.java	                        (rev 0)
+++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/RegexLineCheck.java	2010-04-11 10:12:10 UTC (rev 1400)
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2009 - 2010  Christian Hujer
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.sf.japi.archstat;
+
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.io.File;
+import org.w3c.dom.Element;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/** A Line-based Check.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ * @since 0.1
+ */
+public class RegexLineCheck {
+
+    /** The message type to emit if this check found something. */
+    @NotNull private final MessageType messageType;
+
+    /** The name of this check. */
+    @NotNull private final String name;
+
+    /** The regular expression for this check.
+     * If it matches, the check found something to report.
+     */
+    @NotNull private final Pattern regex;
+
+    /** The message to emit if this check found something. */
+    @NotNull private final String message;
+
+    /** Create a line check.
+     * @param elem XML Element with the check information.
+     */
+    public RegexLineCheck(@NotNull final Element elem) {
+        this(Enum.valueOf(MessageType.class, elem.getAttribute("messageType")), elem.getAttribute("name"), Pattern.compile(elem.getAttribute("regex")), elem.getAttribute("message"));
+    }
+
+    /** Create a line check.
+     * @param messageType The message type to emit if this check found something.
+     * @param name The name of this check.
+     * @param regex The regular expression for this check.
+     * @param message The message to emit if this check found something.
+     */
+    public RegexLineCheck(@NotNull final MessageType messageType, @NotNull final String name, @NotNull final Pattern regex, @NotNull final String message) {
+        this.messageType = messageType;
+        this.name = name;
+        this.regex = regex;
+        this.message = message;
+    }
+
+    /** Returns whether or not this line check finds something.
+     * @param file File to check (informational purpose only, e.g. for error message).
+     * @param line Line to check.
+     * @param lineNumber Line number of the line that's checked.
+     * @return true if this check found a problem, otherwise false.
+     */
+    boolean hasProblem(@NotNull final File file, @NotNull final String line, final int lineNumber) {
+        boolean ret = false;
+        final Matcher matcher = regex.matcher(line);
+        if (matcher.find()) {
+            final int column = matcher.start();
+            ret = true;
+            LogSystem.log(new LogEntry(file, line, lineNumber, column + 1, messageType, name, message));
+        }
+        return ret;
+    }
+
+    /** Returns the name of this check.
+     * @return The name of this check.
+     */
+    @NotNull public String getName() {
+        return name;
+    }
+
+    /** Returns the message type of this check.
+     * @return The message type of this check.
+     */
+    @NotNull public MessageType getMessageType() {
+        return messageType;
+    }
+
+    /** Returns the plural name of this check.
+     * @return The plural name of this check.
+     */
+    @NotNull public String getPlural() {
+        return name; // TODO:2009-02-18:christianhujer:Implement proper plural support.
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean equals(@Nullable final Object obj) {
+        return obj != null && obj instanceof RegexLineCheck && ((RegexLineCheck) obj).name.equals(name);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+}
Property changes on: tools/archStat/trunk/src/prj/net/sf/japi/archstat/RegexLineCheck.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |