KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > tool > common > ResUtil


1
2 /*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/
3
4 /*
5  * Enhydra Java Application Server Project
6  *
7  * The contents of this file are subject to the Enhydra Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License on
10  * the Enhydra web site ( http://www.enhydra.org/ ).
11  *
12  * Software distributed under the License is distributed on an "AS IS"
13  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14  * the License for the specific terms governing rights and limitations
15  * under the License.
16  *
17  * The Initial Developer of the Enhydra Application Server is Lutris
18  * Technologies, Inc. The Enhydra Application Server and portions created
19  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
20  * All Rights Reserved.
21  *
22  * Contributor(s):
23  *
24  */

25 package org.enhydra.tool.common;
26 import java.io.File JavaDoc;
27 import java.text.MessageFormat JavaDoc;
28 public class ResUtil {
29     public ResUtil() {}
30
31     public static String JavaDoc format(String JavaDoc message, String JavaDoc arg) {
32         String JavaDoc out = new String JavaDoc();
33         String JavaDoc[] args = new String JavaDoc[1];
34
35         args[0] = arg;
36         out = MessageFormat.format(message, (Object JavaDoc[])args);
37         return out;
38     }
39
40     public static String JavaDoc format(String JavaDoc message, int arg) {
41         return ResUtil.format(message, (new String JavaDoc()) + arg);
42     }
43
44     public static String JavaDoc format(String JavaDoc message, boolean b) {
45         Boolean JavaDoc bool = new Boolean JavaDoc(b);
46
47         return ResUtil.format(message, bool.toString());
48     }
49
50     public static String JavaDoc format(String JavaDoc message, String JavaDoc arg1, String JavaDoc arg2) {
51         String JavaDoc out = new String JavaDoc();
52         String JavaDoc[] args = new String JavaDoc[2];
53
54         args[0] = arg1;
55         args[1] = arg2;
56         out = MessageFormat.format(message, (Object JavaDoc [])args);
57         return out;
58     }
59
60     public static String JavaDoc format(String JavaDoc message, File JavaDoc file) {
61         String JavaDoc out = new String JavaDoc();
62         PathHandle handle = PathHandle.createPathHandle(file);
63
64         out = ResUtil.format(message, handle.getPath());
65         return out;
66     }
67
68     public static String JavaDoc format(String JavaDoc message, PathHandle handle) {
69         return ResUtil.format(message, handle.getPath());
70     }
71
72     public static String JavaDoc format(String JavaDoc message, String JavaDoc string, File JavaDoc file) {
73         String JavaDoc out = new String JavaDoc();
74         PathHandle handle = PathHandle.createPathHandle(file);
75
76         out = ResUtil.format(message, string, handle.getPath());
77         return out;
78     }
79
80     public static String JavaDoc format(String JavaDoc message, File JavaDoc f1, File JavaDoc f2) {
81         String JavaDoc out = new String JavaDoc();
82         PathHandle handle1 = PathHandle.createPathHandle(f1);
83         PathHandle handle2 = PathHandle.createPathHandle(f2);
84
85         out = ResUtil.format(message, handle1.getPath(), handle2.getPath());
86         return out;
87     }
88
89     public static String JavaDoc format(String JavaDoc message, File JavaDoc file, int integer) {
90         String JavaDoc out = new String JavaDoc();
91         PathHandle handle = PathHandle.createPathHandle(file);
92         String JavaDoc arg2 = (new String JavaDoc() + integer);
93
94         out = ResUtil.format(message, handle.getPath(), arg2);
95         return out;
96     }
97
98 }
99
Popular Tags