|
|
@ -2,55 +2,74 @@ package info.bukova.isspst;
|
|
|
|
|
|
|
|
|
|
|
|
import org.zkoss.util.resource.Labels;
|
|
|
|
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;
|
|
|
|
return str == null ? "" : str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String not0ToStr(long i) {
|
|
|
|
private static String not0ToStr(long i)
|
|
|
|
|
|
|
|
{
|
|
|
|
return i == 0 ? "" : String.valueOf(i);
|
|
|
|
return i == 0 ? "" : String.valueOf(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String localizeDbErr(String sqlError) {
|
|
|
|
public static String localizeDbErr(String sqlError)
|
|
|
|
|
|
|
|
{
|
|
|
|
String splitMessage[] = sqlError.split("'");
|
|
|
|
String splitMessage[] = sqlError.split("'");
|
|
|
|
String message = "";
|
|
|
|
String message = "";
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < splitMessage.length; i++) {
|
|
|
|
for (int i = 0; i < splitMessage.length; i++)
|
|
|
|
if (i % 2 == 0) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (i % 2 == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
message += getLocalized(splitMessage[i]);
|
|
|
|
message += getLocalized(splitMessage[i]);
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
message += " '" + splitMessage[i] + "' ";
|
|
|
|
message += " '" + splitMessage[i] + "' ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return message;
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String localize(String key) {
|
|
|
|
public static String localize(String key)
|
|
|
|
|
|
|
|
{
|
|
|
|
return Labels.getLabel(key) == null ? key : Labels.getLabel(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 words[] = str.split(" ");
|
|
|
|
String key = "";
|
|
|
|
String key = "";
|
|
|
|
|
|
|
|
|
|
|
|
for (String word: words) {
|
|
|
|
for (String word : words)
|
|
|
|
if (!word.isEmpty()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!word.isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
key += word.substring(0, 1).toUpperCase() + word.substring(1);
|
|
|
|
key += word.substring(0, 1).toUpperCase() + word.substring(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Labels.getLabel("Db" + key);
|
|
|
|
return Labels.getLabel("Db" + key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean isEqualForFilter(String value, String search)
|
|
|
|
public static boolean isEqualForFilter(String value, String search)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
value = StringUtils.nullStr(value).toLowerCase();
|
|
|
|
value = StringUtils.nullStr(value).toLowerCase();
|
|
|
|
search = StringUtils.nullStr(search).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)
|
|
|
|
public static String encodeSpecialChars(String value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (value != null)
|
|
|
|
if (value != null)
|
|
|
@ -58,7 +77,7 @@ public class StringUtils {
|
|
|
|
value = value.replace("²", "[up]2[/up]");
|
|
|
|
value = value.replace("²", "[up]2[/up]");
|
|
|
|
value = value.replace("³", "[up]3[/up]");
|
|
|
|
value = value.replace("³", "[up]3[/up]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -69,7 +88,7 @@ public class StringUtils {
|
|
|
|
value = value.replace("[up]2[/up]", "²");
|
|
|
|
value = value.replace("[up]2[/up]", "²");
|
|
|
|
value = value.replace("[up]3[/up]", "³");
|
|
|
|
value = value.replace("[up]3[/up]", "³");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|