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:de.uzk.hki.da.utils.FriendlyFilesUtils.java

/**
 * TODO remove duplicate from UnpackAction
 * @param file//from  w w  w .  ja v  a  2  s . co  m
 * @return
 * @author Daniel M. de Oliveira
 */
public static boolean isFriendlyFileExtension(String filename, String sidecarExts) {

    String[] sidecarExtensions;
    if (sidecarExts.contains(","))
        sidecarExtensions = sidecarExts.split(",");
    else
        sidecarExtensions = sidecarExts.split(";");

    for (int i = 0; i < sidecarExtensions.length; i++) {
        if (FilenameUtils.getExtension(filename).toLowerCase().equals(sidecarExtensions[i].toLowerCase())) {
            return true;
        }
    }
    return false;
}

From source file:de.uzk.hki.da.utils.SidecarUtils.java

/**
 * TODO remove duplicate from UnpackAction
 * @param file//from w  ww.j a  v  a  2  s. c  o  m
 * @return
 * @author Daniel M. de Oliveira
 */
public static boolean hasSidecarExtension(String filename, String sidecarExts) {

    String[] sidecarExtensions;
    if (sidecarExts.contains(","))
        sidecarExtensions = sidecarExts.split(",");
    else
        sidecarExtensions = sidecarExts.split(";");

    for (int i = 0; i < sidecarExtensions.length; i++) {
        if (FilenameUtils.getExtension(filename).toLowerCase().equals(sidecarExtensions[i].toLowerCase())) {
            return true;
        }
    }
    return false;
}

From source file:Main.java

public static String[] getMounts(CharSequence path) {
    BufferedReader bufferedReader = null;
    try {//from  w  ww . j  a  v  a2  s  . c om
        bufferedReader = new BufferedReader(new FileReader("/proc/mounts"), 256);
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            if (line.contains(path)) {
                return line.split(" ");
            }
        }
    } catch (FileNotFoundException ignored) {
        Log.d("TAG", "/proc/mounts does not exist");
    } catch (IOException ignored) {
        Log.d("TAG", "Error reading /proc/mounts");
    } finally {
        if (bufferedReader != null) {
            try {
                bufferedReader.close();
            } catch (IOException ignored) {
                // ignored
            }
        }
    }
    return null;
}

From source file:com.utest.webservice.util.SessionUtil.java

private static List<Cookie> extractCookies(List<String> cookie) {
    List<Cookie> cookies = new ArrayList<Cookie>();
    if (cookie == null)
        return cookies;
    for (String one : cookie) {
        if (one.contains(";")) {
            for (String o : one.split(";")) {
                cookies.add(toCookie(o));
            }/*from w  ww  .  ja  v  a 2  s .  c om*/
        } else {
            cookies.add(toCookie(one));
        }
    }
    return cookies;
}

From source file:com.kotcrab.vis.editor.util.ApplicationUtils.java

public static String getRestartCommand() {
    List<String> vmArguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
    StringBuilder vmArgsOneLine = new StringBuilder();

    if (OsUtils.isMac()) {
        vmArgsOneLine.append("-XstartOnFirstThread ");
    }//from  w ww .  jav  a2s  . c o m

    for (String arg : vmArguments) {
        if (arg.contains("-agentlib") == false) {
            vmArgsOneLine.append(arg).append(" ");
        }
    }

    final StringBuilder cmd = new StringBuilder(PlatformUtils.getJavaBinPath() + " " + vmArgsOneLine);

    String[] mainCommand = System.getProperty("sun.java.command").split(" ");

    if (mainCommand[0].endsWith(".jar"))
        cmd.append("-jar " + new File(mainCommand[0]).getPath());
    else
        cmd.append("-cp \"" + System.getProperty("java.class.path") + "\" " + mainCommand[0]);

    for (int i = 1; i < mainCommand.length; i++) {
        cmd.append(" ");
        cmd.append(mainCommand[i]);
    }

    //if launching from idea, not in debug mode
    String ideaLauncher = "-Didea.launcher.bin.path=";
    int ideaLauncherStart = cmd.indexOf(ideaLauncher);
    if (ideaLauncherStart != -1) {
        cmd.insert(ideaLauncherStart + ideaLauncher.length(), "\"");
        cmd.insert(cmd.indexOf("-cp ", ideaLauncherStart) - 1, "\"");
    }

    return cmd.toString();
}

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

private static int parseTime(String time) {
    time = time.toLowerCase();/*from w  ww  .  ja  va  2 s .c o  m*/
    String[] split;
    if (time.contains("w")) {
        split = time.split("w");
        return Integer.parseInt(split[0]) * 604800;
    } else if (time.contains("d")) {
        split = time.split("d");
        return Integer.parseInt(split[0]) * 86400;
    } else if (time.contains("h")) {
        split = time.split("h");
        return Integer.parseInt(split[0]) * 3600;
    } else if (time.contains("m")) {
        split = time.split("m");
        return Integer.parseInt(split[0]) * 60;
    } else if (time.contains("s")) {
        split = time.split("s");
        return Integer.parseInt(split[0]);
    }
    return 0;
}

