List of usage examples for java.util.regex Pattern quote
public static String quote(String s)
From source file:com.wisemapping.rest.AdminController.java
public boolean isSimpleMap(@NotNull Mindmap mindmap) throws UnsupportedEncodingException { String xmlStr = mindmap.getXmlStr(); String[] topics = xmlStr.split(Pattern.quote("<topic")); return topics.length <= 3; }
From source file:com.griddynamics.jagger.util.StandardMetricsNamesUtil.java
public static String generateScenarioStepMetricRegexp(String scenarioId, String stepId, String metricId) { return SCENARIO_STEP_METRIC_REGEXP_TEMPLATE.replace("{scenario_id}", Pattern.quote(scenarioId)) .replace("{step_id}", Pattern.quote(stepId)).replace("{metric_id}", Pattern.quote(metricId)); }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.lookupproperty.ELTLookupMapWizard.java
/** * Create contents of the dialog./* www . j a v a 2 s.c om*/ * * @param parent */ @Override protected Control createDialogArea(Composite parent) { final Composite container = (Composite) super.createDialogArea(parent); container.getShell().setText("Lookup Mapping"); container.setLayout(new GridLayout(4, false)); new Label(container, SWT.NONE); new Label(container, SWT.NONE); new Label(container, SWT.NONE); new Label(container, SWT.NONE); new Label(container, SWT.NONE); Composite composite = new Composite(container, SWT.None); GridData gd_composite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_composite.heightHint = 574; gd_composite.widthHint = 257; composite.setLayoutData(gd_composite); if (lookupPropertyGrid != null) { if (lookupPropertyGrid.getLookupInputProperties() != null && !lookupPropertyGrid.getLookupInputProperties().isEmpty()) { joinInputList1 = lookupPropertyGrid.getLookupInputProperties().get(0); joinInputList2 = lookupPropertyGrid.getLookupInputProperties().get(1); } else { joinInputList1 = new ArrayList<>(); joinInputList2 = new ArrayList<>(); } viewer1 = createComposite(composite, 10, joinInputList1, 0); viewer2 = createComposite(composite, 290, joinInputList2, 1); if (lookupPropertyGrid.getLookupMapProperties() != null && !lookupPropertyGrid.getLookupMapProperties().isEmpty()) { joinOutputList = lookupPropertyGrid.getLookupMapProperties(); } else { joinOutputList = new ArrayList<>(); } } if (joinInputList != null) { joinInputList.add(joinInputList1); joinInputList.add(joinInputList2); } Composite composite_1 = new Composite(container, SWT.None); GridData gd_composite_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_composite_1.heightHint = 600; gd_composite_1.widthHint = 400; composite_1.setLayoutData(gd_composite_1); labelWidget(composite_1, SWT.None, new int[] { 0, 6, 100, 18 }, "Output Mapping"); outputTableViewer = eltswtWidgets.createTableViewer(composite_1, COLUMN_NAME, new int[] { 0, 30, 398, 538 }, 196, new JoinContentProvider(), new LookupLabelProvider()); outputTableViewer.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { joinOutputProperty(outputTableViewer, null); changeColorOfNonMappedFields(); if (joinOutputList.size() >= 1) { deleteButton.setEnabled(true); } if (joinOutputList.size() >= 2) { upButton.setEnabled(true); downButton.setEnabled(true); } } @Override public void mouseDown(MouseEvent e) { validateDuplicatesInOutputField(); getListOfNonMappedFields(inputFieldMap); changeColorOfNonMappedFields(); } }); eltswtWidgets.createTableColumns(outputTableViewer.getTable(), COLUMN_NAME, 196); CellEditor[] editors = eltswtWidgets.createCellEditorList(outputTableViewer.getTable(), 2); editors[0].setValidator( sourceEditorValidator(outputTableViewer, Messages.EmptySourceFieldNotification, joinOutputList)); editors[1].setValidator(outputFieldEditorValidator(outputTableViewer, Messages.EmptySourceFieldNotification, joinOutputList)); outputTableViewer.setColumnProperties(COLUMN_NAME); outputTableViewer.setCellModifier(new LookupCellModifier(outputTableViewer)); outputTableViewer.setCellEditors(editors); outputTableViewer.setInput(joinOutputList); outputTableViewer.getTable().addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { if (((TableItem) event.item) != null) { if (StringUtils.isNotBlank(((TableItem) event.item).getText())) { String[] data = (((TableItem) event.item).getText()).split(Pattern.quote(".")); if (data != null && data.length == 2) { FilterProperties filter = new FilterProperties(); filter.setPropertyname(data[1]); if (joinInputList1.indexOf(filter) >= 0) { inputTableViewer[0].getTable().setSelection(joinInputList1.indexOf(filter)); } else if (joinInputList2.indexOf(filter) >= 0) { inputTableViewer[1].getTable().setSelection(joinInputList2.indexOf(filter)); } } } } } }); TableViewerEditor.create(outputTableViewer, new ColumnViewerEditorActivationStrategy(outputTableViewer), ColumnViewerEditor.KEYBOARD_ACTIVATION | ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL); propertyError = new Label(composite_1, SWT.None); propertyError.setBounds(0, 572, 350, 25); propertyError.setForeground(CustomColorRegistry.INSTANCE.getColorFromRegistry(255, 0, 0)); propertyError.setVisible(false); Composite composite_2 = new Composite(composite_1, SWT.None); composite_2.setBounds(276, 4, 110, 24); createLabel(composite_2); new Label(container, SWT.NONE); populateWidget(); dropData(outputTableViewer, joinOutputList, true); populatePreviousItemsOfTable(); outputTableViewer.getTable().addMouseTrackListener(new MouseTrackListener() { @Override public void mouseHover(MouseEvent e) { changeColorOfNonMappedFields(); } @Override public void mouseExit(MouseEvent e) { changeColorOfNonMappedFields(); } @Override public void mouseEnter(MouseEvent e) { changeColorOfNonMappedFields(); } }); inputFieldMap = setMapOfInputFieldsPerPort(); sourceFieldList = getListOfNonMappedFields(inputFieldMap); return container; }
From source file:de.tudarmstadt.ukp.csniper.webapp.search.cqp.CqpQuery.java
private List<EvaluationItem> parseOutput(List<String> aOutput) { List<EvaluationItem> items = new ArrayList<EvaluationItem>(); String regexp = "\\s*(\\d+):\\s*<" + E_TEXT + "_" + ATTR_ID + "\\s(.+)>:\\s*(.*?)" + Pattern.quote(leftDelim) + "(.*?)" + Pattern.quote(rightDelim) + "(.*?)"; Pattern p = Pattern.compile(regexp); Matcher m = p.matcher(""); // parse results and create EvaluationItems for (String line : aOutput) { m.reset(line);// w w w . j a v a 2 s . c o m if (m.matches() /* && m.groupCount() == 5 */) { int position = Integer.valueOf(m.group(1)); String documentId = m.group(2).trim(); String lc = m.group(3).trim(); String match = m.group(4).trim(); String rc = m.group(5).trim(); int begin = getBegin(lc, match); int originalMatchBegin = getBegin("", match); int end = getEnd(rc, match); int originalMatchEnd = getEnd("", match); if (!lc.isEmpty()) { lc = getText(lc).trim() + " "; } match = getText(match); if (!rc.isEmpty()) { rc = " " + getText(rc).trim(); } String coveredText = (lc + match + rc); if (coveredText.length() < EvaluationItem.MAX_COLUMN_LENGTH) { EvaluationItem item = new EvaluationItem(corpus, documentId, type, begin, end, coveredText); item.setMatchOnItemText(lc.length(), lc.length() + match.length()); item.setMatchOnOriginalText(originalMatchBegin, originalMatchEnd); items.add(item); } else { log.warn("Ignored oversized match in collection [" + corpus + "] document [" + documentId + "] at [" + begin + "-" + end + "]"); } } else { log.debug("Regexp [" + regexp + "] did not match on [" + line + "]"); } } return items; }
From source file:com.htmlhifive.tools.codeassist.core.proposal.H5ProposalCreater.java
/** * ????????????.//from ww w. ja v a2 s .c o m * * @param proposal * @param elem ?? * @return ???????? */ private boolean isOptionFileProposal(IJavaCompletionProposal proposal, FunctionBean elem) { Pattern pattern = Pattern.compile(Pattern.quote(elem.getName()) + "\\(.*\\).*"); return pattern.matcher(proposal.getDisplayString()).matches(); }
From source file:com.github.wnameless.spring.routing.RoutingPathResolver.java
private String computePath(String rawPath) { String path = rawPath;//from w w w. j a v a 2s .c o m Matcher m = PLACEHOLDER.matcher(rawPath); while (m.find()) { String placeholder = m.group(); String trimmedPlaceholder = placeholder.substring(2, placeholder.length() - 1); String[] keyAndDefault = trimmedPlaceholder.split(":"); String key = keyAndDefault[0]; String deFault = ""; if (keyAndDefault.length > 1) deFault = keyAndDefault[1]; path = path.replaceFirst(Pattern.quote(placeholder), env.getProperty(key, deFault)); } return path; }
From source file:com.net.h1karo.sharecontrol.ShareControl.java
public void updateCheck() { String CBuildString = "", NBuildString = ""; int CMajor = 0, CMinor = 0, CMaintenance = 0, CBuild = 0, NMajor = 0, NMinor = 0, NMaintenance = 0, NBuild = 0;/* ww w .j av a 2 s . c o m*/ try { URL url = new URL("https://api.curseforge.com/servermods/files?projectids=90354"); URLConnection conn = url.openConnection(); conn.setReadTimeout(5000); conn.addRequestProperty("User-Agent", "ShareControl Update Checker"); conn.setDoOutput(true); final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); final String response = reader.readLine(); final JSONArray array = (JSONArray) JSONValue.parse(response); if (array.size() == 0) { this.getLogger().warning("No files found, or Feed URL is bad."); result = UpdateResult.ERROR; return; } String newVersionTitle = ((String) ((JSONObject) array.get(array.size() - 1)).get("name")); newVersion = newVersionTitle.replace("ShareControl v", "").trim(); /**\\**/ /**\\**//**\\**/ /**\ GET VERSIONS /**\ /**\\**/ /**\\**//**\\**/ String[] CStrings = currentVersion.split(Pattern.quote(".")); CMajor = Integer.parseInt(CStrings[0]); if (CStrings.length > 1) if (CStrings[1].contains("-")) { CMinor = Integer.parseInt(CStrings[1].split(Pattern.quote("-"))[0]); CBuildString = CStrings[1].split(Pattern.quote("-"))[1]; if (CBuildString.contains("b")) { beta = true; CBuildString = CBuildString.replace("b", ""); if (CBuildString != "") CBuild = Integer.parseInt(CBuildString) - 1; } else if (CBuildString.contains("a")) { alpha = true; CBuildString = CBuildString.replace("a", ""); if (CBuildString != "") CBuild = Integer.parseInt(CBuildString) - 10; } else CBuild = Integer.parseInt(CBuildString); } else { CMinor = Integer.parseInt(CStrings[1]); if (CStrings.length > 2) if (CStrings[2].contains("-")) { CMaintenance = Integer.parseInt(CStrings[2].split(Pattern.quote("-"))[0]); CBuildString = CStrings[2].split(Pattern.quote("-"))[1]; if (CBuildString.contains("b")) { beta = true; CBuildString = CBuildString.replace("b", ""); if (CBuildString != "") CBuild = Integer.parseInt(CBuildString) - 1; } else if (CBuildString.contains("a")) { alpha = true; CBuildString = CBuildString.replace("a", ""); if (CBuildString != "") CBuild = Integer.parseInt(CBuildString) - 10; } else CBuild = Integer.parseInt(CBuildString); } else CMaintenance = Integer.parseInt(CStrings[2]); } String[] NStrings = newVersion.split(Pattern.quote(".")); NMajor = Integer.parseInt(NStrings[0]); if (NStrings.length > 1) if (NStrings[1].contains("-")) { NMinor = Integer.parseInt(NStrings[1].split(Pattern.quote("-"))[0]); NBuildString = NStrings[1].split(Pattern.quote("-"))[1]; if (NBuildString.contains("b")) { beta = true; NBuildString = NBuildString.replace("b", ""); if (NBuildString != "") NBuild = Integer.parseInt(NBuildString) - 1; } else if (NBuildString.contains("a")) { alpha = true; NBuildString = NBuildString.replace("a", ""); if (NBuildString != "") NBuild = Integer.parseInt(NBuildString) - 10; } else NBuild = Integer.parseInt(NBuildString); } else { NMinor = Integer.parseInt(NStrings[1]); if (NStrings.length > 2) if (NStrings[2].contains("-")) { NMaintenance = Integer.parseInt(NStrings[2].split(Pattern.quote("-"))[0]); NBuildString = NStrings[2].split(Pattern.quote("-"))[1]; if (NBuildString.contains("b")) { beta = true; NBuildString = NBuildString.replace("b", ""); if (NBuildString != "") NBuild = Integer.parseInt(NBuildString) - 1; } else if (NBuildString.contains("a")) { alpha = true; NBuildString = NBuildString.replace("a", ""); if (NBuildString != "") NBuild = Integer.parseInt(NBuildString) - 10; } else NBuild = Integer.parseInt(NBuildString); } else NMaintenance = Integer.parseInt(NStrings[2]); } /**\\**/ /**\\**//**\\**/ /**\ CHECK VERSIONS /**\ /**\\**/ /**\\**//**\\**/ if ((CMajor < NMajor) || (CMajor == NMajor && CMinor < NMinor) || (CMajor == NMajor && CMinor == NMinor && CMaintenance < NMaintenance) || (CMajor == NMajor && CMinor == NMinor && CMaintenance == NMaintenance && CBuild < NBuild)) result = UpdateResult.UPDATE_AVAILABLE; else result = UpdateResult.NO_UPDATE; return; } catch (Exception e) { console.sendMessage(" There was an issue attempting to check for the latest version."); } result = UpdateResult.ERROR; }
From source file:com.evolveum.midpoint.prism.query.SubstringFilter.java
@Override public boolean match(PrismContainerValue containerValue, MatchingRuleRegistry matchingRuleRegistry) throws SchemaException { Item item = getObjectItem(containerValue); MatchingRule matching = getMatchingRuleFromRegistry(matchingRuleRegistry, item); for (Object val : item.getValues()) { if (val instanceof PrismPropertyValue) { Object value = ((PrismPropertyValue) val).getValue(); Iterator<String> iterator = (Iterator<String>) toRealValues().iterator(); while (iterator.hasNext()) { StringBuilder sb = new StringBuilder(); if (!anchorStart) { sb.append(".*"); }/*from ww w .j a va2 s .c o m*/ sb.append(Pattern.quote(iterator.next())); if (!anchorEnd) { sb.append(".*"); } if (matching.matchRegex(value, sb.toString())) { return true; } } } if (val instanceof PrismReferenceValue) { throw new UnsupportedOperationException( "matching substring on the prism reference value not supported yet"); } } return false; }
From source file:com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck.java
/** * Sets the list of package groups and the order they should occur in the * file./* ww w . j a v a2s .com*/ * * @param packageGroups a comma-separated list of package names/prefixes. */ public void setGroups(String... packageGroups) { groups = new Pattern[packageGroups.length]; for (int i = 0; i < packageGroups.length; i++) { String pkg = packageGroups[i]; final StringBuilder pkgBuilder = new StringBuilder(pkg); Pattern grp; // if the pkg name is the wildcard, make it match zero chars // from any name, so it will always be used as last resort. if (WILDCARD_GROUP_NAME.equals(pkg)) { // matches any package grp = Pattern.compile(""); } else if (CommonUtils.startsWithChar(pkg, '/')) { if (!CommonUtils.endsWithChar(pkg, '/')) { throw new IllegalArgumentException("Invalid group"); } pkg = pkg.substring(1, pkg.length() - 1); grp = Pattern.compile(pkg); } else { if (!CommonUtils.endsWithChar(pkg, '.')) { pkgBuilder.append('.'); } grp = Pattern.compile("^" + Pattern.quote(pkgBuilder.toString())); } groups[i] = grp; } }
From source file:com.asakusafw.lang.compiler.cli.BatchCompilerCli.java
private static List<File> parseFiles(CommandLine cmd, Option option, boolean check) { String value = parse(cmd, option); if (value == null) { return Collections.emptyList(); }// w w w .ja va 2s.c o m List<File> results = new ArrayList<>(); for (String segment : value.split(Pattern.quote(File.pathSeparator))) { String s = segment.trim(); if (s.isEmpty()) { continue; } results.add(resolveFile(option, s, check)); } return results; }