List of usage examples for java.lang String contains
public boolean contains(CharSequence s)
From source file:Main.java
private static String getCaller(String tag) { String caller = "<unknown>"; StackTraceElement[] trace = new Throwable().fillInStackTrace().getStackTrace(); if (trace.length < 6) { return caller; }/* w w w. java2 s . c o m*/ // Walk up the stack looking for the first caller outside of LogUtils. // It will be at least 5 frames up, so start there. for (int i = 5; i < trace.length; i++) { // Class<?> clazz = trace[i].getClass(); String clazzName = trace[i].getClassName(); if (!clazzName.contains("Log")) { String callingClass = clazzName; callingClass = callingClass.substring(callingClass.lastIndexOf('.') + 1); callingClass = callingClass.substring(callingClass.lastIndexOf('$') + 1); caller = callingClass + "." + trace[i].getMethodName(); break; } } return String.format(Locale.US, "[%d/%s] %s %s: %s", Thread.currentThread().getId(), Thread.currentThread().getName(), LOG_PREFIX, tag, caller); }
From source file:com.bazaarvoice.jolt.cardinality.CardinalitySpec.java
public static List<PathElement> parse(String key) { if (key.contains("@")) { return Arrays.<PathElement>asList(new AtPathElement(key)); } else if ("*".equals(key)) { return Arrays.<PathElement>asList(new StarAllPathElement(key)); } else if (key.contains("*")) { if (StringUtils.countMatches(key, "*") == 1) { return Arrays.<PathElement>asList(new StarSinglePathElement(key)); } else {//from ww w.j a v a 2s . c o m return Arrays.<PathElement>asList(new StarRegexPathElement(key)); } } else { return Arrays.<PathElement>asList(new LiteralPathElement(key)); } }
From source file:gov.nih.nci.caintegrator.application.util.SafeHTMLUtil.java
public static String clean(String s) { String clean = Translate.decode(s).replace("<", "").replace(">", ""); if (!clean.contains("description") && !clean.contains("Description")) { clean = StringUtils.replace(clean, "script", ""); }/*from w w w .ja v a 2s . c om*/ clean = StringUtils.replace(clean, "%", ""); clean = StringUtils.replace(clean, "#", ""); clean = StringUtils.replace(clean, ";", ""); clean = StringUtils.replace(clean, "'", ""); clean = StringUtils.replace(clean, "\"", ""); clean = StringUtils.replace(clean, "$", ""); clean = StringUtils.replace(clean, "&", ""); clean = StringUtils.replace(clean, "(", ""); clean = StringUtils.replace(clean, ")", ""); clean = StringUtils.replace(clean, "/", ""); clean = StringUtils.replace(clean, "\\", ""); if (clean.length() == 0) { clean = "unamedQuery"; } return clean; }
From source file:Main.java
public static String[] getMounts(final String path) { try {/*from w w w . j a v a2 s. c o m*/ BufferedReader br = new BufferedReader(new FileReader("/proc/mounts"), 256); String line = null; while ((line = br.readLine()) != null) { if (line.contains(path)) { return line.split(" "); } } br.close(); } catch (FileNotFoundException e) { Log.d(TAG, "/proc/mounts does not exist"); } catch (IOException e) { Log.d(TAG, "Error reading /proc/mounts"); } return null; }
From source file:Main.java
public static int getPid(String tag) { Process p;//from ww w. j a v a 2 s .c o m try { p = Runtime.getRuntime().exec("ps "); BufferedReader bufferedReader2 = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = bufferedReader2.readLine()) != null) { if (line.contains(tag)) { return Integer.parseInt(line.split("\\s+")[1]); } } } catch (IOException e) { e.printStackTrace(); } return -1; }
From source file:com.haulmont.cuba.core.sys.jpql.Parser.java
private static JPA2Parser createParser(String input) { if (input.contains("~")) throw new IllegalArgumentException("Input string cannot contain \"~\""); CharStream cs = new AntlrNoCaseStringStream(input); JPA2Lexer lexer = new JPA2Lexer(cs); TokenStream tstream = new CommonTokenStream(lexer); return new JPA2Parser(tstream); }
From source file:com.springsource.hq.plugin.tcserver.serverconfig.web.support.RequestUtils.java
/** * Returns the url to access HQ locally, i.e. without routing through any proxy or load balancer which may be in * front of HQ./*from ww w . j ava 2 s.c om*/ * * @param request A request received by the HQ server from which the HQ URL will be determined * @return the local URL for the HQ server hosting the web app */ public static String getLocalHqUrl(ServletRequest request) { StringBuilder serverUrl = new StringBuilder(); serverUrl.append(request.getScheme()); serverUrl.append("://"); String hostName = request.getLocalName(); if (hostName.contains(":")) { hostName = "[" + hostName + "]"; } serverUrl.append(hostName); serverUrl.append(":"); serverUrl.append(request.getLocalPort()); if (request.isSecure()) { LOGGER.debug("Registering protocol."); UntrustedSSLProtocolSocketFactory.register(); } return serverUrl.toString(); }
From source file:io.selendroid.server.model.internal.JsonXmlUtil.java
private static String extractTagName(String clazz) { if (clazz.contains(".")) { String[] elements = clazz.split("\\."); String simpleClassName = elements[elements.length - 1]; if (simpleClassName.contains("$")) { return replaceDollarCharacter(clazz); }/*from ww w . ja v a2 s.c o m*/ return simpleClassName; } else if (clazz.contains("$")) { return replaceDollarCharacter(clazz); } return clazz; }
From source file:Main.java
public static String rmKeyWords(String objectString, String firMatchString, String secMatchString, String thrMatchString) {//from w ww .j a va 2 s.c o m if (objectString.contains(firMatchString) || objectString.contains(secMatchString) || objectString.contains(thrMatchString)) { objectString = objectString.replaceAll(firMatchString, ""); objectString = objectString.replaceAll(secMatchString, ""); objectString = objectString.replaceAll(thrMatchString, ""); } return objectString; }
From source file:com.envision.envservice.common.util.UserUtil.java
public static void sortByName(List<UserBo> users) { Collections.sort(users, new Comparator<UserBo>() { @Override/*w w w .j a va 2s .c o m*/ public int compare(UserBo u1, UserBo u2) { if (StringUtils.isEmpty(u1.getName())) { return 1; } if (StringUtils.isEmpty(u2.getName())) { return -1; } String u1Name = u1.getName(); if (u1Name.contains(".")) { String[] names = u1Name.split("\\."); u1Name = names[1] + names[0]; } String u2Name = u2.getName(); if (u2Name.contains(".")) { String[] names = u2Name.split("\\."); u2Name = names[1] + names[0]; } return u1Name.compareTo(u2Name); } }); }