From source file:Main.java

/**
 * Method that merges 2 data structures into 1
 * /*  ww w  .  j a  va2s  .  c  o m*/
 * @param featureSet:
 *            the structure containing all features
 * @param featureSet2:
 *            the structure containing Pairwise Correlation features
 * @return the concatenated data structure
 */
public static HashMap<Integer, ArrayList<HashMap<String, Double>>> mergeStructures(
        HashMap<Integer, ArrayList<HashMap<String, Double>>> featureSet,
        ArrayList<ArrayList<HashMap<String, Double>>> featureSet2) {

    HashMap<Integer, ArrayList<HashMap<String, Double>>> featureSet_final = new HashMap<Integer, ArrayList<HashMap<String, Double>>>();

    for (int i = 0; i < featureSet.size(); i++) {
        ArrayList<HashMap<String, Double>> featuresPerChann = featureSet.get(i);
        ArrayList<HashMap<String, Double>> featuresPerChann2 = featureSet2.get(i);
        if (featuresPerChann2 == null)
            continue;

        ArrayList<HashMap<String, Double>> featuresPerChann_final = new ArrayList<HashMap<String, Double>>();

        for (int ii = 0; ii < featuresPerChann.size(); ii++) {
            HashMap<String, Double> h1 = new HashMap<String, Double>();
            HashMap<String, Double> h2 = new HashMap<String, Double>();
            // System.out.println("s:: "+String.format("%03d", ii));
            h1 = featuresPerChann.get(ii);
            for (int j = 0; j < featuresPerChann2.size(); j++) {
                h2 = featuresPerChann2.get(j);
                // System.out.println("h2:"+h2);
                String s = h2.keySet().toString();

                if (s.contains("s" + String.format("%04d", ii))) {
                    // System.out.println("sss"+s.substring(1,14));
                    String new_s = s.substring(1, 17);
                    if (h2.get(new_s) != null) {
                        double v = h2.get(new_s);
                        HashMap<String, Double> h = new HashMap<String, Double>();
                        h.put(new_s.substring(0, 11), v);
                        h1.putAll(h);
                    }
                }
            }
            featuresPerChann_final.add(h1);

        }
        featureSet_final.put(i, featuresPerChann_final);
    }

    return featureSet_final;
}

From source file:Main.java

/**
 * Convenience method for retrieving a subset of the UIDefaults pertaining to a particular class.
 * //from www .  j a v a2s.co m
 * @param className
 *            fully qualified name of the class of interest
 * @return the UIDefaults of the class named
 */
public static UIDefaults getUIDefaultsOfClass(String className) {
    UIDefaults retVal = new UIDefaults();
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    List<?> listKeys = Collections.list(defaults.keys());
    for (Object key : listKeys) {
        if (key instanceof String && ((String) key).startsWith(className)) {
            String stringKey = (String) key;
            String property = stringKey;
            if (stringKey.contains(".")) { //$NON-NLS-1$
                property = stringKey.substring(stringKey.indexOf(".") + 1); //$NON-NLS-1$
            }
            retVal.put(property, defaults.get(key));
        }
    }
    return retVal;
}

From source file:com.streamsets.pipeline.stage.origin.remote.FileFilter.java

/**
 * Convert a limited file glob into a simple regex.
 *
 * @param glob file specification glob/*w  w w.  j  a va  2 s  . c o  m*/
 * @return regex.
 */
private static String globToRegex(String glob) {
    if (glob.charAt(0) == '.' || glob.contains("/") || glob.contains("~")) {
        throw new IllegalArgumentException("Invalid character in file glob");
    }

    // treat dot as a literal.
    glob = glob.replace(".", "\\.");
    glob = glob.replace("*", ".+");
    glob = glob.replace("?", ".{1}+");

    return glob;
}

From source file:Main.java

public static Date parseData(String text) {
    Calendar calendar = Calendar.getInstance();
    if (text.contains(":")) {
        String[] time = text.split(":");
        int hours = Integer.parseInt(time[0]);
        calendar.set(Calendar.MINUTE, Integer.parseInt(time[1]));
        calendar.set(Calendar.HOUR_OF_DAY, hours);
        return calendar.getTime();
    } else if (text.contains("/")) {
        String[] date = text.split("/");
        if (date.length == 3) {
            calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(date[0]));
            calendar.set(Calendar.MONTH, Integer.parseInt(date[1]) - 1);
            calendar.set(Calendar.YEAR, Integer.parseInt(date[2]));
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.HOUR_OF_DAY, 0);
            return calendar.getTime();
        } else if (date.length == 2) {
            calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(date[0]));
            calendar.set(Calendar.MONTH, Integer.parseInt(date[1]) - 1);
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.HOUR_OF_DAY, 0);
            return calendar.getTime();
        }//from   w w  w.  j  av a 2  s . c om
    }
    return null;
}