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:eu.crisis_economics.configuration.AssignmentExpression.java

public static List<String> isExpressionOfType(String rawExpression, FromFileConfigurationContext context) {
    String expression = rawExpression.trim();
    if (!expression.contains("="))
        return null;
    int firstEqualsIndex = expression.indexOf('=');
    if (firstEqualsIndex == rawExpression.length() - 1)
        return null;
    String declExpressionString = rawExpression.substring(0, firstEqualsIndex);
    if (declExpressionString.length() == 0)
        return null;
    List<String> result = Arrays.asList(declExpressionString, rawExpression.substring(firstEqualsIndex + 1));
    return result;
}

From source file:Main.java

public static String getFileName(String url) {
    String fileNameWithExtension = getFileNameWithExtention(url);
    String fileName = fileNameWithExtension;
    if (fileNameWithExtension.contains(".")) {
        fileName = fileNameWithExtension.substring(0, fileNameWithExtension.lastIndexOf("."));
    }//from  w  w w.ja  v  a 2  s  . c  om
    return fileName;
}

From source file:Main.java

public static String createTableSql(Class<?> classs, String tableName, String... extraColumns) {
    mBuffer.setLength(0);//from w w  w  . j a  va  2 s. c o  m
    mBuffer.append("CREATE TABLE IF NOT EXISTS ");
    if (!TextUtils.isEmpty(tableName)) {
        mBuffer.append(tableName);
    } else {
        String className = classs.getSimpleName();
        if (className.contains("[]")) {
            throw new IllegalArgumentException("Can not create array class table");
        }
        mBuffer.append(classs.getSimpleName());
    }
    mBuffer.append("(" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ");
    Field[] fields = classs.getDeclaredFields();
    for (int i = 0; i < fields.length; i++) {
        Field field = fields[i];
        if (field.getType() == Integer.class) {
            mBuffer.append(field.getName() + " INTEGER,");
        } else if (field.getType() == Double.class || field.getType() == Float.class) {
            mBuffer.append(field.getName() + " REAL,");
        } else if (field.getType() == String.class) {
            mBuffer.append(field.getName() + " TEXT,");
        } else if (field.getType() == Boolean.class) {
            mBuffer.append(field.getName() + " INTEGER,");
        } else if (field.getType() == List.class || field.getType() == ArrayList.class) {
            mBuffer.append(field.getName() + " TEXT,");
        }
    }
    if (extraColumns != null && extraColumns.length != 0) {
        for (int i = 0; i < extraColumns.length; i++) {
            mBuffer.append(extraColumns[i]);
            if (i != extraColumns.length - 1) {
                mBuffer.append(",");
            } else {
                mBuffer.append(")");
            }
        }
    }
    return mBuffer.toString();
}

From source file:Main.java

public static boolean containXMLEscapeChar(String xml) {
    String escapes[] = { "<", ">", "&", "\'", "\"" };

    for (String escape : escapes) {
        if (xml.contains(escape)) {
            return true;
        }/*from w  w  w  . ja va  2s .  com*/
    }
    return false;
}

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

public static String format(String[] elements) {
    StringBuilder builder = new StringBuilder();

    int i = 1;//from w w  w  . j  a va 2 s .  c  om
    for (String element : elements) {
        builder.append(element.contains(".") ? "[" + element + "]" : element);
        if (i != elements.length)
            builder.append(".");
        i++;
    }

    return builder.toString();
}

From source file:hr.fer.spocc.util.BasePropertyConstants.java

/**
 * Returns the relative name of the property; for example, relative
 * name of the "some.example" is "example", but relative name
 * of the "test" is again "test".//from   w w  w .  ja va 2 s  .com
 * 
 * @param propertyName apsolute or relative name
 * @return relative name
 */
protected static String relativePropertyName(String propertyName) {
    if (!propertyName.contains(SEPARATOR))
        return propertyName;
    return StringUtils.substringAfterLast(propertyName, SEPARATOR);
}

From source file:hudson.slaves.ComputerLauncherTest.java

private static void assertChecked(String text, String spec) throws IOException {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    ComputerLauncher.checkJavaVersion(new PrintStream(os), "bin/java",
            new BufferedReader(new StringReader(text)));
    String logged = os.toString();
    assertTrue(logged, logged.contains(Messages.ComputerLauncher_JavaVersionResult("bin/java", spec)));
}

From source file:com.pros.jsontransform.expression.FunctionAbstract.java

static JsonNode transformArgument(final JsonNode argumentNode, final ObjectTransformer transformer)
        throws ObjectTransformerException {
    ObjectNode resultNode = transformer.mapper.createObjectNode();

    if (argumentNode.isContainerNode()) {
        // transform argument node
        JsonNode sourceNode = transformer.getSourceNode();
        JsonNode valueNode = transformer.transformExpression(sourceNode, argumentNode);
        resultNode.put("result", valueNode);
    } else if (argumentNode.isTextual()) {
        // transform $i modifier
        String textValue = argumentNode.textValue();
        if (textValue.contains($I)) {
            int arrayIndex = transformer.getIndexOfSourceArray();
            textValue = textValue.replace($I, String.valueOf(arrayIndex));
        }//w  ww.  j  a  v a2  s . c o m
        resultNode.put("result", textValue);
    } else {
        resultNode.put("result", argumentNode);
    }

    return resultNode.get("result");
}

From source file:Main.java

public static String subsituteAttr(Map<String, String> attrMap, String text) {
    if (attrMap == null) {
        return (text);
    }//  w w  w. j av  a2s  .  c om
    if (!text.contains("{")) {
        return (text);
    }
    String newString = text;
    for (Object key : attrMap.keySet()) {
        String value = (String) attrMap.get(key);
        newString = newString.replace("{" + key + "}", value);
    }
    return (newString);
}

From source file:com.mirth.connect.connectors.http.HttpUtil.java

public static String getCharset(String contentType) {
    for (String element : contentType.split(";")) {
        if (element.trim().startsWith("charset") && element.contains("=")) {
            return element.substring(element.indexOf("=") + 1).trim();
        }/*from w  w w. ja  va  2 s .com*/
    }
    return "ISO-8859-1";
}