List of usage examples for java.util.regex Pattern quote
public static String quote(String s)
From source file:de.wusel.partyplayer.gui.PartyPlayer.java
private JComponent createMainComponent() { JPanel mainPanel = new JPanel(new MigLayout("fill", "[][50%][][50%]", "[] [] [] [] [grow]")); mainPanel.add(new JLabel(getText("layout.current.title"))); mainPanel.add(new JSeparator(), "growx"); mainPanel.add(new JLabel(getText("layout.next.title"))); mainPanel.add(new JSeparator(), "growx, wrap"); mainPanel.add(createPlayerPanel(), "grow, span 2"); mainPanel.add(createPlayListPanel(), "grow, hmax 100, span 2, wrap"); mainPanel.add(new JLabel(getText("layout.available.title"))); mainPanel.add(new JSeparator(), "growx, span, wrap"); final JTextField searchField = new JTextField(); searchField.addKeyListener(new KeyAdapter() { @Override/*from w w w. j a v a 2 s . co m*/ public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { searchField.setText(null); table.setRowFilter(null); } try { table.setRowFilter( RowFilter.regexFilter("(?i)" + Pattern.quote(searchField.getText()), 0, 1, 3)); } catch (PatternSyntaxException ex) { table.setRowFilter(null); //do nothing } } }); mainPanel.add(new JLabel(getText("layout.search.label"))); mainPanel.add(searchField, "span, growx, wrap"); mainPanel.add(createSongPanel(), "span, grow"); return mainPanel; }
From source file:com.fiveamsolutions.nci.commons.validator.MultipleCriteriaMessageInterpolator.java
@SuppressWarnings("rawtypes") private String getErrorMessage(ValidationError ve, Validator validator, MessageInterpolator defaultInterpolator) { String error = interpolateWithDefault(ve.getErrorMessageKey(), validator, defaultInterpolator); for (Map.Entry<String, Object> replacement : ve.getErrorMessageReplacements().entrySet()) { String token = Pattern.quote("{" + replacement.getKey() + "}"); error = error.replaceAll(token, replacement.getValue().toString()); }/* ww w . j a va 2 s. c om*/ return error; }
From source file:unalcol.termites.boxplots.InformationCollected1.java
/** * Creates a sample dataset./*w w w . j ava2 s. c o m*/ * * @return A sample dataset. */ private BoxAndWhiskerCategoryDataset createSampleDataset(ArrayList<Double> Pf) { String sDirectorio = experimentsDir; System.out.println("experiments dir" + sDirectorio); File f = new File(sDirectorio); String extension; File[] files = f.listFiles(); Hashtable<String, String> Pop = new Hashtable<>(); PrintWriter escribir; Scanner sc = null; ArrayList<Integer> aPops = new ArrayList<>(); ArrayList<Double> aPf = new ArrayList<>(); ArrayList<String> aTech = new ArrayList<>(); final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); for (File file : files) { extension = ""; int i = file.getName().lastIndexOf('.'); int p = Math.max(file.getName().lastIndexOf('/'), file.getName().lastIndexOf('\\')); if (i > p) { extension = file.getName().substring(i + 1); } // System.out.println(file.getName() + "extension" + extension); if (file.isFile() && extension.equals("csv") && file.getName().startsWith("experiment") && file.getName().contains(mazeMode)) { System.out.println(file.getName()); System.out.println("get: " + file.getName()); String[] filenamep = file.getName().split(Pattern.quote("+")); System.out.println("file" + filenamep[8]); int popsize = Integer.valueOf(filenamep[2]); double pf = Double.valueOf(filenamep[4]); String mode = filenamep[6]; int maxIter = -1; //if (!filenamep[8].isEmpty()) { maxIter = Integer.valueOf(filenamep[8]); //} System.out.println("psize:" + popsize); System.out.println("pf:" + pf); System.out.println("mode:" + mode); System.out.println("maxIter:" + maxIter); //String[] aMode = {"random", "levywalk", "sandc", "sandclw"}; //String[] aMode = {"levywalk", "lwphevap", "hybrid", "hybrid3", "hybrid4", "sequential"}; if (/*Pf == pf && */isInMode(aMode, mode)) { final List list = new ArrayList(); try { sc = new Scanner(file); } catch (FileNotFoundException ex) { Logger.getLogger(DataCollectedLatexConsolidatorSASOMessagesSend1.class.getName()) .log(Level.SEVERE, null, ex); } int agentsCorrect = 0; int worldSize = 0; double averageExplored = 0.0; int bestRoundNumber = 0; double avgSend = 0; double avgRecv = 0; double avgdataExplInd = 0; ArrayList<Double> acSt = new ArrayList<>(); ArrayList<Double> avgExp = new ArrayList<>(); ArrayList<Double> bestR = new ArrayList<>(); ArrayList<Double> avSnd = new ArrayList<>(); ArrayList<Double> avRecv = new ArrayList<>(); ArrayList<Double> avIndExpl = new ArrayList<>(); String[] data = null; while (sc.hasNext()) { String line = sc.nextLine(); //System.out.println("line:" + line); data = line.split(","); agentsCorrect = Integer.valueOf(data[0]); //agentsIncorrect = Integer.valueOf(data[1]); // not used worldSize = Integer.valueOf(data[3]); averageExplored = Double.valueOf(data[4]); // data[3] stdavgExplored - not used bestRoundNumber = Integer.valueOf(data[6]); avgSend = Double.valueOf(data[7]); avgRecv = Double.valueOf(data[8]); avgdataExplInd = Double.valueOf(data[11]); //Add Data and generate statistics acSt.add((double) agentsCorrect); avgExp.add(averageExplored); avSnd.add(avgSend); avRecv.add(avgRecv); avIndExpl.add(avgdataExplInd); list.add(new Double(averageExplored / (double) worldSize * 100)); } LOGGER.debug("Adding series " + i); LOGGER.debug(list.toString()); if (Pf.contains(pf)) { /*pf == 1.0E-4 || pf == 3.0E-4*/ if (Pf.size() == 1) { dataset.add(list, popsize, getTechniqueName(mode)); } else { dataset.add(list, String.valueOf(popsize) + "-" + pf, getTechniqueName(mode)); } } } } } /*for (int i = 0; i < seriesCount; i++) { for (int j = 0; j < categoryCount; j++) { final List list = new ArrayList(); // add some values... for (int k = 0; k < entityCount; k++) { final double value1 = 10.0 + Math.random() * 3; list.add(new Double(value1)); final double value2 = 11.25 + Math.random(); // concentrate values in the middle list.add(new Double(value2)); } LOGGER.debug("Adding series " + i); LOGGER.debug(list.toString()); dataset.add(list, "Series " + i, " Type " + j); } }*/ return dataset; }
From source file:com.hangum.tadpole.rdb.core.editors.main.utils.ExtMakeContentAssistUtil.java
/** * /*from w w w. j a v a 2s . c om*/ * @param userDB * @param strQuery * @param strCursor */ private String getTableColumnAlias(final UserDBDAO userDB, final String strQuery, final String strCursor) { List<String> listName = new ArrayList<>(); TadpoleMetaData dbMetaData = TadpoleSQLManager.getDbMetadata(userDB); String strQuote = dbMetaData.getIdentifierQuoteString(); String strSeparator = "."; String strAlias = ""; if (StringUtils.indexOf(strCursor, strSeparator) != -1) { strAlias = StringUtils.substring(strCursor, 0, StringUtils.indexOf(strCursor, strSeparator)); } if (logger.isDebugEnabled()) { logger.debug("query is [" + strQuery + "]"); logger.debug("[quote]" + strQuote + " [alias]" + strAlias); } String tableNamePattern = "((?:" + strQuote + "(?:[.[^" + strQuote + "]]+)" + strQuote + ")|(?:[\\w" + Pattern.quote(strSeparator) + "]+))"; String structNamePattern; if (StringUtils.isEmpty(strAlias)) { structNamePattern = "(?:from|update|join|into)\\s*" + tableNamePattern; } else { structNamePattern = tableNamePattern + "(?:\\s*\\.\\s*" + tableNamePattern + ")?" + "\\s+(?:(?:AS)\\s)?" + strAlias + "[\\s,]+"; } try { Pattern aliasPattern = Pattern.compile(structNamePattern, Pattern.CASE_INSENSITIVE); Matcher matcher = aliasPattern.matcher(strQuery); if (!matcher.find()) { if (logger.isDebugEnabled()) logger.debug("=====> Not found match"); return ""; } if (matcher.groupCount() > 0) { for (int i = 1; i <= matcher.groupCount(); i++) { listName.add(matcher.group(i)); } } else { if (logger.isDebugEnabled()) logger.debug("=====> Not found object name"); return ""; } } catch (PatternSyntaxException e) { if (logger.isDebugEnabled()) logger.error("=====> find pattern exception"); return ""; } // find object column StringBuffer strColumnList = new StringBuffer(); for (String tblName : listName) { strColumnList.append(getAssistColumnList(userDB, tblName)).append(_PRE_GROUP); } return strColumnList.toString(); }
From source file:unalcol.termites.boxplots.MessagesSent1.java
/** * Creates a sample dataset.//from ww w . j a v a 2 s .c om * * @return A sample dataset. */ private BoxAndWhiskerCategoryDataset createSampleDataset(ArrayList<Double> Pf) { final int seriesCount = 5; final int categoryCount = 4; final int entityCount = 22; String sDirectorio = experimentsDir; File f = new File(sDirectorio); String extension; File[] files = f.listFiles(); Hashtable<String, String> Pop = new Hashtable<>(); PrintWriter escribir; Scanner sc = null; ArrayList<Integer> aPops = new ArrayList<>(); ArrayList<Double> aPf = new ArrayList<>(); ArrayList<String> aTech = new ArrayList<>(); final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); for (File file : files) { extension = ""; int i = file.getName().lastIndexOf('.'); int p = Math.max(file.getName().lastIndexOf('/'), file.getName().lastIndexOf('\\')); if (i > p) { extension = file.getName().substring(i + 1); } // System.out.println(file.getName() + "extension" + extension); if (file.isFile() && extension.equals("csv") && file.getName().startsWith("experiment") && file.getName().contains(mazeMode)) { System.out.println(file.getName()); System.out.println("get: " + file.getName()); String[] filenamep = file.getName().split(Pattern.quote("+")); System.out.println("file" + filenamep[8]); int popsize = Integer.valueOf(filenamep[2]); double pf = Double.valueOf(filenamep[4]); String mode = filenamep[6]; int maxIter = -1; //if (!filenamep[8].isEmpty()) { maxIter = Integer.valueOf(filenamep[8]); //} System.out.println("psize:" + popsize); System.out.println("pf:" + pf); System.out.println("mode:" + mode); System.out.println("maxIter:" + maxIter); //String[] aMode = {"random", "levywalk", "sandc", "sandclw"}; if (/*Pf == pf && */isInMode(aMode, mode)) { final List list = new ArrayList(); try { sc = new Scanner(file); } catch (FileNotFoundException ex) { Logger.getLogger(DataCollectedLatexConsolidatorSASOMessagesSend1.class.getName()) .log(Level.SEVERE, null, ex); } int agentsCorrect = 0; int worldSize = 0; double averageExplored = 0.0; int bestRoundNumber = 0; double avgSend = 0; double avgRecv = 0; double avgdataExplInd = 0; ArrayList<Double> acSt = new ArrayList<>(); ArrayList<Double> avgExp = new ArrayList<>(); ArrayList<Double> bestR = new ArrayList<>(); ArrayList<Double> avSnd = new ArrayList<>(); ArrayList<Double> avRecv = new ArrayList<>(); ArrayList<Double> avIndExpl = new ArrayList<>(); String[] data = null; while (sc.hasNext()) { String line = sc.nextLine(); //System.out.println("line:" + line); data = line.split(","); agentsCorrect = Integer.valueOf(data[0]); //agentsIncorrect = Integer.valueOf(data[1]); // not used worldSize = Integer.valueOf(data[3]); averageExplored = Double.valueOf(data[4]); // data[3] stdavgExplored - not used bestRoundNumber = Integer.valueOf(data[6]); avgSend = Double.valueOf(data[7]); avgRecv = Double.valueOf(data[8]); avgdataExplInd = Double.valueOf(data[11]); //Add Data and generate statistics acSt.add((double) agentsCorrect); avgExp.add(averageExplored); avSnd.add(avgSend); avRecv.add(avgRecv); avIndExpl.add(avgdataExplInd); list.add(new Double(avgSend)); } LOGGER.debug("Adding series " + i); LOGGER.debug(list.toString()); if (Pf.contains(pf)) { /*pf == 1.0E-4 || pf == 3.0E-4*/ if (Pf.size() == 1) { dataset.add(list, popsize, getTechniqueName(mode)); } else { dataset.add(list, String.valueOf(popsize) + "-" + pf, getTechniqueName(mode)); } } } } } /*for (int i = 0; i < seriesCount; i++) { for (int j = 0; j < categoryCount; j++) { final List list = new ArrayList(); // add some values... for (int k = 0; k < entityCount; k++) { final double value1 = 10.0 + Math.random() * 3; list.add(new Double(value1)); final double value2 = 11.25 + Math.random(); // concentrate values in the middle list.add(new Double(value2)); } LOGGER.debug("Adding series " + i); LOGGER.debug(list.toString()); dataset.add(list, "Series " + i, " Type " + j); } }*/ return dataset; }
From source file:unalcol.termites.boxplots.SucessfulRates.java
private static CategoryDataset createDataset(ArrayList<Double> Pf) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); String sDirectorio = experimentsDir; File f = new File(sDirectorio); String extension;//from w ww.j a v a 2 s.c om File[] files = f.listFiles(); Hashtable<String, String> Pop = new Hashtable<>(); PrintWriter escribir; Scanner sc = null; double sucessfulExp = 0.0; for (File file : files) { extension = ""; int i = file.getName().lastIndexOf('.'); int p = Math.max(file.getName().lastIndexOf('/'), file.getName().lastIndexOf('\\')); if (i > p) { extension = file.getName().substring(i + 1); } // System.out.println(file.getName() + "extension" + extension); if (file.isFile() && extension.equals("csv") && file.getName().startsWith("experiment") && file.getName().contains(mazeMode)) { System.out.println(file.getName()); System.out.println("get: " + file.getName()); String[] filenamep = file.getName().split(Pattern.quote("+")); System.out.println("file" + filenamep[8]); int popsize = Integer.valueOf(filenamep[2]); double pf = Double.valueOf(filenamep[4]); String mode = filenamep[6]; int maxIter = -1; //if (!filenamep[8].isEmpty()) { maxIter = Integer.valueOf(filenamep[8]); //} System.out.println("psize:" + popsize); System.out.println("pf:" + pf); System.out.println("mode:" + mode); System.out.println("maxIter:" + maxIter); //String[] aMode = {"random", "levywalk", "sandc", "sandclw"}; //String[] aMode = {"lwphclwevap", "lwsandc2", "lwsandc", "lwphevap2", "lwphevap"}; // String[] aMode = {"levywalk", "lwphevap", "hybrid"}; //String[] aMode = {"levywalk", "lwphevap", "hybrid", "hybrid3", "hybrid4", "sequential"}; if (isInMode(aMode, mode)) { final List list = new ArrayList(); try { sc = new Scanner(file); } catch (FileNotFoundException ex) { Logger.getLogger(DataCollectedLatexConsolidatorSASOMessagesSend1.class.getName()) .log(Level.SEVERE, null, ex); } int agentsCorrect = 0; int worldSize = 0; double averageExplored = 0.0; int bestRoundNumber = 0; double avgSend = 0; double avgRecv = 0; double avgdataExplInd = 0; ArrayList<Double> acSt = new ArrayList<>(); ArrayList<Double> avgExp = new ArrayList<>(); ArrayList<Double> bestR = new ArrayList<>(); ArrayList<Double> avSnd = new ArrayList<>(); ArrayList<Double> avRecv = new ArrayList<>(); ArrayList<Double> avIndExpl = new ArrayList<>(); String[] data = null; while (sc.hasNext()) { String line = sc.nextLine(); //System.out.println("line:" + line); data = line.split(","); agentsCorrect = Integer.valueOf(data[0]); //agentsIncorrect = Integer.valueOf(data[1]); // not used worldSize = Integer.valueOf(data[3]); averageExplored = Double.valueOf(data[4]); // data[3] stdavgExplored - not used bestRoundNumber = Integer.valueOf(data[6]); avgSend = Double.valueOf(data[7]); avgRecv = Double.valueOf(data[8]); avgdataExplInd = Double.valueOf(data[11]); //Add Data and generate statistics acSt.add((double) agentsCorrect); avgExp.add(averageExplored); avSnd.add(avgSend); avRecv.add(avgRecv); avIndExpl.add(avgdataExplInd); sucessfulExp = 0.0; for (int j = 0; j < acSt.size(); j++) { if (acSt.get(j) > 0) { sucessfulExp++; } } } if (Pf.contains(pf)) { defaultcategorydataset.addValue(((double) sucessfulExp) / acSt.size() * 100.0, "" + popsize, getTechniqueName(mode) + "\nPf:" + pf); /*pf == 1.0E-4 || pf == 3.0E-4*/ } } } } return defaultcategorydataset; }
From source file:eu.optimis.mi.monitoring_manager.resources.MonitorManagerQueryResourceHome.java
/** * Run all the get* methods (with the exception of * getLatestComplete*Resource methods) on multiple IPs. * //from w ww. j av a 2 s . co m * @param serviceId * @param methodName * @param parameters * @return MonitoringResourceDatasets */ @GET @Path("/MultipleIPs/{serviceId}/{methodName}/{parameters}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public MonitoringResourceDatasets getFromMultipleIPs(@PathParam("serviceId") String serviceId, @PathParam("methodName") String methodName, @PathParam("parameters") String parameters) { CloudOptimizerRESTClient co = new CloudOptimizerRESTClient(); // Get list of VMs. List<String> vmsList = co.getVMsIdsOfService(serviceId); // Get list of physical node ids and list of IP addresses needed to call // the endpoints. HashMap<String, List<String>> map = getMultipleIpMap(vmsList); List<String> ipAddresses = map.get("ipAddresses"); List<String> physicalIds = map.get("nodes"); // Debug printList(vmsList, "vmsList"); printList(ipAddresses, "ipAddresses"); printList(physicalIds, "physicalIds"); MonitoringResourceDatasets mrds = new MonitoringResourceDatasets(); Client client = Client.create(); String paramArray[] = parameters.split(Pattern.quote(".")); logger.debug("parameter array:" + Arrays.toString(paramArray)); // [6] a, b, c if (methodName.equals("getReportForAllVirtual") || methodName.equals("getReportForAllPhysical") || methodName.equals("getReportForAllEnergy")) { for (String ip : ipAddresses) { String url = this.getAddress(ip, methodName); WebResource service = client.resource(url); MonitoringResourceDatasets dataSet = service.get(MonitoringResourceDatasets.class); mrds.getMonitoring_resource().addAll(dataSet.getMonitoring_resource()); } return mrds; } // [5][8] a, b, c, d else if (methodName.equals("getReportForService") || methodName.equals("getReportForVirtual") || methodName.equals("getReportForPhysical") || methodName.equals("getReportForEnergy") || methodName.equals("getLatestReportForService") || methodName.equals("getLatestReportForVirtual") || methodName.equals("getLatestReportForPhysical") || methodName.equals("getLatestReportForEnergy")) { for (String ip : ipAddresses) { String id = paramArray[0]; String url = this.getAddress(ip, methodName) + "/" + id; WebResource service = client.resource(url); logger.debug("url = " + url); MonitoringResourceDatasets dataSet = service.get(MonitoringResourceDatasets.class); mrds.getMonitoring_resource().addAll(dataSet.getMonitoring_resource()); } return mrds; } // [10] a, b, c, d else if (methodName.equals("getReportForPartService") || methodName.equals("getReportForPartVirtual") || methodName.equals("getReportForPartPhysical") || methodName.equals("getReportForPartEnergy")) { for (String ip : ipAddresses) { String dateFrom = paramArray[0]; String dateTo = paramArray[1]; String url = this.getAddress(ip, methodName) + "/" + dateFrom + "." + dateTo; WebResource service = client.resource(url); logger.debug("url = " + url); MonitoringResourceDatasets dataSet = service.get(MonitoringResourceDatasets.class); mrds.getMonitoring_resource().addAll(dataSet.getMonitoring_resource()); } return mrds; } // [11] a, b, c, d else if (methodName.equals("getReportForPartServiceId") || methodName.equals("getReportForPartVirtualId") || methodName.equals("getReportForPartPhysicalId") || methodName.equals("getReportForPartEnergyId")) { for (String ip : ipAddresses) { String id = paramArray[0]; String dateFrom = paramArray[1]; String dateTo = paramArray[2]; String url = this.getAddress(ip, methodName) + "/" + id + "/" + dateFrom + "." + dateTo; WebResource service = client.resource(url); logger.debug("url = " + url); MonitoringResourceDatasets dataSet = service.get(MonitoringResourceDatasets.class); mrds.getMonitoring_resource().addAll(dataSet.getMonitoring_resource()); } return mrds; } // [7] [9] else if (methodName.equals("getReportForMetric") || methodName.equals("getLatestReportForMetricName")) { for (String ip : ipAddresses) { String metricName = paramArray[0]; String resourceType = paramArray[1]; String url = this.getAddress(ip, methodName) + "/" + metricName + "/" + resourceType; WebResource service = client.resource(url); logger.debug("url = " + url); MonitoringResourceDatasets dataSet = service.get(MonitoringResourceDatasets.class); mrds.getMonitoring_resource().addAll(dataSet.getMonitoring_resource()); } return mrds; } // [12] else if (methodName.equals("getReportForPartMetricName")) { for (String ip : ipAddresses) { String metricName = paramArray[0]; String resourceType = paramArray[1]; String dateFrom = paramArray[2]; String dateTo = paramArray[3]; String url = this.getAddress(ip, methodName) + "/" + metricName + "/" + resourceType + "/" + dateFrom + "." + dateTo; WebResource service = client.resource(url); logger.debug("url = " + url); MonitoringResourceDatasets dataSet = service.get(MonitoringResourceDatasets.class); mrds.getMonitoring_resource().addAll(dataSet.getMonitoring_resource()); } return mrds; } else return mrds; }
From source file:com.jkoolcloud.tnt4j.streams.parsers.ActivityNameValueParser.java
@Override protected ActivityContext prepareItem(TNTInputStream<?, ?> stream, Object data) throws ParseException { String dataStr = getNextActivityString(data); if (StringUtils.isEmpty(dataStr)) { return null; }//from w ww .j a va2s.c o m logger().log(OpLevel.DEBUG, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityParser.splitting.string"), dataStr); if (pattern != null) { Matcher matcher = pattern.matcher(dataStr); if (matcher == null || !matcher.matches()) { logger().log(OpLevel.DEBUG, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityParser.input.not.match"), getName(), pattern.pattern()); return null; } } StrTokenizer tk = stripQuotes ? new StrTokenizer(dataStr, fieldDelim, StrMatcher.doubleQuoteMatcher()) : new StrTokenizer(dataStr, fieldDelim); tk.setIgnoreEmptyTokens(false); String[] fields = tk.getTokenArray(); if (ArrayUtils.isEmpty(fields)) { logger().log(OpLevel.DEBUG, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityParser.no.fields")); return null; } logger().log(OpLevel.DEBUG, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityParser.split"), fields.length); Map<String, String> nameValues = new HashMap<>(fields.length); for (String field : fields) { if (field != null) { String[] nv = field.split(Pattern.quote(valueDelim)); if (ArrayUtils.isNotEmpty(nv)) { nameValues.put(nv[0], nv.length > 1 ? nv[1].trim() : ""); } logger().log(OpLevel.TRACE, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityNameValueParser.found"), field); } } ActivityContext cData = new ActivityContext(stream, data, nameValues); cData.setMessage(getRawDataAsMessage(nameValues)); return cData; }
From source file:gov.nih.nci.security.util.StringUtilities.java
public static boolean checkPatternMatches(String password, String pattern) { Pattern.quote(password); if (Pattern.matches(pattern, password)) return true; else/*from w ww .j a v a 2 s . c om*/ return false; }
From source file:com.alta189.userscript.maven.plugin.UserscriptBuilder.java
private String filterSource(String source) throws UserscriptBuilderException { String result = source;//from w w w. ja v a 2s.c o m Matcher matcher = infludePattern.matcher(source); while (matcher.find()) { String replace = matcher.group(); String file = matcher.group("file"); if (!valid(file)) { throw new UserscriptBuilderException("include tag is invalid"); } File srcFile = new File(getMojo().getSourceDirectory(), file.trim()); if (!srcFile.exists() || !srcFile.isFile()) { throw new UserscriptBuilderException("File does not exist or is not a file: " + srcFile.getPath()); } String contents; try { contents = FileUtils.readFileToString(srcFile); } catch (IOException e) { throw new UserscriptBuilderException("Exception reading file for input tag: " + srcFile.getPath(), e); } result = result.replaceFirst(Pattern.quote(replace), contents); } return result; }