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

/**
 * Resolves an entity reference or character reference to its value. 
 *
 * @param entName The 'name' of the reference. This is the string between
 * & and ;, e.g. amp, quot, #65 or #x41.
 * @return The value of the supplied reference, or the reference itself
 * if it could not be resolved./*from w ww . j  a v  a 2s. com*/
 */
public static String resolveEntity(String entName) {
    if (entName.startsWith("#")) {
        // character reference
        StringBuilder sb = new StringBuilder();
        if (entName.charAt(1) == 'x') {
            // Hex-notation
            sb.append((char) Integer.parseInt(entName.substring(2), 16));
        } else {
            // Dec-notation
            sb.append((char) Integer.parseInt(entName.substring(1)));
        }
        return sb.toString();
    } else if (entName.equals("apos")) {
        return "'";
    } else if (entName.equals("quot")) {
        return "\"";
    } else if (entName.equals("gt")) {
        return ">";
    } else if (entName.equals("lt")) {
        return "<";
    } else if (entName.equals("amp")) {
        return "&";
    } else {
        return entName;
    }
}

From source file:Main.java

/**
 * Return true if and only if name is a software codec.
 * @param name The codec name, e.g. from MediaCodecInfo.getName().
 *///from w  w w .  java2s  .  c  om
public static boolean isSoftwareCodec(String name) {
    // This is structured identically to libstagefright/OMXCodec.cpp .
    if (name.startsWith("OMX.google."))
        return true;

    if (name.startsWith("OMX."))
        return false;

    return true;
}

From source file:Main.java

public static boolean mayBeJson(String string) {
    return !isNullEmptyOrWhitespace(string)
            && ("null".equals(string) || (string.startsWith("[") && string.endsWith("]"))
                    || (string.startsWith("{") && string.endsWith("}")));
}

From source file:de.pksoftware.springstrap.core.util.ConfigUtils.java

public static String getWebjarClasspathLocation(String artifactId, String path) {
    if (!path.startsWith("/")) {
        path = "/" + path;
    }//from   ww  w  . j  ava  2s. c  o  m

    if (!path.endsWith("/")) {
        path = path + "/";
    }

    return "classpath:/webjar/" + artifactId.replace(".", "/") + path;
}

From source file:org.obiba.mica.file.FileUtils.java

public static String normalizePath(String path) {
    String nPath = path.startsWith("/") ? path : String.format("/%s", path);

    if (!isRoot(nPath) && nPath.endsWith("/"))
        nPath = nPath.replaceAll("[/]+$", "");

    return nPath;
}

From source file:com.github.geequery.codegen.util.GenUtil.java

public static boolean isMatchStart(String keyword, String[] strs) {
    for (String str : strs) {
        if (str.startsWith(keyword)) {
            return true;
        }//  w  w w . j  a v a  2 s. co m
    }
    return false;
}

From source file:Main.java

public static String MakeX10String(String nodeString) {
    String x10String = new String(nodeString);
    x10String.trim();/*from   w w w  .  ja  va  2 s. co m*/
    System.err.println(x10String.startsWith("\'"));
    //nodeString.c
    String temp = "\'";
    if (x10String.startsWith("\'") && x10String.endsWith("\'")) {

        x10String = x10String.substring(1, x10String.length() - 1);

    }
    x10String = x10String.replace("\"", "\\\"");
    x10String = x10String.replace("\'\'", "\\\'");
    x10String = "\"" + x10String + "\"";
    return x10String;
}

From source file:Main.java

/**
 * Helper method used to weed out dynamic Proxy types; types that do
 * not expose concrete method API that we could use to figure out
 * automatic Bean (property) based serialization.
 *///from   w ww. j  ava  2  s  .  c o  m
public static boolean isProxyType(Class<?> type) {
    // Then: well-known proxy (etc) classes
    if (Proxy.isProxyClass(type)) {
        return true;
    }
    String name = type.getName();
    // Hibernate uses proxies heavily as well:
    if (name.startsWith("net.sf.cglib.proxy.") || name.startsWith("org.hibernate.proxy.")) {
        return true;
    }
    // Not one of known proxies, nope:
    return false;
}

From source file:cherry.example.web.util.ViewNameUtil.java

public static String fromMethodCall(Object invocationInfo) {

    MethodInvocationInfo info = (MethodInvocationInfo) invocationInfo;
    Method method = info.getControllerMethod();
    Class<?> type = method.getDeclaringClass();

    UriComponentsBuilder ucb = UriComponentsBuilder.newInstance();
    String typePath = getMappedPath(type.getAnnotation(RequestMapping.class));
    if (StringUtils.isNotEmpty(typePath)) {
        ucb.path(typePath);//from   w  ww  . j a  v  a  2s .  c o m
    }

    String methodPath = getMappedPath(method.getAnnotation(RequestMapping.class));
    if (StringUtils.isNotEmpty(methodPath)) {
        ucb.pathSegment(methodPath);
    }

    String path = ucb.build().getPath();
    if (path.startsWith("/")) {
        return path.substring(1);
    }
    return path;
}

From source file:Main.java

public static String makeFile(Context context, String filePath) {
    String fileName;/*from w  ww  .j  av a2  s  . c o  m*/
    if (!filePath.startsWith("/")) {
        if (filePath.contains("/")) {
            fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
        } else {
            fileName = filePath;
        }
        return assetToSd(context, filePath, fileName);
    }
    return null;
}