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:Main.java

public static String assignDynamicValues(String inputXML, Map<String, String> dynamicValues) {
    for (String key : dynamicValues.keySet()) {
        if (inputXML.contains("{" + key + "}")) {
            inputXML = inputXML.replaceAll("\\{" + key + "\\}", dynamicValues.get(key));
        }//from  ww w  . j a va 2 s . c om
    }
    return inputXML;
}

From source file:Main.java

private static int keyStrokeModMac(String keyStrokeStr) {
    keyStrokeStr = keyStrokeStr.toLowerCase();
    int mod = 0;/*from   w  ww .j  a v  a  2s . c o  m*/
    if (keyStrokeStr.contains("ctrl") || keyStrokeStr.contains("control")) {
        mod = mod | InputEvent.CTRL_MASK;
    }
    if (keyStrokeStr.contains("alt")) {
        mod = mod | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    }
    if (keyStrokeStr.contains("meta")) {
        mod = mod | InputEvent.ALT_MASK;
    }
    return mod;
}

From source file:Main.java

public static Bitmap getBitmap(Context context, String imageFile) {
    try {//ww w .  j  a v a  2s  .co  m
        if (imageFile != null) {
            if (imageFile.contains("/")) {
                imageFile = imageFile.substring(imageFile.lastIndexOf("/") + 1);
            }
            FileInputStream in = context.openFileInput(imageFile);
            return BitmapFactory.decodeStream(in);
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static String classify(String packageName, String className) {
    if (className.startsWith(".")) {
        return packageName + className;
    } else if (className.contains(".")) {
        return className;
    } else {//from   ww  w  . j  a v a 2  s. co  m
        return packageName + "." + className;
    }
}

From source file:Main.java

public static String subString(String string) {
    if (string == null || string.length() == 0) {
        return "";
    }// w  ww .j  av  a2 s .c o  m
    if (string.contains(upToCharacter)) {
        int indexOfDot = string.indexOf(".");
        if (indexOfDot != -1) {
            return string.substring(0, indexOfDot);
        }
    }
    return "";
}

From source file:com.amazonaws.cognito.sync.demo.client.server.Utilities.java

public static String extractElement(String json, String element) {
    boolean hasElement = json.contains(element);
    if (hasElement) {
        int elementIndex = json.indexOf(element) + element.length() + 1;
        int startIndex = json.indexOf("\"", elementIndex);
        int endIndex = json.indexOf("\"", startIndex + 1);
        return json.substring(startIndex + 1, endIndex);
    }/*w  w  w.  ja  va 2s  . c om*/

    return null;
}

From source file:com.yoncabt.abys.core.util.Util.java

public static List<Integer> parseSequence(String sequence, int maxCount) {
    if (StringUtils.isBlank(sequence)) {
        return Collections.EMPTY_LIST;
    }/*from ww  w .ja  v  a2  s .  co m*/
    List<Integer> ret = new ArrayList<>();
    for (String item : sequence.split(",")) {
        if (item.contains("-")) {
            String[] split = item.split("-");
            int start = Integer.parseInt(split[0]);
            int end = Integer.parseInt(split[1]);
            for (int i = start; start < end && i <= end; i++) {
                ret.add(i);
                if (ret.size() > maxCount) {
                    throw new IllegalArgumentException(sequence);
                }
            }
        } else {
            ret.add(Integer.parseInt(item));
            if (ret.size() > maxCount) {
                throw new IllegalArgumentException(sequence);
            }
        }
    }
    return ret;
}

From source file:Main.java

public static String getTypeByStream(byte[] data) {
    byte[] b = new byte[4];
    b[0] = data[0];/* w ww . ja  v a  2 s. co m*/
    b[1] = data[1];
    b[2] = data[2];
    b[3] = data[3];
    String type = bytesToHexString(b).toUpperCase();
    if (type.contains("FFD8FF")) {
        return "jpg";
    } else if (type.contains("89504E47")) {
        return "png";
    } else if (type.contains("47494638")) {
        return "gif";
    } else if (type.contains("49492A00")) {
        return "tif";
    } else if (type.contains("424D")) {
        return "bmp";
    }
    return type;
}

From source file:Main.java

public static String getStringReplacedWithToken(final String input, final String tag, final String value) {
    String res = input;

    if (isStringNonEmpty(input) && isStringNonEmpty(tag)) {
        if (res.contains(tag)) {
            res = res.replace(tag, value);
        }//from w w w  .  j  a v a 2s. co  m
    }

    return res;
}

From source file:uk.ac.ebi.eva.utils.ConnectionHelper.java

public static List<ServerAddress> parseServerAddresses(String hosts) throws UnknownHostException {
    List<ServerAddress> serverAddresses = new LinkedList<>();
    for (String hostPort : hosts.split(",")) {
        if (hostPort.contains(":")) {
            String[] split = hostPort.split(":");
            Integer port = Integer.valueOf(split[1]);
            serverAddresses.add(new ServerAddress(split[0], port));
        } else {//from   w  w  w . j  a v  a2  s  . c o m
            serverAddresses.add(new ServerAddress(hostPort, 27017));
        }
    }
    return serverAddresses;
}