KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > nbbuild > utils > cvsutils > CvsEntries


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /************************************************************************
21
22         FILENAME: CvsEntries.java
23
24         AUTHOR: Erica Grevemeyer DATE: Jan 7 11:21:09 PST 2002
25
26 ************************************************************************/

27 package org.netbeans.nbbuild.utils.cvsutils;
28
29 import java.io.*;
30 import java.util.*;
31
32 /** Read a specified CVS/Entries style file,
33  * as Entries & store the collection of Entries
34  * in the passed-in Hashtable. If no 'separator' string
35  * is passed then a 'blankspace' separator is assumed.
36  *
37  * @author Erica Grevemeyer
38  * @version 1.1 Jan 7 11:21:09 PST 200
39  */

40
41 public class CvsEntries {
42
43     private java.util.HashMap JavaDoc<String JavaDoc, Entry> hash = new java.util.HashMap JavaDoc<String JavaDoc, Entry>();
44     private static final String JavaDoc DEFAULT_CVS_ENTRIES_FILENAME = "CVS/Entries";
45
46     // Constructors
47
public CvsEntries(String JavaDoc directoryPath) {
48             this(directoryPath, DEFAULT_CVS_ENTRIES_FILENAME);
49     }
50     
51
52     public CvsEntries(String JavaDoc directoryPath, String JavaDoc fileName) {
53         try {
54             String JavaDoc entriesFile = directoryPath + "/" + fileName;
55             BufferedReader inBuff = new BufferedReader(new FileReader(new File(entriesFile)));
56             Entry e;
57             
58             String JavaDoc line;
59
60             while ((line = inBuff.readLine()) != null) {
61                 e = new Entry(line);
62                 if ( ! e.getFiletype().equals("D") ) {
63                     hash.put(e.getFilename(), e);
64                 }
65             }
66         
67         } catch(IOException e) {
68             System.out.println("Error: " + e.toString());
69         }
70     }
71         
72     public String JavaDoc getRevnoByFileName(String JavaDoc fileName) {
73         Entry e = hash.get(fileName);
74         if (e == null ) {
75             return null;
76         } else {
77             return e.getRevno();
78             }
79     }
80 }
81
Popular Tags