List of usage examples for java.lang String matches
public boolean matches(String regex)
From source file:com.lepin.activity.MyCarVeficActivity.java
/** * ????/*from www .j a v a2 s . c o m*/ * * @param string * @return */ public static boolean isNumberOrLetter(String string) { return string.matches("^[A-Za-z0-9]+$"); }
From source file:org.wso2.carbon.appmgt.gateway.handlers.Utils.java
public static void sendFault(MessageContext messageContext, int status) { org.apache.axis2.context.MessageContext axis2MC = ((Axis2MessageContext) messageContext) .getAxis2MessageContext(); axis2MC.setProperty(NhttpConstants.HTTP_SC, status); messageContext.setResponse(true);/*from ww w . j a v a 2 s .c om*/ messageContext.setProperty("RESPONSE", "true"); messageContext.setTo(null); axis2MC.removeProperty("NO_ENTITY_BODY"); String method = (String) axis2MC.getProperty(Constants.Configuration.HTTP_METHOD); if (method.matches("^(?!.*(POST|PUT)).*$")) { // If the request was not an entity enclosing request, send a XML response back axis2MC.setProperty(Constants.Configuration.MESSAGE_TYPE, "application/xml"); } // Always remove the ContentType - Let the formatter do its thing axis2MC.removeProperty(Constants.Configuration.CONTENT_TYPE); Map headers = (Map) axis2MC.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); if (headers != null) { headers.remove(HttpHeaders.AUTHORIZATION); // headers.remove(HttpHeaders.ACCEPT); headers.remove(HttpHeaders.AUTHORIZATION); //headers.remove(HttpHeaders.ACCEPT); //Default we will send xml out put if error_message_type is json then we will send json response to client // We can set this parameter in _auth_failure_handler_ as follows /*<sequence name="_auth_failure_handler_"> <property name="error_message_type" value="application/json"/> <sequence key="_build_"/> </sequence> */ if (messageContext.getProperty("error_message_type") != null && messageContext .getProperty("error_message_type").toString().equalsIgnoreCase("application/json")) { axis2MC.setProperty(Constants.Configuration.MESSAGE_TYPE, "application/json"); } headers.remove(HttpHeaders.HOST); } Axis2Sender.sendBack(messageContext); }
From source file:com.edgenius.test.TestUtil.java
/** * @param outAtt/*from w ww. j ava2 s . c o m*/ * @param inAtt * @param dynamicAttMap */ private static boolean compareWajx(String outAtt, String inAtt, Map<String, String> dynamicAttMap) { //parse wajax Map<String, String> inWajxMap = RichTagUtil.parseWajaxAttribute(inAtt); Map<String, String> outWajxMap = RichTagUtil.parseWajaxAttribute(outAtt); if (inWajxMap.size() != outWajxMap.size()) return false; for (java.util.Map.Entry<String, String> entry : inWajxMap.entrySet()) { String outValue = outWajxMap.get(entry.getKey()); String inValue = entry.getValue(); //dynamic attribute value if (inValue.matches("\\$\\$DD\\d\\$\\$")) { if (checkDynamicAttribute(dynamicAttMap, outValue, inValue)) { continue; } else { return false; } } if (!StringUtils.equals(inValue, outValue)) { return false; } } return true; }
From source file:com.adobe.communities.ugc.migration.export.MessagesExportServlet.java
private static void writeObject(final JSONWriter writer, final JSONObject object) throws JSONException { final Iterator<String> keys = object.keys(); while (keys.hasNext()) { final String key = keys.next(); writer.key(key);/* www . j av a2 s. co m*/ final Object value = object.get(key); if (value instanceof JSONObject) { writer.object(); writeObject(writer, (JSONObject) value); writer.endObject(); } else { final String valString = value.toString(); if (valString.matches("^[0-9]+$")) { writer.value(Long.parseLong(valString)); } else if (key.equals("read") || key.equals("deleted")) { writer.value(value); } else { writer.value(valString); } } } }
From source file:com.hemou.android.util.StrUtils.java
public static boolean isIllegalPswd(String pswd) { return TextUtils.isEmpty(pswd) || pswd.matches(AppCons.REG_CHAR) || pswd.matches(AppCons.REG_NUM) || pswd.length() < AppCons.MIN_PSWD_LEN; }
From source file:com.ibm.mqlight.api.security.KeyStoreUtils.java
/** * Attempts to load the specified file as a {@link KeyStore}, determining the key store type from the file extension. * * @param file the file containing the key store to be loaded. * @param password password for the key store file. * @return A {@link KeyStore} instance loaded from the specified file. * @throws KeyStoreException if no KeyStore provider supports the key store type (inferred from the key store file extension). * @throws NoSuchAlgorithmException if an unknown algorithm is used to check key store identity. * @throws CertificateException if certificates from the key store could not be loaded. * @throws IOException if there is a problem accessing the key store file. *///from w ww . j av a 2 s .c o m public static KeyStore loadKeyStore(File file, String password) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { final String methodName = "loadKeyStore"; logger.entry(methodName, file); final String fileName = file.getName(); final java.security.KeyStore keyStore; if (fileName.matches("(?i).*\\.jks")) { keyStore = java.security.KeyStore.getInstance("JKS"); } else if (fileName.matches("(?i).*\\.jceks")) { keyStore = java.security.KeyStore.getInstance("JCEKS"); } else if (fileName.matches("(?i).*\\.p12") || fileName.matches("(?i).*\\.pkcs12")) { keyStore = java.security.KeyStore.getInstance("PKCS12"); } else if (fileName.matches("(?i).*\\.kdb")) { keyStore = java.security.KeyStore.getInstance("CMSKS"); } else { final String keyStoreType = java.security.KeyStore.getDefaultType(); keyStore = java.security.KeyStore.getInstance(keyStoreType); } java.io.FileInputStream fileInputStream = null; try { fileInputStream = new java.io.FileInputStream(file); final char[] passwordChars; if (password == null) { passwordChars = null; // TODO would be useful if we could attempt to read the password from an associated stash file. } else { passwordChars = password.toCharArray(); } keyStore.load(fileInputStream, passwordChars); } finally { if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e) { logger.data(methodName, (Object) "failed to close file: ", file, " reason", e); } } } logger.exit(methodName, keyStore); return keyStore; }
From source file:com.hemou.android.util.StrUtils.java
public static boolean isIllegalAcnt(String acnt) { return TextUtils.isEmpty(acnt) || (acnt.matches(AppCons.REG_PHONE_NUM) && acnt.matches(Rules.REGEX_EMAIL)); }
From source file:com.hemou.android.util.StrUtils.java
public static boolean isIllegalDynamicToken(String token) { return TextUtils.isEmpty(token) || !token.matches(AppCons.REG_DYNAMIC_TOKEN); }
From source file:controllers.oer.Application.java
private static FilterBuilder locationFilter(String location) { if (location.matches(".*\\d+.*")) return polygonFilter(location); else//from ww w . j av a 2 s . c om return FilterBuilders.hasParentFilter("geonames-type", QueryBuilders.queryString(location).field("_all")); }
From source file:com.github.wnameless.json.unflattener.JsonUnflattener.java
private static boolean isJsonArray(String keyPart) { return keyPart.matches(arrayIndex); }