List of usage examples for java.util.regex Matcher quoteReplacement
public static String quoteReplacement(String s)
From source file:org.entando.edo.builder.Filebuilder.java
public static String getEntandoPojoInitFilePath(EdoBean bean) { String pojoPath = bean.getEdoBuilder().getBaseDir() + FolderConstants.getJavaFolder() + bean.getEdoBuilder().getPackageName().replaceAll("\\.", Matcher.quoteReplacement(File.separator)) + File.separator + FolderConstants.getInitFolder() + File.separator; String filename = bean.getName() + ".java"; String finalfile = pojoPath + filename; return finalfile; }
From source file:org.wso2.carbon.ui.filters.CSRFProtector.java
/** * Generates and injects CSRF Token in the response as a hidden parameter * * @param request HTTPServerRequest instance * @param responseWrapper HTTPServerletResponseWrapper instance * @throws IOException//from w w w . ja v a 2 s . c o m */ public void enforceProtection(HttpServletRequest request, CSRFResponseWrapper responseWrapper) throws IOException { HttpSession session = request.getSession(false); if (session != null) { String CSRFSessionToken = getCSRFTokenFromSession(session); if (CSRFSessionToken == null) { setCSRFTokenForSession(session); } CSRFSessionToken = getCSRFTokenFromSession(session); String content = new String(responseWrapper.getContent()); content = CSRFConstants.HTML_HEAD_PATTERN.matcher(content) .replaceAll("<script type=\"text/javascript\">\n" + Matcher.quoteReplacement(getInjectingJS(CSRFSessionToken)) + "\n</script>\n</head>"); responseWrapper.setContent(content); responseWrapper.write(); } }
From source file:org.entando.edo.builder.TestBuilderNoPlugin.java
@Test public void test_Service_Init_Sql() throws IOException { String commonPath = "src/main/resources/sql/misc/sandbox".replaceAll("/", Matcher.quoteReplacement(File.separator)); String actualPath = ACTUAL_BASE_FOLDER + commonPath; File actualDir = new File(actualPath); Assert.assertTrue(actualDir.exists()); List<File> actualFiles = this.searchFiles(actualDir, null); Assert.assertEquals(2, actualFiles.size()); this.compareFiles(actualFiles); }
From source file:org.entando.edo.builder.TestBuilder.java
@Test public void test_Service_Init_Sql() throws IOException { String commonPath = "src/main/resources/sql/plugins/jppet".replaceAll("/", Matcher.quoteReplacement(File.separator)); String actualPath = ACTUAL_BASE_FOLDER + commonPath; File actualDir = new File(actualPath); Assert.assertTrue(actualDir.exists()); List<File> actualFiles = this.searchFiles(actualDir, null); Assert.assertEquals(2, actualFiles.size()); this.compareFiles(actualFiles); }
From source file:net.sourceforge.pmd.lang.xml.ast.DOMLineNumbers.java
private String unexpandEntities(Node n, String te) { String result = te;//from ww w.j a v a 2s . c om DocumentType doctype = n.getOwnerDocument().getDoctype(); // implicit entities result = result.replaceAll(Matcher.quoteReplacement("&"), "&"); result = result.replaceAll(Matcher.quoteReplacement("<"), "<"); result = result.replaceAll(Matcher.quoteReplacement(">"), ">"); result = result.replaceAll(Matcher.quoteReplacement("\""), """); result = result.replaceAll(Matcher.quoteReplacement("'"), "'"); if (doctype != null) { NamedNodeMap entities = doctype.getEntities(); String internalSubset = doctype.getInternalSubset(); if (internalSubset == null) { internalSubset = ""; } for (int i = 0; i < entities.getLength(); i++) { Node item = entities.item(i); String entityName = item.getNodeName(); Node firstChild = item.getFirstChild(); if (firstChild != null) { result = result.replaceAll(Matcher.quoteReplacement(firstChild.getNodeValue()), "&" + entityName + ";"); } else { Matcher m = Pattern .compile(Matcher.quoteReplacement("<!ENTITY " + entityName + " ") + "[']([^']*)[']>") .matcher(internalSubset); if (m.find()) { result = result.replaceAll(Matcher.quoteReplacement(m.group(1)), "&" + entityName + ";"); } } } } return result; }
From source file:cz.cas.lib.proarc.common.process.GenericExternalProcess.java
/** * Interpolate parameter values. The replace pattern is {@code ${name}}. * @param s a string to search for placeholders * @return the resolved string/*from www . j a v a2 s. c o m*/ * @see #addParameter(java.lang.String, java.lang.String) */ static String interpolateParameters(String s, Map<String, String> parameters) { if (s == null || s.length() < 4 || parameters.isEmpty()) { // minimal replaceable value ${x} return s; } // finds ${name} patterns Matcher m = REPLACE_PARAM_PATTERN.matcher(s); StringBuffer sb = null; while (m.find()) { if (m.groupCount() == 1) { String param = m.group(1); String replacement = parameters.get(param); if (replacement != null) { sb = sb != null ? sb : new StringBuffer(); m.appendReplacement(sb, Matcher.quoteReplacement(replacement)); } } } if (sb == null) { return s; } m.appendTail(sb); return sb.toString(); }
From source file:com.asual.summer.core.util.StringUtils.java
public static String decorate(String str, Properties values) { Matcher m = Pattern.compile("\\$\\{[^}]*\\}").matcher(str); while (m.find()) { String key = m.group().replaceAll("^\\$\\{|\\}$", ""); Object value = values.get(key); if (value != null) { str = str.replaceAll("\\$\\{" + key + "\\}", Matcher.quoteReplacement(value.toString())); }/*from w w w. j av a 2 s .c o m*/ } return str; }
From source file:org.wso2.carbon.integration.test.client.HttpEventPublisherClient.java
/** * File path will be created for the file to be read with respect to the artifact folder and file name * * @param testCaseFolderName Artifact folder name * @param dataFileName Text file to be read *//*from w w w. ja v a 2 s . co m*/ public static String getTestDataFileLocation(String testCaseFolderName, String dataFileName) throws Exception { String relativeFilePath = FrameworkPathUtil.getSystemResourceLocation() + CEPIntegrationTestConstants.RELATIVE_PATH_TO_TEST_ARTIFACTS + testCaseFolderName + File.separator + dataFileName; relativeFilePath = relativeFilePath.replaceAll("[\\\\/]", Matcher.quoteReplacement(File.separator)); return relativeFilePath; }
From source file:com.urbancode.x2o.xml.NamespaceConfiguration.java
public void loadNameSpaceFromClassPath(String nameSpace) { BidiMap biMap = new DualHashBidiMap(); String filePath = nameSpace.replaceAll("\\.", Matcher.quoteReplacement("/")); String resourceName = filePath + "/" + NAMESPACE_FILE; ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Properties props = new Properties(); log.debug("Looking for resource: " + resourceName); try {//from www . j av a2 s .co m props.load(classLoader.getResourceAsStream(resourceName)); } catch (IOException e) { log.error(e.getClass() + " caught in " + this.getClass()); // swallow } // build the biDirectionalMap for (Object prop : props.keySet()) { biMap.put(prop, props.getProperty((String) prop)); } log.debug("added following elements into map: " + biMap.keySet()); log.debug("Added following value: " + biMap.values()); nameSpaces.put(nameSpace, biMap); }
From source file:com.adaptris.core.services.metadata.PayloadFromMetadataService.java
private String munge(String s) { String result = s;/* ww w .jav a 2 s. c o m*/ if (escapeBackslash()) { // result = s.replaceAll("\\\\", "\\\\\\\\"); result = Matcher.quoteReplacement(s); } return result; }