alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 *
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 *
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Ralph Krueger. 
 */

package org.netbeans.modules.changelog;


import java.util.*;
import org.openide.windows.*;
import org.openide.*;

/**
 * prints the processed groups to output window..
 * @author  ralph
 */
public class LogPrinter_Output implements LogPrinter {
    
    private OutputWriter writer;
    private boolean includeSummary;
    
    public LogPrinter_Output() {
         writer = TopManager.getDefault().getStdOut();
    }
    
    public void printHeader(ChangeLogProcessor processor) {
        includeSummary = processor.isIncludeSummary();
        if (processor.isIncludeQueryDescription()) {
            writer.println("Query:");
            if (processor.getDateRange() != null) {
                writer.println("   Date Range:" + processor.getDateRange());
            }
            if (processor.getRevisionRange() != null) {
                writer.println("   Revision Filter:" + processor.getRevisionRange());
            }
            if (processor.getMessageFilter() != null) {
                String messageType = "";
                if (processor.getMessageFilterType() == ChangeLogProcessor.MESSAGE_FILTER_SUBSTRING) {
                    messageType = "Substring";
                } else if (processor.getMessageFilterType() == ChangeLogProcessor.MESSAGE_FILTER_SOME_WORDS) {
                    messageType = "Any of words";
                } else if (processor.getMessageFilterType() == ChangeLogProcessor.MESSAGE_FILTER_ALL_WORDS) {
                    messageType = "All of words";
                } else if (processor.getMessageFilterType() == ChangeLogProcessor.MESSAGE_FILTER_REGEXP) {
                    messageType = "Regular expression";
                }
                writer.println("   Message Filter (" + messageType + "):" + processor.getMessageFilter());
            }
            if (processor.getFileFilter() != null) {
                String fileType = "";
                if (processor.getFileFilterType() == ChangeLogProcessor.FILE_FILTER_SUBSTRING) {
                    fileType = "Substring";
                } else if (processor.getFileFilterType() == ChangeLogProcessor.FILE_FILTER_REGEXP) {
                    fileType = "Regular expression";
                }
                writer.println("   Contained Files Filter (" + fileType + "):" + processor.getFileFilter());
            }
            if (processor.getSortMode() == ChangeLogProcessor.SORT_BY_DATE) {
                writer.print("   Sort: by Date");
            } else if (processor.getSortMode() == ChangeLogProcessor.SORT_BY_USER) {
                writer.print("   Sort: by User");
            }
            if (processor.isDescendingSort()) {
                writer.println(" (Descending)");
            } else {
                writer.println(" (Ascending)");
            }
        }
    }
    
    public void printGroupHeader(RevisionsGroup group) {
          writer.println("--------------------------------------------------");
          writer.println("User: " + group.getUser());
          writer.println("Date: " + group.getStartingDate());
          writer.println("Message:" + group.getMessage());
    }
    
    public void printSingleRevision(LogInfoRevision revision) {
        String repoFileName = revision.getLogInfoHeader().getRepositoryFilename();
        repoFileName = repoFileName.substring(0, repoFileName.length() - 2);
        writer.println("   " + revision.getNumber() + "  " + repoFileName);
    }
    
    public void printGroupFooter(RevisionsGroup group) {
        //do nothing
    }
    
    public void printSummary(SummaryProcessor processor) {
        if (includeSummary) {
            writer.println("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
            writer.println("Summary:");
            writer.println("Number of changes: " + processor.getCommitCount());
            writer.print("Developers: ");
            String[] users = processor.getUserList();
            for (int i = 0; i < users.length; i++) {
                if (i < users.length) {
                    writer.println(users[i] + ", ");
                } else {
                    writer.println(users[i]);
                }
            }
            writer.println();
            String[] mostChanged = processor.getMostChangedFiles();
            writer.println("Most frequently changed files:");
            for (int j = 0; j < mostChanged.length; j++) {
                writer.println(mostChanged[j]);
            }
            writer.println();
            writer.println("Most active developers (based on number of commits):");
            String[] mostActive= processor.getMostActiveUsers();
            for (int k = 0; k < mostActive.length; k++) {
                writer.println(mostActive[k]);
            }
            writer.println();
        }
    }
    
    public void printFooter(ChangeLogProcessor processor) {
        //do nothing
    }
    
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.