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:ezbake.common.openshift.OpenShiftUtil.java

public static String getConfigurationDir() {
    String repoDir = getRepoDir();
    final String ezbakeConfigDir = "config";
    String retVal;// w w  w . j a v  a2  s  . c  o  m
    if (repoDir.endsWith(File.separator)) {
        retVal = repoDir.concat(ezbakeConfigDir);
    } else {
        retVal = Joiner.on(File.separator).join(repoDir, ezbakeConfigDir);
    }

    return retVal;
}

From source file:info.magnolia.cms.i18n.MessagesUtil.java

/**
 * Adds Variables to a JS witch can be used with the getMessage(key) method
 * @return Javascript-Construct of this textes
 *///  w w w  .  ja v  a 2 s.c om
public static String generateJavaScript(Messages messages) {
    StringBuffer str = new StringBuffer();

    str.append("/* ###################################\n"); //$NON-NLS-1$
    str.append("### Generated AbstractMessagesImpl\n"); //$NON-NLS-1$
    str.append("################################### */\n\n"); //$NON-NLS-1$

    for (Iterator iter = messages.keys(); iter.hasNext();) {
        String key = (String) iter.next();

        if (key.endsWith(".js")) { //$NON-NLS-1$
            String msg = javaScriptString(messages.get(key));
            str.append(AbstractMessagesImpl.JS_OBJECTNAME + ".add('" + key + "','" + msg + "','"
                    + messages.getBasename() + "');");
            str.append("\n"); //$NON-NLS-1$
        }
    }
    return str.toString();
}

From source file:com.savvywits.wethepeople.RESTService.java

public static boolean validateJSON(String string) {
    return string != null && ("null".equals(string) || (string.startsWith("[") && string.endsWith("]"))
            || (string.startsWith("{") && string.endsWith("}")));
}

From source file:de.erdesignerng.util.JasperUtils.java

private static void findReports(Map<File, String> aReportMap, File aDirectory) throws JRException {
    Thread.currentThread().setContextClassLoader(JasperUtils.class.getClassLoader());
    if (aDirectory != null && aDirectory.exists() && aDirectory.canRead()) {
        for (File theFile : aDirectory.listFiles()) {
            String theName = theFile.getName();
            if (theName.endsWith(".jrxml") && (!theName.contains("_"))) {
                try {
                    JasperDesign theDesign = JRXmlLoader.load(new FileInputStream(theFile));
                    String theReportName = theDesign.getName();
                    if (StringUtils.isNotEmpty(theReportName)) {
                        aReportMap.put(theFile, theReportName);
                    }// w ww  . j ava 2s  .  c o  m
                } catch (FileNotFoundException e) {
                    // This cannot happen
                }

            } else {
                if ((theFile.isDirectory()) && (!".".equals(theName)) && (!"..".equals(theName))) {
                    findReports(aReportMap, theFile);
                }
            }
        }
    }
}

From source file:Main.java

public static String GetParentPath(String uri) {
    if (uri.equalsIgnoreCase("/")) {
        return "";
    }//from   w  ww  .java  2 s  . com
    if (uri.endsWith("/")) {
        uri = uri.substring(0, uri.length() - 1);
    }
    if (uri.indexOf('/') < 0) {
        return "";
    }

    SimpleStringSplitter sss = new SimpleStringSplitter('/');
    sss.setString(uri);
    String tmp = "";
    String ret = "";
    while (sss.hasNext()) {
        tmp = sss.next();
        if (sss.hasNext() && tmp.trim().length() > 0) {
            ret += tmp.trim() + "/";
        }
    }
    if (ret.endsWith("/")) {
        ret = ret.substring(0, ret.length() - 1);
    }
    return ret;
}

From source file:com.github.autermann.wps.streaming.ProcessConfiguration.java

/**
 * Normalizes a path by returning {@code null} for {@code null}, {@code /}
 * or empty paths and transforming all other paths to {@code /path}.
 * @param path the path/*from  ww w . ja  va 2  s .c om*/
 * @return the normalized path
 */
