KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > cvsclient > request > NotifyRequest


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 package org.netbeans.lib.cvsclient.request;
20
21 import java.io.*;
22 import java.net.*;
23 import java.text.*;
24 import java.util.*;
25
26 /**
27  * Notify Entry.java
28  * E Sun Nov 11 10:25:40 2001 GMT worker E:\test\admin EUC
29  *
30  * @author Thomas Singer
31  * @version Nov 14, 2001
32  */

33 public class NotifyRequest extends Request {
34     // Constants ==============================================================
35

36     private static final DateFormat DATE_FORMAT;
37     private static final String JavaDoc HOST_NAME;
38
39     static {
40         DATE_FORMAT = new SimpleDateFormat("EEE MMM dd hh:mm:ss yyyy z", Locale.US);
41
42         // detect host name
43
String JavaDoc hostName = "";
44         try {
45             hostName = InetAddress.getLocalHost().getHostName();
46         }
47         catch (Exception JavaDoc ex) {
48             ex.printStackTrace();
49         }
50         HOST_NAME = hostName;
51     }
52
53     // Fields =================================================================
54

55     private final String JavaDoc request;
56
57     // Setup ==================================================================
58

59     /**
60      * Creates an NotifyRequest for the specified file.
61      * If the specified file is null, a IllegalArgumentException is thrown.
62      */

63     public NotifyRequest(File file, String JavaDoc command, String JavaDoc parameters) {
64         if (file == null) {
65             throw new IllegalArgumentException JavaDoc("File must not be null!");
66         }
67
68         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
69         buffer.append("Notify "); // NOI18N
70
buffer.append(file.getName());
71         buffer.append('\n');
72         buffer.append(command);
73         buffer.append('\t');
74         buffer.append(DATE_FORMAT.format(new Date()));
75         buffer.append('\t');
76         buffer.append(HOST_NAME);
77         buffer.append('\t');
78         buffer.append(file.getParent());
79         buffer.append('\t');
80         buffer.append(parameters);
81         buffer.append('\n');
82         this.request = buffer.toString();
83     }
84
85     // Implemented ============================================================
86

87     public String JavaDoc getRequestString() {
88         return request;
89     }
90
91     public boolean isResponseExpected() {
92         return false;
93     }
94 }
95
Popular Tags