1
/* Copyright (c) 2007 SNAP Innovation GmbH
3
* BLOB Streaming for MySQL
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
package org.blobstreaming.lib;
33
* Index return is 0 for the first position in the string.
36
public static int locate(String from, String search, int count)
44
i = from.lastIndexOf(search, i-1);
53
i = from.indexOf(search, i+1);
62
public static int locate(String from, String search)
64
return locate(from, search, 1);
67
public static String left(String from, String search, int count)
69
int x = locate(from, search, count);
76
return from.substring(0, x);
79
public static String left(String from, String search)
81
return left(from, search, 1);
84
public static String right(String from, String search, int count)
86
int x = locate(from, search, count);
93
return from.substring(x+search.length());
96
public static String right(String from, String search)
98
return right(from, search, 1);
102
* Should trim CR and LF as well.
104
public static String trim(String s)
109
public static String substr(String s, int offset, int len)
111
return s.substring(offset, offset+len);
114
public static boolean listContains(String list, String val)
119
item = trim(left(list, ","));
120
if (item.equals(val))
122
list = trim(right(list, ","));
128
public static String replaceAll(String string, String replace, String with)
134
result = new StringBuffer();
135
while (locate(string, replace) >= 0) {
136
result.append(left(string, replace));
138
string = right(string, replace);
140
result.append(string);
141
return result.toString();
144
public static String base64encode(String value, int line_size)
149
public static String base64encode(String value)
151
return base64encode(value, 76);
154
public static String base64decode(String value)