List of usage examples for java.util.regex Matcher quoteReplacement
public static String quoteReplacement(String s)
From source file:org.entando.edo.builder.TestBuilderNoPlugin.java
@Test public void test_Service_Api_Java() throws IOException { String commonPath = "src/main/java/com/myportal/aps/system/services/cat/api".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(5, actualFiles.size()); this.compareFiles(actualFiles); }
From source file:net.ymate.framework.core.taglib.ui.BaseUITag.java
public void writerToCssPart(String content) { __tmplCssPart.append(Matcher.quoteReplacement(content)); }
From source file:org.entando.edo.builder.TestBuilder.java
@Test public void test_Service_Api_Java() throws IOException { String commonPath = "src/main/java/org/entando/entando/plugins/jppet/aps/system/services/cat/api" .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(5, actualFiles.size()); this.compareFiles(actualFiles); }
From source file:org.wso2.cep.integration.common.utils.CEPIntegrationTest.java
/** * @param testCaseFolderName testCaseFolderName Name of the folder created under /artifacts/CEP for the particular test case. * @param configFileName Name of the JSON config-file created under above folder. * @return The above JSON-configuration, as a string * @throws Exception//w w w . ja va 2 s . c o m */ protected String getJSONArtifactConfiguration(String testCaseFolderName, String configFileName) throws Exception { String relativeFilePath = getTestArtifactLocation() + CEPIntegrationTestConstants.RELATIVE_PATH_TO_TEST_ARTIFACTS + testCaseFolderName + "/" + configFileName; relativeFilePath = relativeFilePath.replaceAll("[\\\\/]", Matcher.quoteReplacement(File.separator)); JSONParser jsonParser = new JSONParser(); return jsonParser.parse(new FileReader(relativeFilePath)).toString(); }
From source file:pt.webdetails.cdv.CdvContentGenerator.java
private JSONObject createTest(String origin, String newPath) throws JSONException { JSONObject result = new JSONObject(); if (!newPath.endsWith(".cdv")) { newPath = newPath + ".cdv"; }/*from ww w . ja va 2 s . co m*/ String newFileName = Util.joinPath(CdvEnvironment.getPluginRepositoryDir(), CdvConstants.SolutionFolders.TESTS, newPath); IRWAccess pluginRepo = CdvEnvironment.getPluginRepositoryWriter("tests"); IReadAccess systemRepo = CdvEnvironment.getPluginSystemReader(); IReadAccess contentRepo = CdvEnvironment.getUserContentAccess(); try { if (pluginRepo.fileExists(newPath)) { logger.error("New File already exists, aborting creation of new test"); result.put("success", "false"); return result; } InputStream inputStream; if (StringUtils.isEmpty(origin)) { inputStream = systemRepo.getFileInputStream("validationTemplate.cdv"); } else { inputStream = contentRepo.getFileInputStream(origin); } StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer, CharsetHelper.getEncoding()); String originalTest = writer.toString(); originalTest = Pattern.compile("path:\\s*['\"].*['\"]\\s*,").matcher(originalTest) .replaceFirst("path: '" + newFileName + "',"); originalTest = Pattern.compile("name:\\s*['\"].*['\"]\\s*,").matcher(originalTest) .replaceFirst("name: '" + newFileName.substring(newFileName.lastIndexOf("/") + 1) .replaceAll(Matcher.quoteReplacement(".cdv"), "") + "',"); originalTest = Pattern.compile("createdBy:\\s*['\"].*['\"]\\s*,").matcher(originalTest) .replaceFirst("createdBy: '" + PentahoSessionHolder.getSession().getName() + "',"); inputStream = new ByteArrayInputStream(originalTest.getBytes(CharsetHelper.getEncoding())); pluginRepo.saveFile(newPath, inputStream); result.put("success", "true"); result.put("path", newFileName); } catch (IOException ioe) { logger.error("Error while creating test file", ioe); result.put("success", "false"); } return result; }
From source file:de.mpg.escidoc.services.syndication.Utils.java
/** * Quote <code>{}</code>//from w w w.j a v a2s. c o m * @param str * @return quoted <code>str</code> */ public static String quoteReplacement(String str) { return Matcher.quoteReplacement(str).replace("{", "\\{").replace("}", "\\}"); }
From source file:net.ymate.framework.core.taglib.ui.BaseUITag.java
public void writerToScriptPart(String content) { __tmplScriptPart.append(Matcher.quoteReplacement(content)); }
From source file:org.springframework.integration.ftp.outbound.FtpServerOutboundTests.java
@Test public void testInt2866LocalDirectoryExpressionGET() { String dir = "ftpSource/"; long modified = setModifiedOnSource1(); this.inboundGet.send(new GenericMessage<Object>(dir + " ftpSource1.txt")); Message<?> result = this.output.receive(1000); assertNotNull(result);// w w w .ja v a2 s .c o m File localFile = (File) result.getPayload(); assertThat(localFile.getPath().replaceAll(Matcher.quoteReplacement(File.separator), "/"), containsString(dir.toUpperCase())); assertPreserved(modified, localFile); dir = "ftpSource/subFtpSource/"; this.inboundGet.send(new GenericMessage<Object>(dir + "subFtpSource1.txt")); result = this.output.receive(1000); assertNotNull(result); localFile = (File) result.getPayload(); assertThat(localFile.getPath().replaceAll(Matcher.quoteReplacement(File.separator), "/"), containsString(dir.toUpperCase())); }
From source file:org.jvnet.hudson.plugins.backup.utils.BackupTask.java
/** * Returns a file filter filtering files/dirs to NOT include from jobs' workspace * (this means the returned file filter is already a negation). *//*from ww w. ja va 2 s. c o m*/ public static IOFileFilter createJobsExclusionFileFilter(String hudsonWorkDir, String jobIncludes, String jobExcludes, boolean caseSensitive) { // directory scanning will be done from the HUDSON_HOME/jobs directory DirectoryScanner directoryScanner = new DirectoryScanner(); directoryScanner.setBasedir(new File(hudsonWorkDir, JOBS_NAME)); directoryScanner.setCaseSensitive(caseSensitive); // for each specified inclusion, we need to prefix it with "*/workspace" // to match the workspace directory of each job if (jobIncludes != null && jobIncludes.length() > 0) { // jobIncludes looks like file1,fil2,dir1/**,dir2/* // we need to prefix the first element in the list with "*/workspace" jobIncludes = jobIncludes.replaceAll(Matcher.quoteReplacement("\\"), "/"); jobIncludes = "*/" + WORKSPACE_NAME + '/' + jobIncludes; // we do the same for all other elements in the list jobIncludes = jobIncludes.replaceAll(",", ",*/" + WORKSPACE_NAME + '/'); directoryScanner.setIncludes(jobIncludes.split(",")); } else { directoryScanner.setIncludes(null); } // the same is done for exclusions if (jobExcludes != null && jobExcludes.length() > 0) { jobExcludes = jobExcludes.replaceAll(Matcher.quoteReplacement("\\"), "/"); jobExcludes = "*/" + WORKSPACE_NAME + '/' + jobExcludes; jobExcludes = jobExcludes.replaceAll(",", ",*/" + WORKSPACE_NAME + '/'); directoryScanner.setExcludes(jobExcludes.split(",")); } else { directoryScanner.setExcludes(null); } directoryScanner.scan(); FileFilter ff = new SimpleFileFilter(directoryScanner.getBasedir(), directoryScanner.getExcludedDirectories(), directoryScanner.getExcludedFiles()); return FileFilterUtils.notFileFilter(new DelegateFileFilter(ff)); }
From source file:net.ymate.framework.core.taglib.ui.BaseUITag.java
public void putProperty(String key, String value) { __tmplPropertyPart.put(key, Matcher.quoteReplacement(value)); }