Example usage for java.lang String endsWith

List of usage examples for java.lang String endsWith

Introduction

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

Prototype

public boolean endsWith(String suffix) 

Source Link

Document

Tests if this string ends with the specified suffix.

Usage

From source file:Main.java

/**
 * Does this Lucene field name refer to a diacritics-sensitive alternative?
 *
 * Diacritics-sensitive alternatives are "s" (case- and diacritics-sensitive)
 * and "ci" (case-insensitive but diacritics-sensitive).
 *
 * @param fieldPropAltName Lucene field name including property and alt name
 * @return true if the field name refers to a diacritics-sensitive alternative
 *//*from  w ww  .j  a  va2s .  com*/
public static boolean isDiacriticsSensitive(String fieldPropAltName) {
    // both-sensitive or case-insensitive
    return fieldPropAltName.endsWith(ALT_SEP + "s") || fieldPropAltName.endsWith(ALT_SEP + "ci");
}

From source file:Main.java

public static String concat(String path1, String path2) {
    String result;//from w  w w .  ja  v a  2  s . c o m
    if (path2.startsWith("/") && path1.endsWith("/"))
        result = path1 + path2.substring(1);
    else if (path2.startsWith("/") || path1.endsWith("/"))
        result = path1 + path2;
    else
        result = path1 + "/" + path2;
    int i;
    while ((i = result.indexOf("/./")) >= 0)
        result = result.substring(0, i) + result.substring(i + 2);
    while (result.startsWith("./"))
        result = result.substring(2);
    while (result.endsWith("/."))
        result = result.substring(0, result.length() - 2);
    if (result.isEmpty())
        result = "/";
    return result;
}

From source file:Main.java

public static String[] getXmlFiles(String path) {
    List<String> xmlFiles = new ArrayList<>();
    ZipFile zipFile = null;//from w w w  .  ja  va  2s  .c o m
    try {
        zipFile = new ZipFile(path);
        Enumeration<? extends ZipEntry> entries = zipFile.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            String name = entry.getName();
            if (name.endsWith(".xml") && !name.equals("AndroidManifest.xml")) {
                xmlFiles.add(name);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (zipFile != null) {
            try {
                zipFile.close();
            } catch (IOException ignored) {
            }
        }
    }
    Collections.sort(xmlFiles);
    return xmlFiles.toArray(new String[xmlFiles.size()]);
}

From source file:Main.java

public static String getParentNameofPath(String path) {
    if (path.equals("/")) {
        return null;
    }/*from  ww  w . j a  v a  2s.  co  m*/
    if (path.endsWith("/")) {
        path = path.substring(0, path.length() - 1);
    }
    int index = path.lastIndexOf('/');
    if (path.length() == 1) {
        return path;
    }
    if (index == 0) {
        return "/";
    }
    return path.substring(0, index);
}

From source file:Main.java

/**
 * Returns whether specified window is a HeavyWeightWindow or not.
 *
 * @param window//from   w w w  .j av a  2s . c  o m
 *            window to process
 * @return true if specified window is a HeavyWeightWindow, false otherwise
 */
public static boolean isHeavyWeightWindow(final Window window) {
    if (window == null) {
        return false;
    }
    final String can = window.getClass().getCanonicalName();
    return can != null && can.endsWith("HeavyWeightWindow");
}

From source file:Main.java

public static String removeSizeQuote(String str) {
    if (str == null) {
        return null;
    }/*from w w  w  . j a v  a2 s . co m*/
    if (str.startsWith("\"") && str.endsWith("\"") && str.length() > 2) {
        return str.substring(1, str.length());
    }
    return str;
}

From source file:com.intel.podm.rest.odataid.ODataId.java

public static ODataId oDataId(ODataId oDataId, Id id) {
    String uri = oDataId.toString();
    return oDataId(uri.endsWith("/") ? (uri + id) : (uri + "/" + id));
}

From source file:com.sonar.it.java.suite.TestUtils.java

public static File pluginJar(String artifactId) {
    return Iterables.getOnlyElement(Arrays
            .asList(new File(homeDir(), "plugins/" + artifactId + "/target/").listFiles(new FilenameFilter() {
                @Override/*  ww  w  .j a va2 s. c o  m*/
                public boolean accept(File dir, String name) {
                    return name.endsWith(".jar") && !name.endsWith("-sources.jar");
                }
            })));
}

From source file:Main.java

/**
 * Build an Engagement alias for an Android Activity class. This implementation takes the simple
 * name of the class and removes the "Activity" suffix if any (e.g. "com.mycompany.MainActivity"
 * becomes "Main").<br/>/*  www.  jav a  2  s .  co m*/
 * This method is used by {@link EngagementActivity} and its variants.
 * @return an activity name suitable to be reported by the Engagement service.
 */
public static String buildEngagementActivityName(Class<?> activityClass) {
    String name = activityClass.getSimpleName();
    String suffix = "Activity";
    if (name.endsWith(suffix) && name.length() > suffix.length())
        return name.substring(0, name.length() - suffix.length());
    else
        return name;
}

From source file:edu.sdsc.scigraph.services.refine.RefineUtil.java

private static boolean isProbableJSON(String text) {
    return text.startsWith("[") && text.endsWith("]") || text.startsWith("{") && text.endsWith("}");
}