Thread: [Japi-cvs] SF.net SVN: japi:[764] tools/archStat/trunk/src/prj/net/sf/japi/archstat
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2008-12-29 04:48:14
|
Revision: 764 http://japi.svn.sourceforge.net/japi/?rev=764&view=rev Author: christianhujer Date: 2008-12-29 04:48:11 +0000 (Mon, 29 Dec 2008) Log Message: ----------- Added missing final modifiers. Modified Paths: -------------- historic/trunk/src/test/net/sf/japi/finance/SimpleCapitalCalculatorTest.java libs/swing-list/trunk/src/prj/net/sf/japi/swing/list/ArrayListModel.java libs/swing-misc/trunk/src/prj/net/sf/japi/swing/misc/JFileChooserButton.java libs/swing-recent/trunk/src/prj/net/sf/japi/swing/recent/RecentURLsMenu.java libs/util/trunk/src/prj/net/sf/japi/util/filter/file/Factory.java progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionInfoGUI.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java Modified: historic/trunk/src/test/net/sf/japi/finance/SimpleCapitalCalculatorTest.java =================================================================== --- historic/trunk/src/test/net/sf/japi/finance/SimpleCapitalCalculatorTest.java 2008-12-29 04:44:02 UTC (rev 763) +++ historic/trunk/src/test/net/sf/japi/finance/SimpleCapitalCalculatorTest.java 2008-12-29 04:48:11 UTC (rev 764) @@ -29,7 +29,7 @@ */ public class SimpleCapitalCalculatorTest extends TestCase { - SimpleCapitalCalculator ic = new SimpleCapitalCalculator(100, 15); + final SimpleCapitalCalculator ic = new SimpleCapitalCalculator(100, 15); public void testSimpleCapitalCalculator() throws Exception { //ic = new SimpleCapitalCalculator(100, 15); Modified: libs/swing-list/trunk/src/prj/net/sf/japi/swing/list/ArrayListModel.java =================================================================== --- libs/swing-list/trunk/src/prj/net/sf/japi/swing/list/ArrayListModel.java 2008-12-29 04:44:02 UTC (rev 763) +++ libs/swing-list/trunk/src/prj/net/sf/japi/swing/list/ArrayListModel.java 2008-12-29 04:48:11 UTC (rev 764) @@ -184,7 +184,7 @@ private class IteratorWrapper implements Iterator<E> { /** Iterator that's wrapped. */ - private Iterator<E> iterator; + private final Iterator<E> iterator; /** The current element, needed in {@link #remove()}. */ private E currentElement = null; Modified: libs/swing-misc/trunk/src/prj/net/sf/japi/swing/misc/JFileChooserButton.java =================================================================== --- libs/swing-misc/trunk/src/prj/net/sf/japi/swing/misc/JFileChooserButton.java 2008-12-29 04:44:02 UTC (rev 763) +++ libs/swing-misc/trunk/src/prj/net/sf/japi/swing/misc/JFileChooserButton.java 2008-12-29 04:48:11 UTC (rev 764) @@ -40,12 +40,12 @@ /** The JTextField to read/write the file path to. * @serial include */ - private JTextField textField; + private final JTextField textField; /** The file selection mode. * @serial include */ - private int fileSelectionMode; + private final int fileSelectionMode; /** The base directory for choosing files. * @serial include Modified: libs/swing-recent/trunk/src/prj/net/sf/japi/swing/recent/RecentURLsMenu.java =================================================================== --- libs/swing-recent/trunk/src/prj/net/sf/japi/swing/recent/RecentURLsMenu.java 2008-12-29 04:44:02 UTC (rev 763) +++ libs/swing-recent/trunk/src/prj/net/sf/japi/swing/recent/RecentURLsMenu.java 2008-12-29 04:48:11 UTC (rev 764) @@ -96,7 +96,7 @@ private static final long serialVersionUID = 1L; /** The URL to be opened. */ - private String url; + private final String url; /** Create a URLAction. * @param url URL to use for this action. Modified: libs/util/trunk/src/prj/net/sf/japi/util/filter/file/Factory.java =================================================================== --- libs/util/trunk/src/prj/net/sf/japi/util/filter/file/Factory.java 2008-12-29 04:44:02 UTC (rev 763) +++ libs/util/trunk/src/prj/net/sf/japi/util/filter/file/Factory.java 2008-12-29 04:48:11 UTC (rev 764) @@ -46,7 +46,7 @@ private static class NotFileFilter extends AbstractFileFilter { /** Filter to invert. */ - private FileFilter filter; + private final FileFilter filter; /** Create a NotFileFilter. * @param filter Filter to invert Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionInfoGUI.java =================================================================== --- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionInfoGUI.java 2008-12-29 04:44:02 UTC (rev 763) +++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionInfoGUI.java 2008-12-29 04:48:11 UTC (rev 764) @@ -38,7 +38,7 @@ /** The Label. * @serial include */ - private JLabel label; + private final JLabel label; /** Create a new QuestionCollectionInfoGUI. */ Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java 2008-12-29 04:44:02 UTC (rev 763) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java 2008-12-29 04:48:11 UTC (rev 764) @@ -13,7 +13,7 @@ public class LineCheck { /** The message type to emit if this check found something. */ - @NotNull private MessageType type; + @NotNull private final MessageType type; /** The name of this check. */ @NotNull private final String name; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-02-01 16:28:47
|
Revision: 785 http://japi.svn.sourceforge.net/japi/?rev=785&view=rev Author: christianhujer Date: 2009-02-01 16:28:43 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Improved logging mechanisms. They can now be less verbose and more identical to the output of compiler error messages. Modified Paths: -------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java 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 2009-02-01 16:27:10 UTC (rev 784) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-02-01 16:28:43 UTC (rev 785) @@ -46,6 +46,9 @@ /** Whether or not to output memory statistics. */ private boolean memoryStatistics; + /** Whether or not to print summaries. */ + private boolean printSummaries; + /** {@inheritDoc} */ @SuppressWarnings({"InstanceMethodNamingConvention"}) public int run(@NotNull final List<String> args) throws Exception { @@ -61,7 +64,7 @@ readDefaultCheckers(); final FileStat fileStat = new FileStat(checkers); for (final String arg : args) { - fileStat.addChild(arg); + fileStat.addChild(arg, printSummaries); } fileStat.printStatistic(System.out, depth); if (memoryStatistics) { @@ -73,7 +76,7 @@ } /** The default depth. */ - private static final int DEFAULT_DEPTH = Integer.MAX_VALUE; + private static final int DEFAULT_DEPTH = 0; //Integer.MAX_VALUE; /** The depth up to which statistics are printed. */ @@ -95,6 +98,14 @@ this.depth = depth; } + /** Sets whether or not to print summaries. + * @param printSummaries <code>true</code> to print summaries, otherwise <code>false</code>. + */ + @Option({"s", "summary"}) + public void setPrintSummary(@NotNull final Boolean printSummaries) { + this.printSummaries = printSummaries; + } + /** Returns the depth up to which statistics are printed. * @return The depth up to which statistics are printed. */ Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java 2009-02-01 16:27:10 UTC (rev 784) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java 2009-02-01 16:28:43 UTC (rev 785) @@ -53,7 +53,7 @@ } @SuppressWarnings({"AssignmentToCollectionOrArrayFieldFromParameter"}) - FileStat(final List<LineCheck> checkers, @NotNull final File file) { + FileStat(final List<LineCheck> checkers, @NotNull final File file, final boolean printSummaries) { this.checkers = checkers; this.file = file; title = file.toString(); @@ -79,16 +79,18 @@ } if (file.isDirectory()) { for (final File member : file.listFiles()) { - addChild(member); + addChild(member, printSummaries); } } - treeWarnings(); + if (printSummaries) { + treeWarnings(); + } } void treeWarnings() { for (final LineCheck lineCheck : checkers) { final Integer i = checkWarnings.get(lineCheck); if (i != null && i > 0) { - System.err.println(file + ": " + lineCheck.getType() + ": " + i + " " + lineCheck.getPlural()); + System.err.println(file + ": " + lineCheck.getMessageType() + ": " + i + " " + lineCheck.getPlural()); } } if (warnings > 0) { @@ -111,17 +113,29 @@ /** Adds a child with the specified filename. * @param filename Filename of the child to add. */ - public void addChild(final String filename) { - addChild(new File(filename)); + public void addChild(final String filename, final boolean printSummaries) { + addChild(new File(filename), printSummaries); } /** Adds a child with the specified file. * @param file File of the child to add. */ - public void addChild(final File file) { - addChild(new FileStat(checkers, file)); + public void addChild(final File file, final boolean printSummaries) { + if (!isIgnored(file)) { + addChild(new FileStat(checkers, file, printSummaries)); + } } + /** Returns whether or not a file is ignored. + * @param file File that might be ignored. + * @return <code>true</code> if <var>file</var> is ignored, otherwise <code>false</code>. + */ + public boolean isIgnored(@NotNull final File file) { + final String filename = file.getName(); + // TODO:christianhujer:This should be configurable. + return ".svn".equals(filename); + } + /** Adds a child with the specified statistics. * @param child Child to add. */ @@ -153,8 +167,10 @@ * @throws IOException In case of I/O problems. */ public void printStatistic(@NotNull final Appendable out, final int level) throws IOException { - out.append("Title;Errors;Raw lines;Lines w/o comments;Comment lines;Sloc\n"); - print(out, level); + if (level > 0) { + out.append("Title;Errors;Raw lines;Lines w/o comments;Comment lines;Sloc\n"); + print(out, level); + } } /** Prints recursive statistics to the specified appendable. @@ -165,7 +181,7 @@ public void print(final Appendable out, final int level) throws IOException { out.append(toString()); out.append("\n"); - if (level > 0) { + if (level > 1) { for (final File file : new TreeSet<File>(children.keySet())) { children.get(file).print(out, level - 1); } Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java 2009-02-01 16:27:10 UTC (rev 784) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java 2009-02-01 16:28:43 UTC (rev 785) @@ -13,7 +13,7 @@ public class LineCheck { /** The message type to emit if this check found something. */ - @NotNull private final MessageType type; + @NotNull private final MessageType messageType; /** The name of this check. */ @NotNull private final String name; @@ -30,17 +30,17 @@ * @param elem XML Element with the check information. */ public LineCheck(@NotNull final Element elem) { - this(Enum.valueOf(MessageType.class, elem.getAttribute("type")), elem.getAttribute("name"), Pattern.compile(elem.getAttribute("regex")), elem.getAttribute("message")); + this(Enum.valueOf(MessageType.class, elem.getAttribute("messageType")), elem.getAttribute("name"), Pattern.compile(elem.getAttribute("regex")), elem.getAttribute("message")); } /** Create a line check. - * @param type The message type to emit if this check found something. + * @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 type, @NotNull final String name, @NotNull final Pattern regex, @NotNull final String message) { - this.type = type; + 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; @@ -58,7 +58,7 @@ if (m.find()) { final int column = m.start(); ret = true; - LogSystem.log(new LogEntry(file, line, lineNumber, column + 1, type, name, message)); + LogSystem.log(new LogEntry(file, line, lineNumber, column + 1, messageType, name, message)); } return ret; } @@ -70,14 +70,14 @@ return name; } - /** Returns the type of this check. - * @return The type of this check. + /** Returns the message type of this check. + * @return The message type of this check. */ - @NotNull public MessageType getType() { - return type; + @NotNull public MessageType getMessageType() { + return messageType; } - /** returns the plural name of this check. + /** Returns the plural name of this check. * @return The plural name of this check. */ @NotNull public String getPlural() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-02-18 05:37:28
|
Revision: 958 http://japi.svn.sourceforge.net/japi/?rev=958&view=rev Author: christianhujer Date: 2009-02-18 05:37:26 +0000 (Wed, 18 Feb 2009) Log Message: ----------- Fixed checkstyle issues. Modified Paths: -------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-02-18 05:15:34 UTC (rev 957) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-02-18 05:37:26 UTC (rev 958) @@ -63,7 +63,7 @@ private boolean printSummaries; /** {@inheritDoc} */ - @SuppressWarnings({"InstanceMethodNamingConvention"}) + @SuppressWarnings({"InstanceMethodNamingConvention", "ProhibitedExceptionDeclared"}) public int run(@NotNull final List<String> args) throws Exception { if (args.size() == 0) { System.err.println("Error: No arguments given."); @@ -85,7 +85,7 @@ System.gc(); System.err.println("Memory free (end, after GC): " + Runtime.getRuntime().freeMemory()); } - return fileStat.warnings > 0 ? 1 : 0; + return fileStat.getWarnings() > 0 ? 1 : 0; } /** The default depth. */ @@ -140,7 +140,8 @@ final BufferedReader in = new BufferedReader(new FileReader(file)); try { final char[] buf = new char[BUF_SIZE]; - for (int charsRead; (charsRead = in.read(buf)) != -1; ) { + //noinspection NestedAssignment + for (int charsRead; (charsRead = in.read(buf)) != -1;) { sb.append(buf, 0, charsRead); } } finally { @@ -150,18 +151,24 @@ } /** The Pattern for splitting lines. */ - // TODO: This is somehow bogus. Replace this by something else. - private static final Pattern lineSplitPattern = Pattern.compile("(?<=\\r\\n|\\r|\\n)"); + // TODO:2009-02-18:christianhujer:This is somehow bogus. Replace this by something else. + private static final Pattern LINE_SPLIT_PATTERN = Pattern.compile("(?<=\\r\\n|\\r|\\n)"); /** The Pattern for counting lines. */ - private static final Pattern lineCountPattern = Pattern.compile("$", Pattern.MULTILINE); + private static final Pattern LINE_COUNT_PATTERN = Pattern.compile("$", Pattern.MULTILINE); + /** Pattern that matches comments. */ + private static final Pattern COMMENT_PATTERN = Pattern.compile("/(/.*?$|\\*.*?\\*/(\\s*?\\n)?)", Pattern.MULTILINE | Pattern.DOTALL); + + /** Pattern that matches source lines. */ + private static final Pattern SOURCE_LINE_PATTERN = Pattern.compile("^.*\\S.*\\S.*\\S.*$", Pattern.MULTILINE); + /** Returns the number of lines in the specified string. * @param string String of which to count lines. * @return The number of lines in <var>string</var> */ static int countLines(final CharSequence string) { - return count(lineCountPattern, string) - 1; + return count(LINE_COUNT_PATTERN, string) - 1; } /** Returns a split array of lines for the specified string. @@ -169,19 +176,30 @@ * @return Array with lines. */ static String[] getLines(final CharSequence string) { - return lineSplitPattern.split(string); + return LINE_SPLIT_PATTERN.split(string); } - private static final Pattern commentPattern = Pattern.compile("/(/.*?$|\\*.*?\\*/(\\s*?\\n)?)", Pattern.MULTILINE | Pattern.DOTALL); + /** Returns a String that is the input String with all comments removed. + * @param string String from which to remove the comments. + * @return Copy of <var>string</var> with all comments removed. + */ static CharSequence removeCComments(final CharSequence string) { - return commentPattern.matcher(string).replaceAll(""); + return COMMENT_PATTERN.matcher(string).replaceAll(""); } - private static final Pattern sourceLinePattern = Pattern.compile("^.*\\S.*\\S.*\\S.*$", Pattern.MULTILINE); + /** Returns the number of source lines of <var>string</var>. + * @param string String of which to count the number of source lines. + * @return The number of source lines of <var>string</var>. + */ static int countSourceLines(final CharSequence string) { - return count(sourceLinePattern, string); + return count(SOURCE_LINE_PATTERN, string); } + /** Returns the number of matches of <var>pattern</var> on <var>string</var>. + * @param pattern Pattern of which to count the matches. + * @param string String in which to count the matches. + * @return The number of matches of <var>pattern</var> on <var>string</var>. + */ private static int count(final Pattern pattern, final CharSequence string) { int count = 0; final Matcher m = pattern.matcher(string); @@ -191,6 +209,10 @@ return count; } + /** Reads the default checkers. + * @throws SAXException In case of XML issues when reading the default checkers. + * @throws IOException In case of I/O problems when reading the default checkers. + */ private void readDefaultCheckers() throws SAXException, IOException { final Enumeration<URL> checkers = ArchStat.class.getClassLoader().getResources("net/sf/japi/archstat/Checker.xml"); while (checkers.hasMoreElements()) { @@ -198,12 +220,16 @@ readCheckers(url); } } + + /** Parses the checkers. + * @param doc Document from which to parse the checkers. + */ 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)) { - // TODO improve + // TODO:2009-02-18:christianhujer:Improve. throw new RuntimeException("Duplicate Checker " + check.getName()); } checkers.add(new LineCheck((Element) nl.item(i))); Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java 2009-02-18 05:15:34 UTC (rev 957) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java 2009-02-18 05:37:26 UTC (rev 958) @@ -50,17 +50,23 @@ /** The file (regular file or directory) of this statistic. */ @Nullable private final File file; + /** Number of raw lines. */ private int linesRaw; + /** Number of lines which are not a comment. */ private int linesNoComment; + /** Number of true source lines. */ private int sourceLines; + /** Number of lines which are a comment. */ private int commentLines; + /** The text of the file to which this FileStat applies. */ private CharSequence fileText; - int warnings; + /** Number of warnings that occurred. */ + private int warnings; @SuppressWarnings({"AssignmentToCollectionOrArrayFieldFromParameter"}) FileStat(final List<LineCheck> checkers) { @@ -110,8 +116,8 @@ System.err.println(file + ": " + lineCheck.getMessageType() + ": " + i + " " + lineCheck.getPlural()); } } - if (warnings > 0) { - System.err.println(file + ": " + "warning: " + warnings + " warnings."); + if (getWarnings() > 0) { + System.err.println(file + ": " + "warning: " + getWarnings() + " warnings."); } } void checkLine(final String line, final int lineNumber) { @@ -122,7 +128,7 @@ } } public void incWarning(final LineCheck lineCheck) { - warnings++; + warnings = getWarnings() + 1; final Integer i = checkWarnings.get(lineCheck); checkWarnings.put(lineCheck, i != null ? i + 1 : 1); } @@ -149,7 +155,7 @@ */ public boolean isIgnored(@NotNull final File file) { final String filename = file.getName(); - // TODO:christianhujer:This should be configurable. + // TODO:2009-02-18:christianhujer:This should be configurable. return ".svn".equals(filename); } @@ -162,7 +168,7 @@ linesNoComment += child.linesNoComment; sourceLines += child.sourceLines; commentLines += child.commentLines; - warnings += child.warnings; + warnings = getWarnings() + child.getWarnings(); for (final LineCheck lineCheck : checkers) { final Integer childI = child.checkWarnings.get(lineCheck); if (childI != null) { @@ -204,4 +210,8 @@ } } } + + public int getWarnings() { + return warnings; + } } Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java 2009-02-18 05:15:34 UTC (rev 957) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java 2009-02-18 05:37:26 UTC (rev 958) @@ -98,7 +98,7 @@ * @return The plural name of this check. */ @NotNull public String getPlural() { - return name; // TODO + return name; // TODO:2009-02-18:christianhujer:Implement proper plural support. } /** {@inheritDoc} */ Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java 2009-02-18 05:15:34 UTC (rev 957) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java 2009-02-18 05:37:26 UTC (rev 958) @@ -22,16 +22,20 @@ /** Static access to logging. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class LogSystem { +public final class LogSystem { /** The loggers. */ - private static final Logger[] loggers = { new StreamLogger(System.err) }; + private static final Logger[] LOGGERS = { new StreamLogger(System.err) }; + /** Utility class - do not instanciate. */ + private LogSystem() { + } + /** Logs a single log entry. * @param logEntry LogEntry to log. */ public static void log(@NotNull final LogEntry logEntry) { - for (final Logger logger : loggers) { + for (final Logger logger : LOGGERS) { logger.log(logEntry); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-03-02 02:22:23
|
Revision: 1249 http://japi.svn.sourceforge.net/japi/?rev=1249&view=rev Author: christianhujer Date: 2009-03-02 01:32:35 +0000 (Mon, 02 Mar 2009) Log Message: ----------- Add @since information for classes and packages. Modified Paths: -------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogEntry.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/Logger.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/MessageType.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/StreamLogger.java Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-03-02 01:32:13 UTC (rev 1248) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-03-02 01:32:35 UTC (rev 1249) @@ -40,6 +40,7 @@ /** A Command for performing recursive source code file statistics. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 */ public class ArchStat extends BasicCommand { Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java 2009-03-02 01:32:13 UTC (rev 1248) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java 2009-03-02 01:32:35 UTC (rev 1249) @@ -29,6 +29,7 @@ /** Per-File statistics. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 */ public class FileStat { Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java 2009-03-02 01:32:13 UTC (rev 1248) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java 2009-03-02 01:32:35 UTC (rev 1249) @@ -26,6 +26,7 @@ /** A Line-based Check. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 */ public class LineCheck { Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogEntry.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogEntry.java 2009-03-02 01:32:13 UTC (rev 1248) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogEntry.java 2009-03-02 01:32:35 UTC (rev 1249) @@ -24,6 +24,7 @@ /** A LogEntry represents an atomic ArchStat information. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 */ public class LogEntry { Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java 2009-03-02 01:32:13 UTC (rev 1248) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java 2009-03-02 01:32:35 UTC (rev 1249) @@ -21,6 +21,7 @@ /** Static access to logging. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 */ public final class LogSystem { Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/Logger.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/Logger.java 2009-03-02 01:32:13 UTC (rev 1248) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/Logger.java 2009-03-02 01:32:35 UTC (rev 1249) @@ -21,6 +21,7 @@ /** Loggers log LogEntries. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 */ public interface Logger { Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/MessageType.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/MessageType.java 2009-03-02 01:32:13 UTC (rev 1248) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/MessageType.java 2009-03-02 01:32:35 UTC (rev 1249) @@ -21,6 +21,7 @@ /** A MessageType. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 */ public enum MessageType { Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/StreamLogger.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/StreamLogger.java 2009-03-02 01:32:13 UTC (rev 1248) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/StreamLogger.java 2009-03-02 01:32:35 UTC (rev 1249) @@ -22,6 +22,7 @@ /** The StreamLogger is a Logger for LogEntries that logs to the specified Stream. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 */ public class StreamLogger implements Logger { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <chr...@us...> - 2010-04-11 11:06:54
|
Revision: 1405 http://japi.svn.sourceforge.net/japi/?rev=1405&view=rev Author: christianhujer Date: 2010-04-11 11:06:48 +0000 (Sun, 11 Apr 2010) Log Message: ----------- Move the logging classes to a package of their own. Modified Paths: -------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/RegexLineCheck.java Added Paths: ----------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/ tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/LogEntry.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/LogSystem.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/Logger.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/StreamLogger.java Removed Paths: ------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogEntry.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/Logger.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/StreamLogger.java Deleted: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogEntry.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogEntry.java 2010-04-11 10:44:37 UTC (rev 1404) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogEntry.java 2010-04-11 11:06:48 UTC (rev 1405) @@ -1,149 +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.io.File; -import java.util.Formatter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** A LogEntry represents an atomic ArchStat information. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @since 0.1 - */ -public class LogEntry { - - /** The File for which this LogEntry is being logged. */ - private final File file; - - /** The line in {@link #file} for which this LogEntry is being logged. - * Maybe <code>null</code> if the LogEntry does not apply to a particular line. - */ - @Nullable private final String line; - - /** The lineNumber in {@link #file} for which this LogEntry is being logged. - * Maybe <code>null</code> if the LogEntry does not apply to a particular lineNumber. - * The line number is the user line, the first line is 1. - */ - @Nullable private final Integer lineNumber; - - /** The column in {@link #file} {@link #lineNumber} for which this LogEntry is being logged. - * Maybe <code>null</code> if the LogEntry does not apply to a particular column. - * The column is the user column, the first column is 1. - */ - @Nullable private final Integer column; - - /** The MessageType for this LogEntry. */ - @NotNull private final MessageType messageType; - - /** The message ID of this type of log entry. */ - @NotNull private final String messageId; - - /** The message of this log entry. */ - @NotNull private final String message; - - /** Creates a LogEntry. - * @param file File for which this LogEntry is being logged. - * @param line Line in <var>file</var> or <code>null</code>. - * @param lineNumber Line number in <var>file</var> or <code>null</code> (user line, first line is 1). - * @param column Column in <var>lineNumber</var> or <code>null</code> (user column, first column is 1). - * @param messageType Message Type. - * @param messageId Message ID. - * @param message The message. - */ - public LogEntry(final File file, @Nullable final String line, @Nullable final Integer lineNumber, @Nullable final Integer column, @NotNull final MessageType messageType, @NotNull final String messageId, @NotNull final String message) { - this.file = file; - this.line = removeEOL(line); - this.lineNumber = lineNumber; - this.column = column; - this.messageType = messageType; - this.messageId = messageId; - this.message = message; - } - - /** Returns a String with any trailing end of line characters removed. - * Trailing whitespace other than EOL characters are not removed. - * This method currently treats LF and CR as EOL characters. - * @param line Line from which to remove trailing end of line characters, maybe <code>null</code> - * @return The line with trailing end of line characters removed. - */ - private static String removeEOL(@Nullable final String line) { - if (line != null) { - return line.replaceAll("[\n\r]+$", ""); - } - return line; - } - - /** Creates a LogEntry. - * @param file File for which this LogEntry is being logged. - * @param messageType Message Type. - * @param messageId Message ID. - * @param message The message. - */ - public LogEntry(final File file, @NotNull final MessageType messageType, @NotNull final String messageId, @NotNull final String message) { - this(file, null, null, null, messageType, messageId, message); - } - - /** Returns the file for which this LogEntry was created. - * @return The file for which this LogEntry was created. - */ - public File getFile() { - return file; - } - - /** Returns the lineNumber for which this LogEntry was created. - * @return The lineNumber number or <code>null</code> in case it's not applicable. - */ - @Nullable public Integer getLineNumber() { - return lineNumber; - } - - /** Returns the column for which this LogEntry was created. - * @return The column number or <code>null</code> in case it's not applicable. - */ - @Nullable public Integer getColumn() { - return column; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return toString(new Formatter()).toString(); - } - - /** Formats this LogEntry to the specified formatter. - * @param out Formatter to log to. - * @return <var>out</var> for convenience. - */ - public Formatter toString(@NotNull final Formatter out) { - if (lineNumber != null && column != null) { - out.format("%s:%s:%s: %s: (%s): %s", file, lineNumber, column, messageType, messageId, message); - if (line != null) { - out.format("%n%s%n", line); - for (int i = 1; i < column; i++) { - out.format("-"); - } - out.format("^%n"); - } - } else if (lineNumber != null) { - out.format("%s:%s: %s: (%s): %s", file, lineNumber, messageType, messageId, message); - } else { - out.format("%s: %s: (%s): %s", file, messageType, messageId, message); - } - return out; - } -} Deleted: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java 2010-04-11 10:44:37 UTC (rev 1404) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java 2010-04-11 11:06:48 UTC (rev 1405) @@ -1,43 +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 org.jetbrains.annotations.NotNull; - -/** Static access to logging. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @since 0.1 - */ -public final class LogSystem { - - /** The loggers. */ - private static final Logger[] LOGGERS = { new StreamLogger(System.err) }; - - /** Utility class - do not instanciate. */ - private LogSystem() { - } - - /** Logs a single log entry. - * @param logEntry LogEntry to log. - */ - public static void log(@NotNull final LogEntry logEntry) { - for (final Logger logger : LOGGERS) { - logger.log(logEntry); - } - } -} Deleted: tools/archStat/trunk/src/prj/net/sf/japi/archstat/Logger.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/Logger.java 2010-04-11 10:44:37 UTC (rev 1404) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/Logger.java 2010-04-11 11:06:48 UTC (rev 1405) @@ -1,32 +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 org.jetbrains.annotations.NotNull; - -/** Loggers log LogEntries. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @since 0.1 - */ -public interface Logger { - - /** Logs a LogEntry. - * @param logEntry LogEntry to log. - */ - void log(@NotNull LogEntry logEntry); -} Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/RegexLineCheck.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/RegexLineCheck.java 2010-04-11 10:44:37 UTC (rev 1404) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/RegexLineCheck.java 2010-04-11 11:06:48 UTC (rev 1405) @@ -23,6 +23,8 @@ import org.w3c.dom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import net.sf.japi.archstat.log.LogEntry; +import net.sf.japi.archstat.log.LogSystem; /** A Line-based Check. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> Deleted: tools/archStat/trunk/src/prj/net/sf/japi/archstat/StreamLogger.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/StreamLogger.java 2010-04-11 10:44:37 UTC (rev 1404) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/StreamLogger.java 2010-04-11 11:06:48 UTC (rev 1405) @@ -1,44 +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.Formatter; -import org.jetbrains.annotations.NotNull; - -/** The StreamLogger is a Logger for LogEntries that logs to the specified Stream. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @since 0.1 - */ -public class StreamLogger implements Logger { - - /** The Stream for logging. */ - @NotNull - private final Formatter out; - - /** Creates a StreamLogger. - * @param out Stream for logging. - */ - public StreamLogger(@NotNull final Appendable out) { - this.out = new Formatter(out); - } - - /** {@inheritDoc} */ - public void log(@NotNull final LogEntry logEntry) { - out.format("%s%n", logEntry); - } -} Copied: tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/LogEntry.java (from rev 1404, tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogEntry.java) =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/LogEntry.java (rev 0) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/LogEntry.java 2010-04-11 11:06:48 UTC (rev 1405) @@ -0,0 +1,150 @@ +/* + * 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.log; + +import java.io.File; +import java.util.Formatter; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import net.sf.japi.archstat.MessageType; + +/** A LogEntry represents an atomic ArchStat information. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 + */ +public class LogEntry { + + /** The File for which this LogEntry is being logged. */ + private final File file; + + /** The line in {@link #file} for which this LogEntry is being logged. + * Maybe <code>null</code> if the LogEntry does not apply to a particular line. + */ + @Nullable private final String line; + + /** The lineNumber in {@link #file} for which this LogEntry is being logged. + * Maybe <code>null</code> if the LogEntry does not apply to a particular lineNumber. + * The line number is the user line, the first line is 1. + */ + @Nullable private final Integer lineNumber; + + /** The column in {@link #file} {@link #lineNumber} for which this LogEntry is being logged. + * Maybe <code>null</code> if the LogEntry does not apply to a particular column. + * The column is the user column, the first column is 1. + */ + @Nullable private final Integer column; + + /** The MessageType for this LogEntry. */ + @NotNull private final MessageType messageType; + + /** The message ID of this type of log entry. */ + @NotNull private final String messageId; + + /** The message of this log entry. */ + @NotNull private final String message; + + /** Creates a LogEntry. + * @param file File for which this LogEntry is being logged. + * @param line Line in <var>file</var> or <code>null</code>. + * @param lineNumber Line number in <var>file</var> or <code>null</code> (user line, first line is 1). + * @param column Column in <var>lineNumber</var> or <code>null</code> (user column, first column is 1). + * @param messageType Message Type. + * @param messageId Message ID. + * @param message The message. + */ + public LogEntry(final File file, @Nullable final String line, @Nullable final Integer lineNumber, @Nullable final Integer column, @NotNull final MessageType messageType, @NotNull final String messageId, @NotNull final String message) { + this.file = file; + this.line = removeEOL(line); + this.lineNumber = lineNumber; + this.column = column; + this.messageType = messageType; + this.messageId = messageId; + this.message = message; + } + + /** Returns a String with any trailing end of line characters removed. + * Trailing whitespace other than EOL characters are not removed. + * This method currently treats LF and CR as EOL characters. + * @param line Line from which to remove trailing end of line characters, maybe <code>null</code> + * @return The line with trailing end of line characters removed. + */ + private static String removeEOL(@Nullable final String line) { + if (line != null) { + return line.replaceAll("[\n\r]+$", ""); + } + return line; + } + + /** Creates a LogEntry. + * @param file File for which this LogEntry is being logged. + * @param messageType Message Type. + * @param messageId Message ID. + * @param message The message. + */ + public LogEntry(final File file, @NotNull final MessageType messageType, @NotNull final String messageId, @NotNull final String message) { + this(file, null, null, null, messageType, messageId, message); + } + + /** Returns the file for which this LogEntry was created. + * @return The file for which this LogEntry was created. + */ + public File getFile() { + return file; + } + + /** Returns the lineNumber for which this LogEntry was created. + * @return The lineNumber number or <code>null</code> in case it's not applicable. + */ + @Nullable public Integer getLineNumber() { + return lineNumber; + } + + /** Returns the column for which this LogEntry was created. + * @return The column number or <code>null</code> in case it's not applicable. + */ + @Nullable public Integer getColumn() { + return column; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return toString(new Formatter()).toString(); + } + + /** Formats this LogEntry to the specified formatter. + * @param out Formatter to log to. + * @return <var>out</var> for convenience. + */ + public Formatter toString(@NotNull final Formatter out) { + if (lineNumber != null && column != null) { + out.format("%s:%s:%s: %s: (%s): %s", file, lineNumber, column, messageType, messageId, message); + if (line != null) { + out.format("%n%s%n", line); + for (int i = 1; i < column; i++) { + out.format("-"); + } + out.format("^%n"); + } + } else if (lineNumber != null) { + out.format("%s:%s: %s: (%s): %s", file, lineNumber, messageType, messageId, message); + } else { + out.format("%s: %s: (%s): %s", file, messageType, messageId, message); + } + return out; + } +} Property changes on: tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/LogEntry.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/LogSystem.java (from rev 1404, tools/archStat/trunk/src/prj/net/sf/japi/archstat/LogSystem.java) =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/LogSystem.java (rev 0) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/LogSystem.java 2010-04-11 11:06:48 UTC (rev 1405) @@ -0,0 +1,43 @@ +/* + * 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.log; + +import org.jetbrains.annotations.NotNull; + +/** Static access to logging. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 + */ +public final class LogSystem { + + /** The loggers. */ + private static final Logger[] LOGGERS = { new StreamLogger(System.err) }; + + /** Utility class - do not instanciate. */ + private LogSystem() { + } + + /** Logs a single log entry. + * @param logEntry LogEntry to log. + */ + public static void log(@NotNull final LogEntry logEntry) { + for (final Logger logger : LOGGERS) { + logger.log(logEntry); + } + } +} Property changes on: tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/LogSystem.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/Logger.java (from rev 1404, tools/archStat/trunk/src/prj/net/sf/japi/archstat/Logger.java) =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/Logger.java (rev 0) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/Logger.java 2010-04-11 11:06:48 UTC (rev 1405) @@ -0,0 +1,32 @@ +/* + * 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.log; + +import org.jetbrains.annotations.NotNull; + +/** Loggers log LogEntries. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 + */ +public interface Logger { + + /** Logs a LogEntry. + * @param logEntry LogEntry to log. + */ + void log(@NotNull LogEntry logEntry); +} Property changes on: tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/Logger.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/StreamLogger.java (from rev 1404, tools/archStat/trunk/src/prj/net/sf/japi/archstat/StreamLogger.java) =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/StreamLogger.java (rev 0) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/StreamLogger.java 2010-04-11 11:06:48 UTC (rev 1405) @@ -0,0 +1,44 @@ +/* + * 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.log; + +import java.util.Formatter; +import org.jetbrains.annotations.NotNull; + +/** The StreamLogger is a Logger for LogEntries that logs to the specified Stream. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @since 0.1 + */ +public class StreamLogger implements Logger { + + /** The Stream for logging. */ + @NotNull + private final Formatter out; + + /** Creates a StreamLogger. + * @param out Stream for logging. + */ + public StreamLogger(@NotNull final Appendable out) { + this.out = new Formatter(out); + } + + /** {@inheritDoc} */ + public void log(@NotNull final LogEntry logEntry) { + out.format("%s%n", logEntry); + } +} Property changes on: tools/archStat/trunk/src/prj/net/sf/japi/archstat/log/StreamLogger.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. |
From: <chr...@us...> - 2009-10-05 23:51:09
|
Revision: 1390 http://japi.svn.sourceforge.net/japi/?rev=1390&view=rev Author: christianhujer Date: 2009-10-05 23:50:55 +0000 (Mon, 05 Oct 2009) Log Message: ----------- Fix some IntelliJ IDEA warnings. Modified Paths: -------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java 2009-10-05 00:36:09 UTC (rev 1389) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/FileStat.java 2009-10-05 23:50:55 UTC (rev 1390) @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,7 +44,7 @@ private final Map<File, FileStat> children = new HashMap<File, FileStat>(); /** The list of errors that occurred. */ - private final List<Throwable> errors = new ArrayList<Throwable>(); + private final Collection<Throwable> errors = new ArrayList<Throwable>(); /** The title of this statistic. */ private final String title; Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java 2009-10-05 00:36:09 UTC (rev 1389) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/LineCheck.java 2009-10-05 23:50:55 UTC (rev 1390) @@ -72,9 +72,9 @@ */ boolean hasProblem(@NotNull final File file, @NotNull final String line, final int lineNumber) { boolean ret = false; - final Matcher m = regex.matcher(line); - if (m.find()) { - final int column = m.start(); + 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)); } @@ -104,8 +104,8 @@ /** {@inheritDoc} */ @Override - public boolean equals(@Nullable final Object o) { - return o != null && o instanceof LineCheck && ((LineCheck) o).name.equals(name); + public boolean equals(@Nullable final Object obj) { + return obj != null && obj instanceof LineCheck && ((LineCheck) obj).name.equals(name); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |