OSDN Git Service

1ecad6133125c32d48b59e95c221537640cc5818
[filelock/repo.git] / filelock / src / main / java / jp / sourceforge / filelock / ConsoleMain.java
1 /*\r
2  * Copyright (C) 2007 uguu at users.sourceforge.jp, All Rights Reserved.\r
3  *\r
4  * Redistribution and use in source and binary forms, with or without\r
5  * modification, are permitted provided that the following conditions\r
6  * are met:\r
7  *\r
8  *    1. Redistributions of source code must retain the above copyright\r
9  *       notice, this list of conditions and the following disclaimer.\r
10  *\r
11  *    2. Redistributions in binary form must reproduce the above copyright\r
12  *       notice, this list of conditions and the following disclaimer in the\r
13  *       documentation and/or other materials provided with the distribution.\r
14  *\r
15  *    3. Neither the name of Clarkware Consulting, Inc. nor the names of its\r
16  *       contributors may be used to endorse or promote products derived\r
17  *       from this software without prior written permission. For written\r
18  *       permission, please contact clarkware@clarkware.com.\r
19  *\r
20  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\r
21  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
22  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL\r
23  * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
26  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
28  * NEGLIGENCE OR OTHERWISE) ARISING IN  ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
29  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
30  */\r
31 \r
32 package jp.sourceforge.filelock;\r
33 \r
34 import java.io.IOException;\r
35 import java.util.Map;\r
36 import java.util.TreeMap;\r
37 \r
38 /**\r
39  * <p>\r
40  * アプリケーションのエントリーポイントです。\r
41  * </p>\r
42  * \r
43  * @author $Author$\r
44  * @version $Rev$ $Date$\r
45  */\r
46 public final class ConsoleMain {\r
47 \r
48     private ConsoleMain() {\r
49         throw new UnsupportedOperationException();\r
50     }\r
51 \r
52     /**\r
53      * <p>\r
54      * アプリケーションのエントリーポイントです。\r
55      * </p>\r
56      * \r
57      * @param args\r
58      *            アプリケーション引数。\r
59      * @throws IOException\r
60      *             失敗した場合。\r
61      */\r
62     public static void main(String[] args) throws IOException {\r
63         FileLockUtil flu = new FileLockUtil(args);\r
64 \r
65         Map<String, Boolean> lockStateMap = new TreeMap<String, Boolean>();\r
66         for (String path : flu.lockFiles()) {\r
67             lockStateMap.put(path, true);\r
68         }\r
69         for (String path : flu.lockFailFiles()) {\r
70             lockStateMap.put(path, false);\r
71         }\r
72 \r
73         for (Map.Entry<String, Boolean> entry : lockStateMap.entrySet()) {\r
74             if (entry.getValue()) {\r
75                 System.out.println("LOCK " + entry.getKey());\r
76             } else {\r
77                 System.out.println("FAIL " + entry.getKey());\r
78             }\r
79         }\r
80 \r
81         System.in.read();\r
82     }\r
83 \r
84 }\r