List of usage examples for java.util.regex Pattern quote
public static String quote(String s)
From source file:de.tarent.maven.plugins.pkg.AbstractMvnPkgPluginTestCase.java
protected boolean debContainsArtifact(String s) throws MojoExecutionException, IOException { final Pattern p = Pattern.compile(".*" + Pattern.quote(s) + ".*"); return debContains(p, "-c"); }
From source file:alfio.manager.CheckInManager.java
public static String decrypt(String key, String payload) { try {/*from w ww . j a v a2 s . c o m*/ Pair<Cipher, SecretKeySpec> cipherAndSecret = getCypher(key); Cipher cipher = cipherAndSecret.getKey(); String[] splitted = payload.split(Pattern.quote("|")); byte[] iv = Base64.decodeBase64(splitted[0]); byte[] body = Base64.decodeBase64(splitted[1]); cipher.init(Cipher.DECRYPT_MODE, cipherAndSecret.getRight(), new IvParameterSpec(iv)); byte[] decrypted = cipher.doFinal(body); return new String(decrypted, StandardCharsets.UTF_8); } catch (GeneralSecurityException e) { throw new IllegalStateException(e); } }
From source file:com.bluexml.side.Framework.alfresco.notification.NotificationPolicy.java
protected String getSiteShortName(NodeRef node) { Path path = serviceRegistry.getNodeService().getPath(node); logger.debug("Node path :" + path); String regExpSiteName = ".*" + Pattern.quote(SiteModel.TYPE_SITES.toString()) + "/\\{[^}]*\\}([^/]+)/.*"; String pathString = path.toString(); String siteShortName = null;// w ww .j a v a 2 s . c o m if (Pattern.matches(regExpSiteName, pathString)) { // get site short name siteShortName = pathString.replaceFirst(regExpSiteName, "$1"); } return siteShortName; }
From source file:it.analysis.IssueJsonReportTest.java
private String expected(String path) throws IOException { try (WsResponse response = newWsClient(orchestrator).wsConnector() .call(new GetRequest("api/server/version"))) { String version = response.content(); return sanitize(IOUtils.toString(getResourceInputStream(path))) .replaceAll(Pattern.quote(SONAR_VERSION_PLACEHOLDER), version); }/*w w w .java 2 s .com*/ }
From source file:de.tarent.maven.plugins.pkg.AbstractMvnPkgPluginTestCase.java
protected boolean ipkContainsArtifact(String s) throws MojoExecutionException, IOException { final Pattern p = Pattern.compile(".*" + Pattern.quote(s) + ".*"); return ipkContains(p, "-c"); }
From source file:com.hubrick.raml.mojo.AbstractSpringWebMojo.java
private String getBodySchema(Map<String, MimeType> requestBody, String contentType) { if (requestBody == null) { return null; }//from w w w . j av a 2 s.co m final String[] split = contentType.split("/", 2); if (split.length != 2) { return null; } final String extensionReplacementRegexp = String.format("(?<=%s/)(.*\\+)(?=%s)", Pattern.quote(split[0]), Pattern.quote(split[1])); return requestBody.entrySet().stream() .filter(e -> e.getKey().replaceAll(extensionReplacementRegexp, "").equals(contentType)) .map(e -> e.getValue()).map(e -> e.getSchema()).findFirst().orElse(null); }
From source file:com.dattasmoon.pebble.plugin.NotificationService.java
private void sendToPebble(String title, String notificationText) { title = title.trim();/*ww w .j a va 2 s. co m*/ notificationText = notificationText.trim(); if (title.trim().isEmpty() || notificationText.isEmpty()) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Detected empty title or notification text, skipping"); } return; } for (int i = 0; i < converts.length(); i++) { String from; String to; try { JSONObject convert = converts.getJSONObject(i); from = "(?i)" + Pattern.quote(convert.getString("from")); to = convert.getString("to"); } catch (JSONException e) { continue; } //not sure if the title should be replaced as well or not. I'm guessing not //title = title.replaceAll(from, to); notificationText = notificationText.replaceAll(from, to); } // Create json object to be sent to Pebble final Map<String, Object> data = new HashMap<String, Object>(); data.put("title", title); data.put("body", notificationText); final JSONObject jsonData = new JSONObject(data); final String notificationData = new JSONArray().put(jsonData).toString(); // Create the intent to house the Pebble notification final Intent i = new Intent(Constants.INTENT_SEND_PEBBLE_NOTIFICATION); i.putExtra("messageType", Constants.PEBBLE_MESSAGE_TYPE_ALERT); i.putExtra("sender", getString(R.string.app_name)); i.putExtra("notificationData", notificationData); // Send the alert to Pebble if (Constants.IS_LOGGABLE) { Log.d(Constants.LOG_TAG, "About to send a modal alert to Pebble: " + notificationData); } sendBroadcast(i); notification_last_sent = System.currentTimeMillis(); }
From source file:de.mpg.escidoc.services.reporting.ReportFHI.java
/** * Joins the elements of the provided array into a single String containing the provided list of elements. * Separator will be put between the not null/empty elements * @param arr is the list of the elements. * @param delimiter /*w ww .ja va 2 s.co m*/ * @return joined string */ public static String join(String[] arr, String delimiter) { if (arr == null || arr.length == 0) return null; StringBuffer sb = new StringBuffer(); if (delimiter == null) delimiter = ""; for (int i = 0, n = arr.length; i < n; i++) { if (arr[i] == null || arr[i].trim().equals("")) continue; sb.append(arr[i]); if (i < n - 1) sb.append(delimiter); } String str = sb.toString().replaceAll(Pattern.quote(delimiter) + "$", ""); return str; }
From source file:com.adobe.ags.curly.controller.ActionRunner.java
private void applyVariables(Map<String, String> variables) { Set<String> variableTokens = ActionUtils.getVariableNames(action); variableTokens.forEach((String originalName) -> { String[] parts = originalName.split("\\|"); String var = parts[0]; String replaceVar = Pattern.quote("${" + originalName + "}"); String replace = variables.get(var) == null ? "" : variables.get(var); URL = URL.replaceAll(replaceVar, Matcher.quoteReplacement(replace)); putFile = putFile.replaceAll(replaceVar, Matcher.quoteReplacement(replace)); });/* w w w . j a v a 2 s . c o m*/ applyMultiVariablesToMap(variables, postVariables); applyMultiVariablesToMap(variables, getVariables); applyVariablesToMap(variables, requestHeaders); }
From source file:org.jboss.as.test.integration.security.auditing.CustomAuditProviderModuleTest.java
@Test public void testBaduser1() throws Exception { /*/*www .j a v a 2 s . c o m*/ * baduser1 can authenticate, because we use the correct password, but he does not have the "gooduser" role required by * SecuredServlet and the server thus return 403 rather than 401 */ assertResponse(CustomLoginModule1.BADUSER1_USERNAME, CustomLoginModule1.BADUSER1_PASSWORD, 403); try (BufferedReader r = Files.newBufferedReader(AUDIT_LOG_PATH, UTF_8)) { assertAuditLog(r, Pattern.quote("INFO " + CustomAuditProviderModule.class.getName() + " [Success]principal=" + CustomLoginModule1.BADUSER1_USERNAME + ";")); } }