KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > monolog > file > DottedStringTools


1 /**
2  * Copyright (C) 2001-2003 France Telecom R&D
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package org.objectweb.util.monolog.file;
20
21 /**
22  *
23  * @author Sebastien Chassande-Barrioz
24  */

25 public class DottedStringTools {
26     public static String JavaDoc getLast(String JavaDoc dottedName) {
27         if (dottedName==null)
28             return null;
29         int pos = dottedName.lastIndexOf('.');
30         if (pos == -1)
31             return dottedName;
32         pos++;
33         if (pos==dottedName.length())
34             return "";
35         return dottedName.substring(pos, dottedName.length());
36     }
37
38     public static String JavaDoc getEnd(String JavaDoc dottedName) {
39         if (dottedName==null)
40             return null;
41         int pos = dottedName.indexOf('.');
42         if (pos == -1)
43             return dottedName;
44         pos++;
45         if (pos==0)
46             return "";
47         return dottedName.substring(pos, dottedName.length());
48     }
49
50     public static String JavaDoc getBegin(String JavaDoc dottedName) {
51         if (dottedName==null)
52             return null;
53         int pos = dottedName.lastIndexOf('.');
54         if (pos == -1)
55             return dottedName;
56         return dottedName.substring(0, pos);
57     }
58
59     public static String JavaDoc getFirst(String JavaDoc dottedName) {
60         if (dottedName==null)
61             return null;
62         int pos = dottedName.indexOf('.');
63         if (pos == -1)
64             return dottedName;
65         return dottedName.substring(0, pos);
66     }
67 }
68
Popular Tags