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:com.axibase.tsd.collector.AtsdUtil.java

public static String sanitizeValue(String s) {
    s = escapeCSV(s);//ww w  .  j  a  v a2  s  .com
    if ((s.contains(" ") || s.contains("=") || s.contains("\t")) && !s.startsWith("\"")) {
        StringBuilder sb = new StringBuilder("\"");
        s = sb.append(s).append("\"").toString();
    }

    return s;
}

From source file:com.meltmedia.cadmium.email.jersey.EmailFormValidator.java

protected static boolean pageExists(String pagePath, ContentService contentService) {
    if (pagePath.contains("-INF")) {
        return false;
    }//w ww. java2  s  .  com
    File pagePathFile = new File(contentService.getContentRoot(), pagePath);
    return pagePathFile.exists();
}

From source file:edu.lternet.pasta.datapackagemanager.ProvenanceBackfiller.java

private static List<EmlPackageId> getAllDataPackageRevisions(DataPackageRegistry dataPackageRegistry)
        throws ClassNotFoundException, SQLException {
    List<EmlPackageId> allDataPackageRevisions = new ArrayList<EmlPackageId>();
    boolean includeInactive = false;

    ArrayList<String> packageIdList = dataPackageRegistry.listAllDataPackageRevisions(includeInactive);

    for (String packageId : packageIdList) {
        if (packageId != null && packageId.contains(".")) {
            String[] elements = packageId.split("\\.");
            if (elements.length != 3) {
                String msg = String.format("The packageId '%s' does not conform to the "
                        + "standard format <scope>.<identifier>.<revision>", packageId);
                throw new IllegalArgumentException(msg);
            } else {
                String scope = elements[0];
                Integer identifier = new Integer(elements[1]);
                Integer revision = new Integer(elements[2]);
                EmlPackageId emlPackageId = new EmlPackageId(scope, identifier, revision);
                allDataPackageRevisions.add(emlPackageId);
            }/*from  www  .  ja  v a  2s .  c  o  m*/
        }
    }

    return allDataPackageRevisions;
}

From source file:com.mmd.mssp.util.HttpUtil.java

public static String httpGet(String uri) throws IOException {
    HttpClient httpclient = new DefaultHttpClient();
    HttpGet httpget = new HttpGet(uri);
    HttpResponse response = httpclient.execute(httpget);

    logger.info(httpget.getURI().toString() + " == " + response.getStatusLine());

    HttpEntity entity = response.getEntity();
    Header[] cts = response.getHeaders("Content-Type");
    String charset = "UTF-8";
    if (cts.length > 0) {
        String ContentType = cts[0].getValue();
        if (ContentType.contains("charset")) {
            charset = ContentType.split("charset=")[1];
        }//from   w  ww .j a va 2s  .c  o  m
    }
    if (entity != null) {
        InputStream instream = entity.getContent();
        try {
            StringBuffer buffer = new StringBuffer();
            char[] chars = new char[BUFFER_SIZE];
            while (true) {
                BufferedReader reader = new BufferedReader(new InputStreamReader(instream, charset));
                int len = reader.read(chars);
                if (len < 0) {
                    break;
                }
                buffer.append(chars, 0, len);
            }
            return buffer.toString();
        } catch (IOException ex) {
            throw ex;
        } catch (RuntimeException ex) {
            httpget.abort();
            throw ex;
        } finally {
            instream.close();
            httpclient.getConnectionManager().shutdown();
        }
    }
    return "";
}

From source file:in.flipbrain.Utils.java

public static String getVideoId(String url) throws MalformedURLException {
    URL u = new URL(url);
    String host = u.getHost();//from   www  . j  a  va  2  s  . co  m
    if (host.equals("youtu.be")) {
        return u.getPath();
    } else if (host.equals("www.youtube.com")) {
        String path = u.getPath();
        if (path.contains("embed")) {
            return path.substring(path.indexOf("/"));
        } else {
            String query = u.getQuery();
            String[] parts = query.split("&");
            for (String p : parts) {
                if (p.startsWith("v=")) {
                    return p.substring(2);
                }
            }
        }
    }
    return null;
}

From source file:de.blizzy.documentr.TestUtil.java

public static String removeViewPrefix(String view) {
    return view.contains(":") ? StringUtils.substringAfter(view, ":") : view; //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:edu.uci.ics.crawler4j.util.Util.java

public static boolean hasXMLContent(String contentType) {
    if (contentType != null) {
        String typeStr = contentType.toLowerCase();
        if (typeStr.contains("text/xml") || typeStr.contains("application/xml")) {
            return true;
        }// ww  w.  j  ava  2  s.c om
    }
    return false;
}

From source file:edu.uci.ics.crawler4j.util.Util.java

public static boolean hasPlainTextContent(String contentType) {
    if (contentType != null) {
        String typeStr = contentType.toLowerCase();
        if (typeStr.contains("text/plain")) {
            return true;
        }//  w  w  w  .java  2 s  . co  m
    }
    return false;
}

From source file:edu.ucla.cs.scai.linkedspending.index.Utils.java

public static String normalizeWords(String w) {
    w = w.replaceAll("[^A-Za-z0-9']", " ");
    //separate camel case words
    if (!w.contains(" ")) {
        w = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(w), ' ');
    }/*w w w  . j  ava  2s .c o m*/
    //collapse multiple spaces
    w = w.replaceAll("\\s+", " ");
    //change to lower case
    w = w.toLowerCase();
    return w;
}

From source file:net.dbjorge.jthumbor.ThumborUtils.java

/**
 * Sanitizes a given URL to include a protocol prefix. If one is not found, it prepends the
 * given default protocol.//ww w .  j  a  v a2  s  . c  om
 *
 * Note that unlike {@see #sanitizeUrlWithoutProtocol(String, String)}, this method does
 * NOT raise any error if the given URL starts with a non-default protocol. It also does not
 * override such a non-default protocol.
 *
 * Inputs may not be null.
 */
public static String sanitizeUrlWithProtocol(String url, String defaultProtocol) {
    if (url.contains("://") && url.indexOf('/') - 1 == url.indexOf("://")) {
        return url;
    } else {
        return defaultProtocol + "://" + url;
    }
}