|
|
|
@ -2,24 +2,32 @@ package info.bukova.isspst;
|
|
|
|
|
|
|
|
|
|
import org.zkoss.util.resource.Labels;
|
|
|
|
|
|
|
|
|
|
public class StringUtils {
|
|
|
|
|
public class StringUtils
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static String nullStr(String str) {
|
|
|
|
|
private static String nullStr(String str)
|
|
|
|
|
{
|
|
|
|
|
return str == null ? "" : str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String not0ToStr(long i) {
|
|
|
|
|
private static String not0ToStr(long i)
|
|
|
|
|
{
|
|
|
|
|
return i == 0 ? "" : String.valueOf(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String localizeDbErr(String sqlError) {
|
|
|
|
|
public static String localizeDbErr(String sqlError)
|
|
|
|
|
{
|
|
|
|
|
String splitMessage[] = sqlError.split("'");
|
|
|
|
|
String message = "";
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < splitMessage.length; i++) {
|
|
|
|
|
if (i % 2 == 0) {
|
|
|
|
|
for (int i = 0; i < splitMessage.length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i % 2 == 0)
|
|
|
|
|
{
|
|
|
|
|
message += getLocalized(splitMessage[i]);
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
message += " '" + splitMessage[i] + "' ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -27,16 +35,20 @@ public class StringUtils {
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String localize(String key) {
|
|
|
|
|
public static String localize(String key)
|
|
|
|
|
{
|
|
|
|
|
return Labels.getLabel(key) == null ? key : Labels.getLabel(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String getLocalized(String str) {
|
|
|
|
|
private static String getLocalized(String str)
|
|
|
|
|
{
|
|
|
|
|
String words[] = str.split(" ");
|
|
|
|
|
String key = "";
|
|
|
|
|
|
|
|
|
|
for (String word: words) {
|
|
|
|
|
if (!word.isEmpty()) {
|
|
|
|
|
for (String word : words)
|
|
|
|
|
{
|
|
|
|
|
if (!word.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
key += word.substring(0, 1).toUpperCase() + word.substring(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -48,7 +60,14 @@ public class StringUtils {
|
|
|
|
|
{
|
|
|
|
|
value = StringUtils.nullStr(value).toLowerCase();
|
|
|
|
|
search = StringUtils.nullStr(search).toLowerCase();
|
|
|
|
|
return value.contains(search);
|
|
|
|
|
return value.startsWith(search);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isIcEqualForFilter(long value, long search)
|
|
|
|
|
{
|
|
|
|
|
String compareValue = StringUtils.not0ToStr(value);
|
|
|
|
|
String searchValue = StringUtils.not0ToStr(search);
|
|
|
|
|
return compareValue.startsWith(searchValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String encodeSpecialChars(String value)
|
|
|
|
|