Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.h2spatial / org.gvsig.h2spatial.h2gis132 / org.gvsig.h2spatial.h2gis132.provider / src / main / java / org / gvsig / fmap / dal / store / h2 / functions / Reverseinstr.java @ 46047

History | View | Annotate | Download (1.46 KB)

1 45472 jjdelcerro
/*
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2020 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
 *
19
 * For any additional information, do not hesitate to contact us
20
 * at info AT gvsig.com, or visit our website www.gvsig.com.
21
 */
22
23
package org.gvsig.fmap.dal.store.h2.functions;
24
25 46047 jjdelcerro
import org.apache.commons.lang3.StringUtils;
26 45472 jjdelcerro
27
/**
28
 *
29
 * @author gvSIG Team
30
 */
31 46047 jjdelcerro
public class Reverseinstr {
32 45472 jjdelcerro
33
    public static String getSQL() {
34 46047 jjdelcerro
        return "CREATE ALIAS REVERSE FOR \"org.gvsig.fmap.dal.store.h2.functions.Reverseinstr.reverseinstr\"";
35 45472 jjdelcerro
    }
36
37 46047 jjdelcerro
    public static Object reverseinstr(String string, String substring) {
38
        if( string == null || substring == null ) {
39
            return null;
40
        }
41
        int n = string.lastIndexOf(substring);
42
        if( n<0 ) {
43
            return 0;
44
        }
45
        return n+1;
46 45472 jjdelcerro
    }
47
}