01: /**
02: * Copyright (C) 2001-2003 France Telecom R&D
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * 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: */package org.objectweb.util.monolog.file;
18:
19: /**
20: *
21: * @author Sebastien Chassande-Barrioz
22: */
23: public class DottedStringTools {
24: public static String getLast(String dottedName) {
25: if (dottedName == null)
26: return null;
27: int pos = dottedName.lastIndexOf('.');
28: if (pos == -1)
29: return dottedName;
30: pos++;
31: if (pos == dottedName.length())
32: return "";
33: return dottedName.substring(pos, dottedName.length());
34: }
35:
36: public static String getEnd(String dottedName) {
37: if (dottedName == null)
38: return null;
39: int pos = dottedName.indexOf('.');
40: if (pos == -1)
41: return dottedName;
42: pos++;
43: if (pos == 0)
44: return "";
45: return dottedName.substring(pos, dottedName.length());
46: }
47:
48: public static String getBegin(String dottedName) {
49: if (dottedName == null)
50: return null;
51: int pos = dottedName.lastIndexOf('.');
52: if (pos == -1)
53: return dottedName;
54: return dottedName.substring(0, pos);
55: }
56:
57: public static String getFirst(String dottedName) {
58: if (dottedName == null)
59: return null;
60: int pos = dottedName.indexOf('.');
61: if (pos == -1)
62: return dottedName;
63: return dottedName.substring(0, pos);
64: }
65: }
|