Example usage for java.lang String contains

List of usage examples for java.lang String contains

Introduction

In this page you can find the example usage for java.lang String contains.

Prototype

public boolean contains(CharSequence s) 

Source Link

Document

Returns true if and only if this string contains the specified sequence of char values.

Usage

From source file:com.bstek.dorado.util.PathUtils.java

public static boolean isSafePath(String path) {
    boolean dangerous = (path.contains("..") || StringUtils.containsAny(path, ",: \n\r"));
    return !dangerous;
}

From source file:com.mgmtp.perfload.agent.util.ClassNameUtils.java

public static String abbreviatePackageName(String className) {
    if (className.contains(".")) {
        String packageName = substringBeforeLast(className, ".");
        String simpleClassName = substringAfterLast(className, ".");
        List<String> list = from(Splitter.on('.').splitToList(packageName))
                .transform(new Function<String, String>() {
                    @Override//from w w w . j  a  va 2s.co m
                    public String apply(String input) {
                        return input.substring(0, 1);
                    }
                }).toList();
        return Joiner.on('.').join(list) + '.' + simpleClassName;
    } else {
        return className;
    }
}

From source file:com.sky8the2flies.KOTH.util.TimeParser.java

public static int parseToSeconds(String time) {
    int amount = 0;
    if (time.contains(":")) {
        String[] split = time.split(":");
        for (String bits : split) {
            amount = amount + parseTime(bits);
        }//from   w ww  .j  a  va2  s  . com
    } else
        amount = parseTime(time);
    return amount;
}

From source file:Util.java

/**
 * Checks if classNames belongs to package
 * // ww w.j  a v a2  s  . c om
 * @param className
 *            class name
 * @param packageName
 *            package
 * @return true if belongs
 */
public static boolean isPackageMember(String className, String packageName) {
    if (!className.contains(".")) {
        return packageName == null || packageName.isEmpty();
    } else {
        String classPackage = className.substring(0, className.lastIndexOf('.'));
        return packageName.equals(classPackage);
    }
}

From source file:Main.java

public static String[] sortQualities(String[] qualities) {
    Arrays.sort(qualities, new Comparator<String>() {
        @Override/*from  w  w  w .java 2 s . c o  m*/
        public int compare(String lhs, String rhs) {
            if (lhs.contains("p") && rhs.contains("p")) {
                int q1 = Integer.parseInt(lhs.substring(0, lhs.indexOf('p')));
                int q2 = Integer.parseInt(rhs.substring(0, rhs.indexOf('p')));
                if (q1 < q2) {
                    return 1;
                } else if (q1 < q2) {
                    return -1;
                } else {
                    return 0;
                }
            }

            if (lhs.equals("3D"))
                return 1;

            return 0;
        }
    });
    return qualities;
}

From source file:com.google.demo.translate.Translator.java

private static String postTranslationParser(String string) {
    if (string.contains(",")) {
        return "\"" + string + "\"";
    }//from  www.j a v  a 2  s. c  o  m

    return string;
}

From source file:Main.java

/**
 *  get file name form url /* w  ww .  ja va  2 s.c  o  m*/
 * @param url
 * @return
 */
public static String getFileNameFromURL(String url) {
    int length = url.length();
    int lastIndex = 0;
    if (url.contains("/")) {
        lastIndex = url.lastIndexOf("/");
    } else if (url.contains("\"")) {
        lastIndex = url.lastIndexOf("\"");
    }
    return url.substring(lastIndex, length - lastIndex);
}

From source file:Main.java

public static boolean isConfirmMessage(String content) {
    if (content == null) {
        return false;
    }/*from   w ww.jav  a  2  s .  co  m*/
    if (content.contains("|")) {
        return true;
    }
    return false;
}

From source file:Main.java

public static boolean isValidShopImageUrl(String url) {
    if (url == null || url.equals(""))
        return false;

    if (url.contains("{0}") || url.contains("{1}"))
        return false;

    return true;/*from w w  w.j a  v a2s.  co m*/
}

From source file:info.hieule.framework.laravel.utils.LaravelSecurityString.java

public static void updateSecurityString(FileObject configFile) throws IOException {
    List<String> lines = configFile.asLines();
    String newKey = RandomStringUtils.randomAlphanumeric(32);
    OutputStream outputStream = configFile.getOutputStream();
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(outputStream, "UTF-8"), true); // NOI18N
    try {//from  ww w .ja v a 2s.  co  m
        for (String line : lines) {
            if (line.contains(_SECURITY_STRING_LINE)) {
                line = String.format(_SECURITY_STRING_FORMAT, newKey);
            }
            pw.println(line);
        }
    } finally {
        outputStream.close();
        pw.close();
    }
}