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:com.medvision360.medrecord.tools.cliclient.ArchetypeUploader.java

protected static String getBaseUrl() {
    String baseUrl = System.getProperty("medrecord.url", "http://medrecord.test.medvision360.org/medrecord");
    if (baseUrl.endsWith("/")) {
        baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
    }/*w ww  .j a  va 2 s.  c  om*/
    if (baseUrl.endsWith("/v2")) {
        baseUrl = baseUrl.substring(0, baseUrl.length() - 3);
    }
    return baseUrl;
}

From source file:Main.java

private static String joinPath(String root, String[] path) {
    if (root.endsWith(File.separator)) {
        root = root.substring(0, root.length() - 1);
    }/*from   w  ww.  j  a  v a  2 s .  c  o m*/

    return Joiner.on(File.separator).join(Lists.asList(root, path));
}

From source file:Main.java

public static String formatValue(double value) {
    if (value < 0) {
        throw new NumberFormatException("Negative value " + value);
    }/*from   w w w.  ja  v  a2s. c  o  m*/
    String s = String.format(Locale.US, "%.8f", value);
    while (s.length() > 1 && (s.endsWith("0") || s.endsWith("."))) {
        s = (s.substring(0, s.length() - 1));
    }
    return s;
}

From source file:Main.java

private static boolean isSupported(String fileName) {
    for (int i = 0; i < mSupportedFiles.length; i++) {
        if (fileName.endsWith(mSupportedFiles[i])) {
            return true;
        }/*w  w w .j a  va2s  .  c o m*/
    }
    return false;
}

From source file:com.vaadin.sass.testcases.scss.AbstractDirectoryScanningSassTests.java

private static File[] getScssFiles(URL directoryUrl) throws URISyntaxException {
    URL sasslangUrl = directoryUrl;
    File sasslangDir = new File(sasslangUrl.toURI());
    File scssDir = new File(sasslangDir, "scss");
    Assert.assertTrue(scssDir.exists());

    return scssDir.listFiles(new FilenameFilter() {

        @Override//from  w w  w  .  j a  va2  s  .  co m
        public boolean accept(File dir, String name) {
            return name.endsWith(".scss");
        }
    });
}

From source file:Main.java

public static String getImageNetPath(String path, String domain) {
    if (path.startsWith("http://")) {
        return path;
    } else {//www  . j  a v  a2 s  .  c  o  m
        if (domain.endsWith("/") && path.startsWith("/")) {
            return domain + path.substring(1);
        } else if (!domain.endsWith("/") && path.startsWith("/")) {
            return domain + path;
        } else if (domain.endsWith("/") && !path.startsWith("/")) {
            return domain + path;
        } else {
            return domain + "/" + path;
        }
    }
}

From source file:Main.java

/**
 * @return map where value is path to javascript file in the project and key is created based on file name and formatted as reference to angular directive in
 * html//from w ww  .j a  v  a  2 s .  c o m
 */
public static Map<String, String> getJsPathsByAngularDirectiveName(IProject project) {
    // TODO in theory project could have two directives with the same name, but under different modules
    final Map<String, String> jsPathByDirectiveName = new HashMap<String, String>();
    try {
        project.accept(new IResourceVisitor() {
            private static final String SUFFIX_JS = ".js";

            // private static final String SUFFIX_HTML = ".html";

            @Override
            public boolean visit(IResource res) throws CoreException {
                if (res instanceof IFile) {
                    IFile file = (IFile) res;
                    String name = res.getName();
                    if (name.endsWith(SUFFIX_JS)) {
                        String directiveName = name.substring(0, name.length() - SUFFIX_JS.length());
                        String directiveAttributeName = getDirectiveNameAsHtmlAttribute(directiveName);
                        jsPathByDirectiveName.put(directiveAttributeName,
                                file.getProjectRelativePath().toPortableString());
                        // } else if (name.endsWith(SUFFIX_HTML)) {
                        // TODO
                    }
                }
                return true;
            }
        });
    } catch (CoreException e) {
        throw new RuntimeException("Failed to detect JS files", e);
    }
    return jsPathByDirectiveName;
}

From source file:com.cloudera.nav.sdk.client.writer.MetadataWriterFactory.java

private static String joinUrlPath(String base, String component) {
    return base + (base.endsWith("/") ? "" : "/") + component;
}

From source file:de.micromata.tpsb.doc.parser.TypeUtils.java

License:asdf

public static String stripClassEnd(String t) {
    if (t == null || t.endsWith(".class") == false) {
        return t;
    }// www.  ja  va  2s  .  c  o m
    return t.substring(0, t.length() - ".class".length());
}

From source file:Main.java

public static String getProperties(int properties) {
    StringBuilder permissionStr = new StringBuilder();
    String binaryString = Integer.toBinaryString(properties);
    binaryString = String.format("%16s", binaryString).replace(' ', '0');
    int len = binaryString.length();
    //PROPERTY_BROADCAST (0x00000001)
    if (binaryString.charAt(len - 1) == '1') {
        permissionStr.append("BROADCAST,");
    }//from   w w  w.  j  av a2s . c  om
    //PROPERTY_READ (0x00000002)
    if (binaryString.charAt(len - 2) == '1') {
        permissionStr.append("READ,");
    }
    //PROPERTY_WRITE_NO_RESPONSE (0x00000004)
    if (binaryString.charAt(len - 3) == '1') {
        permissionStr.append("WRITE_NO_RESPONSE,");
    }
    //PROPERTY_WRITE (0x00000008)
    if (binaryString.charAt(len - 4) == '1') {
        permissionStr.append("READ_ENCRYPTED_MITM,");
    }

    //PROPERTY_NOTIFY (0x00000010)
    if (binaryString.charAt(len - 5) == '1') {
        permissionStr.append("NOTIFY,");
    }
    //PROPERTY_INDICATE (0x00000020)
    if (binaryString.charAt(len - 6) == '1') {
        permissionStr.append("INDICATE,");
    }
    //PROPERTY_SIGNED_WRITE (0x00000040)
    if (binaryString.charAt(len - 7) == '1') {
        permissionStr.append("SIGNED_WRITE,");
    }

    //PROPERTY_EXTENDED_PROPS (0x00000080)
    if (binaryString.charAt(len - 8) == '1') {
        permissionStr.append("EXTENDED_PROPS,");
    }

    String perStr = permissionStr.toString();
    if (perStr.endsWith(",")) {
        perStr = perStr.substring(0, perStr.length() - 1);
    }

    return perStr;
}