19 package org.turro.contacts.util;
22 import java.io.IOException;
24 import java.util.Properties;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import org.turro.string.Strings;
28 import org.turro.elephant.context.ElephantContext;
29 import org.turro.elephant.impl.util.FileUtil;
37 public static String
getType(String value) {
38 for(Map.Entry entry: getProperties().entrySet()) {
39 if(matchValue((String) entry.getValue(), value)) {
40 return (String) entry.getKey();
53 private static Properties properties;
55 private static Properties getProperties() {
56 if(properties ==
null) {
59 properties =
new Properties();
60 properties.load(FileUtil.getBufferedFile(file));
61 }
catch (IOException ex) {
62 Logger.getLogger(TypeByValues.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
68 private static boolean matchValue(String values, String value) {
69 if(!Strings.isBlank(values)) {
70 return values.toLowerCase().matches(
".*(,|^)" + value.toLowerCase() +
"(,|$).*");
static String getRealPath(String path)