private static String normalizePath(String path) {
    if (path == null || path.isEmpty() || path.equals("/")) {
        return null;
    }
    String s = path;
    if (s.endsWith("/")) {
        s = s.substring(0, s.length() - 1);
    }
    return s.charAt(0) == '/' ? s : '/' + s;
}

From source file:io.fabric8.maven.support.Apps.java

/**
 * Posts a file to the git repository//from   w  w  w .j  ava 2s .c  o m
 */
public static HttpResponse postFileToGit(File file, String user, String password, String consoleUrl,
        String branch, String path, Logger logger) throws URISyntaxException, IOException {
    HttpClientBuilder builder = HttpClients.custom();
    if (Strings.isNotBlank(user) && Strings.isNotBlank(password)) {
        CredentialsProvider credsProvider = new BasicCredentialsProvider();
        credsProvider.setCredentials(new AuthScope("localhost", 443),
                new UsernamePasswordCredentials(user, password));
        builder = builder.setDefaultCredentialsProvider(credsProvider);
    }

    CloseableHttpClient client = builder.build();
    try {

        String url = consoleUrl;
        if (!url.endsWith("/")) {
            url += "/";
        }
        url += "git/";
        url += branch;
        if (!path.startsWith("/")) {
            url += "/";
        }
        url += path;

        logger.info("Posting App Zip " + file.getName() + " to " + url);
        URI buildUrl = new URI(url);
        HttpPost post = new HttpPost(buildUrl);

        // use multi part entity format
        FileBody zip = new FileBody(file);
        HttpEntity entity = MultipartEntityBuilder.create().addPart(file.getName(), zip).build();
        post.setEntity(entity);
        // post.setEntity(new FileEntity(file));

        HttpResponse response = client.execute(URIUtils.extractHost(buildUrl), post);
        logger.info("Response: " + response);
        if (response != null) {
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode < 200 || statusCode >= 300) {
                throw new IllegalStateException("Failed to post App Zip to: " + url + " " + response);
            }
        }
        return response;
    } finally {
        Closeables.closeQuietly(client);
    }
}

From source file:Main.java

public static String convertToXpath(String expression) {
    if (expression == null) {
        return expression;
    }/*from w w  w . ja v  a2 s. c o  m*/

    if (expression.startsWith(EXPRESSION_LEFT) && expression.endsWith(EXPRESSION_RIGHT)) {
        return expression.substring(1, expression.length() - 1);
    } else {
        return expression.replace(EXPRESSION_SEPARATOR, XPATH_SEPARATOR);
    }

}

From source file:com.mgmtp.perfload.core.common.util.PropertiesUtils.java

public static List<String> getSubList(final PropertiesMap properties, final String keyPrefix) {
    String prefix = keyPrefix.endsWith(".") ? keyPrefix : keyPrefix + ".";

    List<String> result = newArrayList();
    for (int i = 1;; ++i) {
        String value = properties.get(prefix + i);
        if (value == null) {
            break;
        }/*from www .  j  a  va 2s . c om*/
        result.add(value);
    }
    return result;
}

From source file:net.orpiske.ssps.common.repository.ProviderFactory.java

/**
 * Creates a new repository provider based on the repository information
 * @param repositoryInfo repository information
 * @return A repository provider object//from  w  w  w.  j a  va 2s . c o  m
 */
public static Provider newProvider(final RepositoryInfo repositoryInfo) {
    String url = repositoryInfo.getUrl();

    if (url.endsWith(".git") || url.startsWith("git://")) {
        return new GitProvider(repositoryInfo);
    }

    if (url.startsWith("svn://")) {
        return new SvnProvider(repositoryInfo);
    }

    // Defaults to SvnProvider because, well, most git repositories end with ".git"
    return new SvnProvider(repositoryInfo);

}