List of usage examples for java.lang String startsWith
public boolean startsWith(String prefix)
From source file:com.textocat.textokit.eval.EvaluationLauncher.java
private static Map<String, String> getPrefixedKeyPairs(Properties props, String prefix) { Map<String, String> result = Maps.newHashMap(); for (String key : props.stringPropertyNames()) { if (key.startsWith(prefix)) { result.put(key.substring(prefix.length()), props.getProperty(key)); }/*from ww w. ja v a 2 s . c o m*/ } return result; }
From source file:org.gytheio.messaging.jackson.JsonClassKeyDeserializer.java
public static Object deserializeKeyToClass(String key) throws IOException, JsonProcessingException { if (!key.startsWith("class ")) { throw new IllegalArgumentException("Invalid key format"); }//from ww w . j ava2 s . c o m String classname = key.replaceFirst("class ", ""); try { return JsonClassKeyDeserializer.class.getClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(e); } }
From source file:info.magnolia.cms.util.PathUtil.java
public static String addLeadingSlash(String path) { if (!path.startsWith("/")) { //$NON-NLS-1$ return "/" + path; //$NON-NLS-1$ }/*from w w w .ja va2 s . c om*/ return path; }
From source file:Main.java
public static String addParam(String key, String value, String srcStr) { if (srcStr == null || srcStr.startsWith(MAP_EMPTY)) { StringBuilder sb = new StringBuilder(); sb.append(MAP_OPEN);//www . j a v a2 s . c o m addEntry(sb, key, value); sb.append(MAP_CLOSE); return sb.toString(); } if (srcStr.startsWith(MAP_OPEN)) { StringBuilder sb = new StringBuilder(); sb.append(MAP_OPEN); addEntry(sb, key, value); sb.append(srcStr.substring(MAP_OPEN.length())); return sb.toString(); } return srcStr; }
From source file:Main.java
public static String unquote(String s, String quote) { if (!TextUtils.isEmpty(s) && !TextUtils.isEmpty(quote)) { if (s.startsWith(quote) && s.endsWith(quote)) { return s.substring(1, s.length() - quote.length()); }/* w ww . j a v a2 s . c o m*/ } return s; }
From source file:cn.guoyukun.spring.web.utils.ServletUtils.java
/** * url?method firstPrefix+lastPrefixes//from w ww.jav a 2 s . c o m * ?url/sample/create ?firstPrefix:/sample lastPrefixed /create * * @param request * @param method * @param firstPrefix * @param lastPrefixes * @return */ public static boolean startWith(HttpServletRequest request, RequestMethod method, String firstPrefix, String... lastPrefixes) { String requestMethod = request.getMethod(); if (!requestMethod.equalsIgnoreCase(method.name())) { return false; } String url = request.getServletPath(); if (!url.startsWith(firstPrefix)) { return false; } if (lastPrefixes.length == 0) { return true; } url = url.substring(firstPrefix.length()); for (String lastPrefix : lastPrefixes) { if (url.startsWith(lastPrefix)) { return true; } } return false; }
From source file:Utils.java
public static String quote(String str) { if (str == null) return str; if (str.length() < 2 || !str.startsWith("\"") || !str.endsWith("\"")) str = "\"" + str + "\""; return str;/*from ww w.jav a2 s .c om*/ }
From source file:Main.java
public static Map<String, Object> getProperties(Object bean) { Map<String, Object> map = new HashMap<String, Object>(); for (Method method : bean.getClass().getMethods()) { String name = method.getName(); if ((name.length() > 3 && name.startsWith("get") || name.length() > 2 && name.startsWith("is")) && Modifier.isPublic(method.getModifiers()) && method.getParameterTypes().length == 0 && method.getDeclaringClass() != Object.class) { int i = name.startsWith("get") ? 3 : 2; String key = name.substring(i, i + 1).toLowerCase() + name.substring(i + 1); try { map.put(key, method.invoke(bean, new Object[0])); } catch (Exception e) { }// w ww. j a v a 2 s . co m } } return map; }
From source file:Main.java
private static String[] lineToStrs(String line) { String[] ret = new String[2]; if ((line != null)) { String[] strs = line.trim().split("\t+"); ret[0] = strs[0].trim();/*from w w w. java 2 s.c om*/ for (int i = 1; i < strs.length; i++) { String str = strs[i].trim(); if (!str.isEmpty()) { if (!str.startsWith("#")) { ret[1] = str; } break; } } } return ret; }
From source file:musiccrawler.validate.Validator.java
public static String validPath(String input) { if (StringUtils.isNotBlank(input)) { if (!input.startsWith(Constant.CharacterSpec.FORWARD_SLASH)) { return Constant.CharacterSpec.FORWARD_SLASH + input; } else if (!input.endsWith(Constant.CharacterSpec.FORWARD_SLASH)) { return input + Constant.CharacterSpec.FORWARD_SLASH; } else {/*from www. ja v a 2 s . c o m*/ return Constant.CharacterSpec.FORWARD_SLASH + input + Constant.CharacterSpec.FORWARD_SLASH; } } return input; }