Example usage for java.lang String startsWith

List of usage examples for java.lang String startsWith

Introduction

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

Prototype

public boolean startsWith(String prefix) 

Source Link

Document

Tests if this string starts with the specified prefix.

Usage

From source file:Main.java

public static List<String> getAllTables(Uri uri) {
    List<String> result = new ArrayList<String>();

    String mainTable = uri.getLastPathSegment();
    result.add(mainTable);//w w w.j  a  va 2s  .c om

    Set<String> queryParameterNames = uri.getQueryParameterNames();
    Iterator<String> iterator = queryParameterNames.iterator();
    while (iterator.hasNext()) {
        String table = iterator.next();
        if (table.startsWith(TABLE)) {
            result.add(table.replaceFirst(TABLE, ""));
        }
    }
    return result;
}

From source file:Main.java

/**
 * Removes single quotes at the start and end of tokenName.
 *///from ww  w.  j av a2 s .c o m
public static String formatTokenName(String tokenName) {
    if (tokenName.length() > 0 && tokenName.startsWith("'")) {
        tokenName = tokenName.substring(1, tokenName.length());
    }
    if (tokenName.length() > 0 && tokenName.endsWith("'")) {
        tokenName = tokenName.substring(0, tokenName.length() - 1);
    }
    return tokenName;
}

From source file:Main.java

private static String[] parseAttrValue(String s) {
    if (s == null || s.length() <= 0 || !s.startsWith("@"))
        throw new IllegalArgumentException("Invalid argument expresion " + s);
    s = s.substring(1);//ww w  . j  av  a2 s  .  c o  m
    int i = s.indexOf('=');
    String[] a = new String[2];
    a[0] = s.substring(0, i);
    a[1] = s.substring(i + 2, s.length() - 1);
    return a;
}

From source file:Main.java

/**
 * Return whether the given content type is considered as text.
 *
 * @param contentType   content type or null
 * @return              true if not null and a text content type, false otherwise.
 *///w  ww . jav  a  2  s  . c o m
public static boolean isTextContentType(String contentType) {
    return contentType != null && contentType.startsWith(TEXT_CONTENT_TYPE_PREFIX);
}

From source file:Main.java

public static boolean isServiceFilesStartWithFiles(String str) {
    if (str == null)
        return false;
    if (str.startsWith("/files/"))
        return true;
    return false;
}

From source file:Main.java

public static boolean isWebSocketEndpoint(String url) {
    String urlLowerCase = url.toLowerCase(Locale.US);
    return urlLowerCase.startsWith("ws://") || urlLowerCase.startsWith("wss://");
}

From source file:Main.java

/**
 * //from www  . ja va 2  s  .  c  om
 * Example usage:
 * <pre>
 * SwingUtil.createFileFilter("JEQL script (*.jql)", "jql")
 * </pre>
 * @param description
 * @param extension
 * @return the file filter
 */
public static FileFilter createFileFilter(final String description, String extension) {
    final String dotExt = extension.startsWith(".") ? extension : "." + extension;
    FileFilter ff = new FileFilter() {
        public String getDescription() {
            return description;
        }

        public boolean accept(File f) {
            return f.isDirectory() || f.toString().toLowerCase().endsWith(dotExt);
        }
    };
    return ff;
}

From source file:Main.java

/**
 * Get a list of all saved characters names.
 *//*from  w w  w  . j  a  v  a  2  s.com*/
public static List<String> listCharacterNames(Context context) {
    List<String> names = new ArrayList<>();

    for (String name : context.fileList()) {
        if (name.startsWith(CORE_PREFIX)) {
            names.add(name.replace(CORE_PREFIX, ""));
        } else if (name.startsWith(FAE_PREFIX)) {
            names.add(name.replace(FAE_PREFIX, ""));
        }
    }

    return names;
}

From source file:com.plan.proyecto.servicios.utilidades.UrlParser.java

public static List<String> pullLinks(String text) {

    List<String> links = new ArrayList();

    String regex = "\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]";
    Pattern p = Pattern.compile(regex);
    Matcher m = p.matcher(text);//  ww  w . j  av a  2s  . co m
    while (m.find()) {
        String urlStr = m.group();
        if (urlStr.startsWith("(") && urlStr.endsWith(")")) {
            urlStr = urlStr.substring(1, urlStr.length() - 1);
        }
        links.add(urlStr);
    }
    return links;
}

From source file:Main.java

public static String getClassName(Type type) {
    if (type == null) {
        return "";
    }/*w  ww .  j  av  a  2  s  . c o  m*/
    String className = type.toString();
    if (className.startsWith(TYPE_NAME_PREFIX)) {
        className = className.substring(TYPE_NAME_PREFIX.length());
    }
    return className;
}