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:Main.java

public static String getTypeByStream(InputStream is) {
    byte[] b = new byte[4];
    try {/*from w  w w .j a  va2 s . co  m*/
        is.read(b, 0, b.length);
    } catch (IOException e) {
        e.printStackTrace();
    }
    String type = bytesToHexString(b).toUpperCase();
    if (type.contains("FFD8FF")) {
        return "jpg";
    } else if (type.contains("89504E47")) {
        return "png";
    } else if (type.contains("47494638")) {
        return "gif";
    } else if (type.contains("49492A00")) {
        return "tif";
    } else if (type.contains("424D")) {
        return "bmp";
    }
    return type;
}

From source file:Main.java

public static String getYesterdayFormattedTime() {

    Calendar calendar = getCurrentCalendar();
    calendar.add(Calendar.HOUR_OF_DAY, -9);
    calendar.add(Calendar.DAY_OF_MONTH, -1);
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
    String result = format.format(calendar.getTime());
    String standardName = "";
    if (result.contains("JST")) {
        standardName = "JST";
        result = result.replaceAll(standardName, "+09:00");
    } else if (result.contains("GMT")) {
        standardName = "GMT";
        result = result.replaceAll(standardName, "");
    }//from w  w w . jav a2 s .c om
    return result;
}

From source file:br.com.vpsa.oauth2android.response.StringParser.java

public static List<NameValuePair> parseForParameters(String stringResponse)
        throws JSONException, InvalidRequestException, InvalidClientException, InvalidGrantException,
        UnauthorizedClientException, UnsupportedGrantTypeException, InvalidScopeException, OAuthException {
    OAuthException exception = null;/*from ww  w  . j  a v  a 2s  .com*/
    List<NameValuePair> parameterList = new ArrayList<NameValuePair>();
    String[] parameters = stringResponse.split("&");
    for (String parameter : parameters) {
        if (parameter.contains("?")) {
            parameterList.add(new BasicNameValuePair("redirectUri", parameter.split("?")[0]));
            parameter = parameter.split("?")[1];
        }
        if (parameter.contains("=")) {

            String[] pair = parameter.split("=");
            BasicNameValuePair basicNameValuePair = new BasicNameValuePair(pair[0], pair[1]);
            parameterList.add(basicNameValuePair);
            if (basicNameValuePair.getName().equalsIgnoreCase("error")) {
                exception = ErrorParser.getException(basicNameValuePair.getValue());
            }
        }
    }
    if (exception != null) {
        throw exception;
    }
    return parameterList;
}

From source file:com.hazelcast.qasonar.utils.PropertyReaderBuilder.java

private static void addProjectResourceIds(PropertyReader propertyReader, String projectResourceIdString) {
    if (!projectResourceIdString.contains(",")) {
        propertyReader.addProjectResourceId(projectResourceIdString);
        return;/*from w ww.  j  av  a  2s  .  c o m*/
    }

    asList(projectResourceIdString.split("\\s*,\\s*")).forEach(propertyReader::addProjectResourceId);
}

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

public static String putParam4query(String uri, String key, String val) {
    if (uri.contains("?")) {
        return uri + "&" + key + "=" + val;
    }//www.  j a  v a 2 s .c  om
    return uri + "?" + key + "=" + val;
}

From source file:com.denimgroup.threadfix.framework.impl.dotNetWebForm.AscxFileMappingsFileParser.java

public static Map<String, AscxFile> getMap(File rootDirectory) {
    if (!rootDirectory.exists() || !rootDirectory.isDirectory()) {
        throw new IllegalArgumentException(
                "Invalid directory passed to WebFormsEndpointGenerator: " + rootDirectory);
    }//  w  w  w.  j  av a  2  s.  co m

    Collection ascxFiles = FileUtils.listFiles(rootDirectory, new FileExtensionFileFilter("ascx"),
            TrueFileFilter.INSTANCE);

    Map<String, AscxFile> map = map();

    for (Object aspxFile : ascxFiles) {
        if (aspxFile instanceof File) {

            File file = (File) aspxFile;
            String name = file.getName();
            String key = name.contains(".") ? name.substring(0, name.indexOf('.')) : name;
            map.put(key, new AscxFile(file));
        }
    }

    return map;
}

From source file:com.netflix.spinnaker.orca.pipelinetemplate.PipelineTemplateService.java

private static boolean containsJinja(String string) {
    return string.contains("{%") || string.contains("{{");
}

From source file:com.haulmont.cuba.gui.components.ValuePathHelper.java

public static String[] parse(String path) {
    if (!path.contains(".") && !path.contains("["))
        return new String[] { path };

    List<String> elements = new ArrayList<>();

    int bracketCount = 0;

    StringBuilder buffer = new StringBuilder();

    for (int i = 0; i < path.length(); i++) {
        char c = path.charAt(i);
        if (c == '[') {
            bracketCount++;/*from   w  w  w  .jav  a  2s .c  om*/
            continue;
        }

        if (c == ']') {
            bracketCount--;
            continue;
        }

        if ('.' != c || bracketCount > 0)
            buffer.append(c);

        if ('.' == c && bracketCount == 0) {
            String element = buffer.toString();
            if (!StringUtils.isEmpty(element)) {
                elements.add(element);
            } else {
                throw new IllegalStateException("Wrong value path format");
            }
            buffer = new StringBuilder();
        }
    }
    elements.add(buffer.toString());

    return elements.toArray(new String[elements.size()]);
}

From source file:Main.java

public static String highlightText(String html, String name, String text) {
    if (TextUtils.isEmpty(text)) {
        return name;
    }/*from w  w  w  . j  a  v a 2  s .  c o m*/

    if (name.contains(text)) {
        String replaceHtml = html.replace("%s", text);
        name = name.replaceAll(text, replaceHtml);
    }

    return name;
}

From source file:edu.du.penrose.systems.fedoraApp.batchIngest.bus.BatchIngestThreadManager.java

/**
 * @param batchSetName of type institution_batchSet
 * /*from  ww w  .  j a v a  2 s.  c o m*/
 * @return status of the task performing an ingest for this batchSet
 */
static public StatusData getAllBatchSetStatus(String batchSetName) {

    if (!batchSetName.contains("_")) {
        System.out.println("invalid batchSetName"); // TBD temp for debug
    }
    StatusData allStatus = new StatusData();

    allStatus.setBatchIsUpdates(isBatchIsUpdates(batchSetName));
    allStatus.setBatchSetName(batchSetName);
    allStatus.setStatus(getBatchSetStatus(batchSetName));
    allStatus.setCompleted(getCurrentCompleted(batchSetName));
    allStatus.setFailed(getCurrentFailed(batchSetName));
    allStatus.setInstitution(getInstitution(batchSetName));
    allStatus.setRunning(isBatchSetRunning(batchSetName));

    allStatus.setTotalFilesAddedSuccess(getTotalFilesAddedSuccess(batchSetName));
    allStatus.setTotalFilesAddedFailed(getTotalFilesAddedFailed(batchSetName));
    allStatus.setTotalFilesUpdatedSuccess(getTotalFilesUpdatedSuccess(batchSetName));
    allStatus.setTotalFilesUpdatedFailed(getTotalFilesUpdatedFailed(batchSetName));

    allStatus.setIslandoraCollection(getIslandoraCollection(batchSetName));
    allStatus.setIslandoraContentModel(getIslandoraContentModel(batchSetName));

    allStatus.setstoppedByUser(isStoppedByUser(batchSetName));

    return allStatus;
}