Example usage for java.lang String matches

List of usage examples for java.lang String matches

Introduction

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

Prototype

public boolean matches(String regex) 

Source Link

Document

Tells whether or not this string matches the given regular expression.

Usage

From source file:ips1ap101.lib.core.db.util.DBUtils.java

public static String[] getConstraintMessageKeys(String message) {
    String trimmed = StringUtils//from  ww  w . j  a v  a2s. c o  m
            .trimToEmpty(StringUtils.substringAfter(StringUtils.substringBefore(message, WHERE), ERROR));
    if (StringUtils.isNotBlank(trimmed)) {
        String[] tokens = StringUtils.split(trimmed, ';');
        if (tokens != null && tokens.length > 1) {
            String key = tokens[0].trim();
            if (key.matches("^[0-9]{1,3}$")) {
                int length = Integer.valueOf(key);
                if (length == tokens.length - 1) {
                    String string;
                    String[] keys = new String[length];
                    for (int i = 1; i < tokens.length; i++) {
                        key = tokens[i].trim();
                        if (key.endsWith(SUFIJO) && StringUtils.indexOfAny(key, INFIJOS) > 0) {
                            key = StringUtils.removeEnd(key, SUFIJO);
                            string = BundleMensajes.getString(key);
                            keys[i - 1] = isKey(string) ? string : "<" + key + ">";
                        } else {
                            return null;
                        }
                    }
                    return keys;
                }
            }
        }
        String key, string;
        String stripChars = BOMK + EOMK;
        List<String> list = new ArrayList<>();
        Pattern pattern = Pattern.compile("\\" + BOMK + ".*\\" + EOMK);
        Matcher matcher = pattern.matcher(trimmed);
        while (matcher.find()) {
            key = StringUtils.strip(matcher.group(), stripChars);
            if (key.endsWith(SUFIJO) && StringUtils.indexOfAny(key, INFIJOS) > 0) {
                key = StringUtils.removeEnd(key, SUFIJO);
                string = BundleMensajes.getString(key);
                key = isKey(string) ? string : "<" + key + ">";
                list.add(key);
            }
        }
        return (list.isEmpty()) ? null : list.toArray(new String[list.size()]);
    }
    return null;
}

From source file:gov.medicaid.services.util.Util.java

/**
 * Checks if the given value contains only digits.
 *
 * @param value the value to check/*from  w  w  w . jav  a 2s  .c o  m*/
 * @return true if only digits are included
 */
public static boolean isDigits(String value) {
    return value.matches("[0-9]+");
}

From source file:com.ms.commons.utilities.StaticContentDeploy.java

public static synchronized void init() {
    String staticVersion = getStaticVersion();
    if (StringUtils.isBlank(staticVersion) || StringUtils.equals(staticVersion, "0")
            || !staticVersion.matches("\\d+")) {
        staticVersion = StringUtils.EMPTY;
    }// ww w .jav a 2s.  c  om
    StaticContentDeploy.jsVersion = staticVersion;
    StaticContentDeploy.imgVersion = staticVersion;
    StaticContentDeploy.cssVersion = staticVersion;
}

From source file:net.padaf.preflight.font.AbstractFontValidator.java

public static boolean isSubSet(String fontName) {
    return fontName.matches(subSetPattern);
}

From source file:com.launchkey.sdk.crypto.JCECrypto.java

private static byte[] getKeyBytesFromPEM(String pem) {
    StringBuilder strippedKey = new StringBuilder();
    for (String line : pem.split("\n")) {
        if (!line.matches(".*(BEGIN|END) (RSA )?(PUBLIC|PRIVATE) KEY.*")) {
            strippedKey.append(line.trim());
        }// www  . j  a  v  a  2 s  .  c om
    }
    return BASE_64.decode(strippedKey.toString().getBytes());
}

From source file:edu.cornell.mannlib.vitro.webapp.utils.jena.URIUtils.java

public static boolean hasExistingURI(String uriStr, OntModel ontModel) {
    boolean existingURI = false;
    ontModel.enterCriticalSection(Lock.READ);
    try {/*from  w w  w  . java2  s  . c  o  m*/
        boolean validPropertyURI = true;
        String localName = uriStr.substring(uriStr.lastIndexOf("/") + 1);
        //if local name is only numbers, this is not a valid uri for a property
        if (localName.matches("\\d+")) {
            validPropertyURI = false;
        }
        Resource newURIAsRes = ResourceFactory.createResource(uriStr);

        StmtIterator closeIt = ontModel.listStatements(newURIAsRes, null, (RDFNode) null);
        if (closeIt.hasNext()) {
            existingURI = true;

        }
        //if not in the subject position, check in object position
        if (!existingURI) {
            closeIt = ontModel.listStatements(null, null, newURIAsRes);
            if (closeIt.hasNext()) {
                existingURI = true;
            }
        }
        //Check for property
        if (validPropertyURI && !existingURI) {
            Property newURIAsProp = ResourceFactory.createProperty(uriStr);
            closeIt = ontModel.listStatements(null, newURIAsProp, (RDFNode) null);
            if (closeIt.hasNext()) {
                existingURI = true;
            }
        }
    } finally {
        ontModel.leaveCriticalSection();
    }

    return existingURI;
}

From source file:airbrake.Backtrace.java

public static boolean isValidBacktrace(String string) {
    return string.matches("[^:]*:\\d+.*");
}

From source file:jp.co.opentone.bsol.framework.test.util.ExpectedMessageStringGenerator.java

public static String generate(String msg, String actionName, Object... vars) {

    if (StringUtils.isNotEmpty(actionName)) {
        msg = msg.replace("$action$", "?[" + actionName + "]");
    }//ww  w  . java2 s. co  m

    assertTrue(!msg.matches("\\$action\\$"));

    String result = MessageFormat.format(msg, vars);
    assertTrue(!result.matches("\\{[0-9]+\\}"));

    return result;
}

From source file:fr.paris.lutece.plugins.genericattributes.util.GenericAttributesUtils.java

/**
 * Convert a string to int//from  w w w  .  j a  v  a 2 s.  c  o m
 * @param strParameter the string parameter to convert
 * @return the conversion
 */
public static int convertStringToInt(String strParameter) {
    int nIdParameter = -1;

    try {
        if ((strParameter != null) && strParameter.matches(REGEX_ID)) {
            nIdParameter = Integer.parseInt(strParameter);
        }
    } catch (NumberFormatException ne) {
        AppLogService.error(ne);
    }

    return nIdParameter;
}

From source file:com.sap.core.odata.core.edm.EdmBinary.java

private static boolean validateLiteral(final String value, final EdmLiteralKind literalKind) {
    return literalKind == EdmLiteralKind.URI ? value.matches("(?:X|binary)'(?:\\p{XDigit}{2})*'")
            : Base64.isBase64(value);/*  w  w  w  .j ava  2  s. co  m*/
}