Example usage for java.lang String indexOf

List of usage examples for java.lang String indexOf

Introduction

In this page you can find the example usage for java.lang String indexOf.

Prototype

public int indexOf(String str) 

Source Link

Document

Returns the index within this string of the first occurrence of the specified substring.

Usage

From source file:Main.java

public static String getNameFromNameAddress(String nameAddress) {
    return nameAddress.substring(0, nameAddress.indexOf(" "));
}

From source file:Main.java

public static String getArrayName(String arrNameFull) {
    return arrNameFull.substring(0, arrNameFull.indexOf("["));
}

From source file:Main.java

/**
 * if the component path is "a", it would be direct mapping. true
 * if the component path is "a.b.c", it would be complex mapping. false
 * //from   w  w w.  j  av  a 2s.  c  om
 * @param componentPath
 * @return
 */
public static boolean isDirectComponentPath(String componentPath) {
    return (componentPath.indexOf(".") == -1);
}

From source file:Main.java

public static String filterOutSoapHeader(String xml) {
    int start = xml.indexOf("<soap:Header>");
    if (start < 0) {
        return xml;
    }/*w  w  w.  ja v  a2 s.  c o m*/

    int end = xml.indexOf("</soap:Header>");
    if (end < 0) {
        throw new IllegalArgumentException("Close tag for SOAP header not presented");
    }

    String part1 = xml.substring(0, start);
    String part2 = xml.substring(end + "</soap:Header>".length());
    return part1 + part2;
}

From source file:Main.java

/**
 * Returns the prefix of the given name, or null if there is no prefix.
 *///from  w w w  . jav a  2  s.co m
public static String getPrefix(String name) {
    int colonLocation = name.indexOf(':');
    return colonLocation == -1 ? null : name.substring(0, colonLocation);
}

From source file:Main.java

/**
 * Returns the offset of the name without a prefix.
 * /*from   w ww  . j  a  v  a 2  s.c  o  m*/
 * @param name the name, with or without a prefix
 * @return the offset of the name without a prefix
 */
public static int getUnprefixedOffset(String name) {
    int colonIndex = name.indexOf(':');
    return colonIndex == -1 ? 0 : colonIndex + 1;
}

From source file:Main.java

public static void splitName(String nodeName, String[] name) {
    int p = nodeName.indexOf(":");
    if (p < 0) {
        name[0] = null;/*from  w w w .  j ava  2 s  .  c  om*/
        name[1] = nodeName;
    } else {
        name[0] = nodeName.substring(0, p);
        name[1] = nodeName.substring(p + 1);
    }
}

From source file:Main.java

public static String removeHeaderDirective(String xml) {
    int indexOfDirStart = xml.indexOf("<?");
    if (indexOfDirStart == -1)
        return (xml);

    int indexOfDirEnd = xml.indexOf("?>", indexOfDirStart + 2);
    if (indexOfDirEnd == -1)
        return (xml);

    return (xml.substring(xml.indexOf("<", indexOfDirEnd + 2)));
}

From source file:Main.java

public static String getFileNameFromURL(String s) {
    if (s == null) {
        return null;
    }/*from   www .j av a  2  s .c o  m*/
    String s1 = URLDecoder.decode(s);
    if (s1.indexOf("?") >= 0) {
        s1 = s1.substring(0, s1.indexOf("?"));
    }
    return s1.substring(1 + s1.lastIndexOf(File.separator), s1.length());
}

From source file:Main.java

private static boolean isToplevelClass(String fileName) {
    return fileName.indexOf('$') < 0;
}