ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/cvslib ChangeLogParser.java
Date Mon, 06 Dec 2004 17:35:42 GMT
peterreilly    2004/12/06 09:35:42

  Modified:    src/main/org/apache/tools/ant/taskdefs/cvslib
                        ChangeLogParser.java
  Log:
  checkstyle changes
  Obtained from: Kevin Jackson
  
  Revision  Changes    Path
  1.28      +61 -56    ant/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java
  
  Index: ChangeLogParser.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ChangeLogParser.java	9 Mar 2004 16:48:14 -0000	1.27
  +++ ChangeLogParser.java	6 Dec 2004 17:35:42 -0000	1.28
  @@ -37,35 +37,35 @@
       private static final int GET_PREVIOUS_REV = 5;
   
       /** input format for dates read in from cvs log */
  -    private static final SimpleDateFormat c_inputDate
  +    private static final SimpleDateFormat INPUT_DATE
           = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
   
       static {
           TimeZone utc = TimeZone.getTimeZone("UTC");
  -        c_inputDate.setTimeZone(utc);
  +        INPUT_DATE.setTimeZone(utc);
       }
   
       //The following is data used while processing stdout of CVS command
  -    private String m_file;
  -    private String m_date;
  -    private String m_author;
  -    private String m_comment;
  -    private String m_revision;
  -    private String m_previousRevision;
  +    private String file;
  +    private String date;
  +    private String author;
  +    private String comment;
  +    private String revision;
  +    private String previousRevision;
   
  -    private int m_status = GET_FILE;
  +    private int status = GET_FILE;
   
       /** rcs entries */
  -    private final Hashtable m_entries = new Hashtable();
  +    private final Hashtable entries = new Hashtable();
   
       /**
        * Get a list of rcs entries as an array.
        *
        * @return a list of rcs entries as an array
        */
  -    CVSEntry[] getEntrySetAsArray() {
  -        final CVSEntry[] array = new CVSEntry[ m_entries.size() ];
  -        Enumeration e = m_entries.elements();
  +    public CVSEntry[] getEntrySetAsArray() {
  +        final CVSEntry[] array = new CVSEntry[ entries.size() ];
  +        Enumeration e = entries.elements();
           int i = 0;
           while (e.hasMoreElements()) {
               array[i++] = (CVSEntry) e.nextElement();
  @@ -76,9 +76,10 @@
       /**
        * Receive notification about the process writing
        * to standard output.
  +     * @param line the line to process
        */
       public void stdout(final String line) {
  -        switch(m_status) {
  +        switch(status) {
               case GET_FILE:
                   // make sure attributes are reset when
                   // working on a 'new' file.
  @@ -100,6 +101,10 @@
               case GET_PREVIOUS_REV:
                   processGetPreviousRevision(line);
                   break;
  +
  +            default:
  +                // Do nothing
  +                break;
           }
       }
   
  @@ -110,114 +115,115 @@
        */
       private void processComment(final String line) {
           final String lineSeparator = System.getProperty("line.separator");
  -        if (line.equals("============================================================================="))
{
  +        if (line.equals(
  +                "============================================================================="))
{
               //We have ended changelog for that particular file
               //so we can save it
               final int end
  -                = m_comment.length() - lineSeparator.length(); //was -1
  -            m_comment = m_comment.substring(0, end);
  +                = comment.length() - lineSeparator.length(); //was -1
  +            comment = comment.substring(0, end);
               saveEntry();
  -            m_status = GET_FILE;
  +            status = GET_FILE;
           } else if (line.equals("----------------------------")) {
               final int end
  -                = m_comment.length() - lineSeparator.length(); //was -1
  -            m_comment = m_comment.substring(0, end);
  -            m_status = GET_PREVIOUS_REV;
  +                = comment.length() - lineSeparator.length(); //was -1
  +            comment = comment.substring(0, end);
  +            status = GET_PREVIOUS_REV;
           } else {
  -            m_comment += line + lineSeparator;
  +            comment += line + lineSeparator;
           }
       }
   
       /**
        * Process a line while in "GET_FILE" state.
        *
  -     * @param line the line
  +     * @param line the line to process
        */
       private void processFile(final String line) {
           if (line.startsWith("Working file:")) {
  -            m_file = line.substring(14, line.length());
  -            m_status = GET_REVISION;
  +            file = line.substring(14, line.length());
  +            status = GET_REVISION;
           }
       }
   
       /**
        * Process a line while in "REVISION" state.
        *
  -     * @param line the line
  +     * @param line the line to process
        */
       private void processRevision(final String line) {
           if (line.startsWith("revision")) {
  -            m_revision = line.substring(9);
  -            m_status = GET_DATE;
  +            revision = line.substring(9);
  +            status = GET_DATE;
           } else if (line.startsWith("======")) {
               //There was no revisions in this changelog
               //entry so lets move unto next file
  -            m_status = GET_FILE;
  +            status = GET_FILE;
           }
       }
   
       /**
        * Process a line while in "DATE" state.
        *
  -     * @param line the line
  +     * @param line the line to process
        */
       private void processDate(final String line) {
           if (line.startsWith("date:")) {
  -            m_date = line.substring(6, 25);
  +            date = line.substring(6, 25);
               String lineData = line.substring(line.indexOf(";") + 1);
  -            m_author = lineData.substring(10, lineData.indexOf(";"));
  +            author = lineData.substring(10, lineData.indexOf(";"));
   
  -            m_status = GET_COMMENT;
  +            status = GET_COMMENT;
   
               //Reset comment to empty here as we can accumulate multiple lines
               //in the processComment method
  -            m_comment = "";
  +            comment = "";
           }
       }
   
       /**
        * Process a line while in "GET_PREVIOUS_REVISION" state.
        *
  -     * @param line the line
  +     * @param line the line to process
        */
       private void processGetPreviousRevision(final String line) {
           if (!line.startsWith("revision")) {
               throw new IllegalStateException("Unexpected line from CVS: "
                   + line);
           }
  -        m_previousRevision = line.substring(9);
  +        previousRevision = line.substring(9);
   
           saveEntry();
   
  -        m_revision = m_previousRevision;
  -        m_status = GET_DATE;
  +        revision = previousRevision;
  +        status = GET_DATE;
       }
   
       /**
        * Utility method that saves the current entry.
        */
       private void saveEntry() {
  -        final String entryKey = m_date + m_author + m_comment;
  +        final String entryKey = date + author + comment;
           CVSEntry entry;
  -        if (!m_entries.containsKey(entryKey)) {
  -            entry = new CVSEntry(parseDate(m_date), m_author, m_comment);
  -            m_entries.put(entryKey, entry);
  +        if (!entries.containsKey(entryKey)) {
  +            entry = new CVSEntry(parseDate(date), author, comment);
  +            entries.put(entryKey, entry);
           } else {
  -            entry = (CVSEntry) m_entries.get(entryKey);
  +            entry = (CVSEntry) entries.get(entryKey);
           }
   
  -        entry.addFile(m_file, m_revision, m_previousRevision);
  +        entry.addFile(file, revision, previousRevision);
       }
   
       /**
        * Parse date out from expected format.
        *
  -     * @param date the string holding dat
  +     * @param date the string holding date
        * @return the date object or null if unknown date format
        */
       private Date parseDate(final String date) {
           try {
  -            return c_inputDate.parse(date);
  +            return INPUT_DATE.parse(date);
           } catch (ParseException e) {
               //final String message = REZ.getString( "changelog.bat-date.error", date );
               //getContext().error( message );
  @@ -226,15 +232,14 @@
       }
   
       /**
  -     * reset all internal attributes except status.
  +     * Reset all internal attributes except status.
        */
  -    private void reset() {
  -        m_file = null;
  -        m_date = null;
  -        m_author = null;
  -        m_comment = null;
  -        m_revision = null;
  -        m_previousRevision = null;
  +    public void reset() {
  +        this.file = null;
  +        this.date = null;
  +        this.author = null;
  +        this.comment = null;
  +        this.revision = null;
  +        this.previousRevision = null;
       }
  -
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message