Java Code Examples for java.util.regex.Pattern#toString()
The following examples show how to use
java.util.regex.Pattern#toString() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: kylin-on-parquet-v2 File: KylinConfigBase.java License: Apache License 2.0 | 6 votes |
private static String getFileName(String homePath, Pattern pattern) { File home = new File(homePath); SortedSet<String> files = Sets.newTreeSet(); if (home.exists() && home.isDirectory()) { File[] listFiles = home.listFiles(); if (listFiles != null) { for (File file : listFiles) { final Matcher matcher = pattern.matcher(file.getName()); if (matcher.matches()) { files.add(file.getAbsolutePath()); } } } } if (files.isEmpty()) { throw new RuntimeException("cannot find " + pattern.toString() + " in " + homePath); } else { return files.last(); } }
Example 2
Source Project: neoscada File: IncludeItemProvider.java License: Eclipse Public License 1.0 | 6 votes |
/** * This returns the label styled text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getStyledText ( Object object ) { Pattern labelValue = ( (Include)object ).getPattern (); String label = labelValue == null ? null : labelValue.toString (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_Include_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_Include_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
Example 3
Source Project: neoscada File: PatternFilterItemProvider.java License: Eclipse Public License 1.0 | 6 votes |
/** * This returns the label styled text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getStyledText ( Object object ) { Pattern labelValue = ( (PatternFilter)object ).getPattern (); String label = labelValue == null ? null : labelValue.toString (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_PatternFilter_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_PatternFilter_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
Example 4
Source Project: neoscada File: ExcludeItemProvider.java License: Eclipse Public License 1.0 | 6 votes |
/** * This returns the label styled text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getStyledText ( Object object ) { Pattern labelValue = ( (Exclude)object ).getPattern (); String label = labelValue == null ? null : labelValue.toString (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_Exclude_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_Exclude_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
Example 5
Source Project: systemsgenetics File: Strings.java License: GNU General Public License v3.0 | 6 votes |
public static String concat(String[] s, Pattern t) { String sepstr = t.toString(); int len = 0; for (int i = 0; i < s.length; i++) { if (s[i] != null) { len += s[i].length(); } else { len += 4; } } len += ((s.length - 1) * sepstr.length()); StringBuilder output = new StringBuilder(len); for (int i = 0; i < s.length; i++) { if (i == 0) { output.append(s[i]); } else { output.append(sepstr).append(s[i]); } } return output.toString(); }
Example 6
Source Project: neoscada File: AknProxyItemProvider.java License: Eclipse Public License 1.0 | 6 votes |
/** * This returns the label styled text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getStyledText ( Object object ) { Pattern labelValue = ( (AknProxy)object ).getPattern (); String label = labelValue == null ? null : labelValue.toString (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_AknProxy_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_AknProxy_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
Example 7
Source Project: opentest File: CustomConditions.java License: MIT License | 6 votes |
/** * Returns an ExpectedCondition instance that waits for the current page URL * to match the provided regular expression. */ public static ExpectedCondition<Boolean> urlToMatch(final Pattern regexPattern) { return new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driver) { String url = driver.getCurrentUrl(); Boolean matches = regexPattern.matcher(url).matches(); return matches; } @Override public String toString() { return "current page URL to match: " + regexPattern.toString(); } }; }
Example 8
Source Project: binnavi File: PostgreSQLFunctionNotificationParser.java License: Apache License 2.0 | 6 votes |
private FunctionNotificationContainer parseFunctionNotification(final PGNotification notification, final SQLProvider provider) { final Pattern pattern = Pattern.compile(functionNotificationPattern); final Matcher matcher = pattern.matcher(notification.getParameter()); if (!matcher.find()) { throw new IllegalStateException("IE02739: compiled pattern: " + pattern.toString() + " did not match notification: " + notification.getParameter()); } final String databaseOperation = matcher.group(2); final Integer moduleId = Integer.parseInt(matcher.group(3)); final IAddress functionAddress = new CAddress(new BigInteger(matcher.group(4))); final INaviModule module = provider.findModule(moduleId); return new FunctionNotificationContainer(moduleId, module, functionAddress, databaseOperation); }
Example 9
Source Project: java-docs-samples File: Game.java License: Apache License 2.0 | 6 votes |
/** * checkWin - has anyone won. */ public void checkWin() { final Pattern[] wins; if (moveX) { wins = XWins; } else { wins = OWins; } for (Pattern winPattern : wins) { if (winPattern.matcher(board).matches()) { if (moveX) { winner = userX; } else { winner = userO; } winningBoard = winPattern.toString(); } } }
Example 10
Source Project: systemsgenetics File: Strings.java License: GNU General Public License v3.0 | 6 votes |
public static String concat(Object[] s, Pattern t) { String sepstr = t.toString(); int len = 0; for (int i = 0; i < s.length; i++) { if (s[i] != null) { len += s[i].toString().length(); } else { len += 4; } } len += ((s.length - 1) * t.toString().length()); StringBuilder output = new StringBuilder(len); for (int i = 0; i < s.length; i++) { if (i == 0) { output.append(s[i].toString()); } else { output.append(sepstr).append(s[i].toString()); } } return output.toString(); }
Example 11
Source Project: Kylin File: KylinConfig.java License: Apache License 2.0 | 6 votes |
private static String getFileName(String homePath, Pattern pattern) { File home = new File(homePath); SortedSet<String> files = Sets.newTreeSet(); if (home.exists() && home.isDirectory()) { for (File file : home.listFiles()) { final Matcher matcher = pattern.matcher(file.getName()); if (matcher.matches()) { files.add(file.getAbsolutePath()); } } } if (files.isEmpty()) { throw new RuntimeException("cannot find " + pattern.toString() + " in " + homePath); } else { return files.last(); } }
Example 12
Source Project: Tomcat8-Source-Read File: CustomObjectInputStream.java License: MIT License | 5 votes |
/** * Construct a new instance of CustomObjectInputStream with filtering of * deserialized classes. * * @param stream The input stream we will read from * @param classLoader The class loader used to instantiate objects * @param log The logger to use to report any issues. It may only be null if * the filterMode does not require logging * @param allowedClassNamePattern The regular expression to use to filter * deserialized classes. The fully qualified * class name must match this pattern for * deserialization to be allowed if filtering * is enabled. * @param warnOnFailure Should any failures be logged? * * @exception IOException if an input/output error occurs */ public CustomObjectInputStream(InputStream stream, ClassLoader classLoader, Log log, Pattern allowedClassNamePattern, boolean warnOnFailure) throws IOException { super(stream); if (log == null && allowedClassNamePattern != null && warnOnFailure) { throw new IllegalArgumentException( sm.getString("customObjectInputStream.logRequired")); } this.classLoader = classLoader; this.log = log; this.allowedClassNamePattern = allowedClassNamePattern; if (allowedClassNamePattern == null) { this.allowedClassNameFilter = null; } else { this.allowedClassNameFilter = allowedClassNamePattern.toString(); } this.warnOnFailure = warnOnFailure; Set<String> reportedClasses; synchronized (reportedClassCache) { reportedClasses = reportedClassCache.get(classLoader); } if (reportedClasses == null) { reportedClasses = Collections.newSetFromMap(new ConcurrentHashMap<String,Boolean>()); synchronized (reportedClassCache) { Set<String> original = reportedClassCache.get(classLoader); if (original == null) { reportedClassCache.put(classLoader, reportedClasses); } else { // Concurrent attempts to create the new Set. Make sure all // threads use the first successfully added Set. reportedClasses = original; } } } this.reportedClasses = reportedClasses; }
Example 13
Source Project: spring-localstack File: Container.java License: Apache License 2.0 | 5 votes |
/** * Poll the docker logs until a specific token appears, then return. Primarily used to look * for the "Ready." token in the localstack logs. */ public void waitForLogToken(Pattern pattern) { int attempts = 0; do { if(logContainsPattern(pattern)) { return; } waitForLogs(); attempts++; } while(attempts < MAX_LOG_COLLECTION_ATTEMPTS); throw new IllegalStateException("Could not find token: " + pattern.toString() + " in docker logs."); }
Example 14
Source Project: vertx-web File: OpenAPI3PathResolverTest.java License: Apache License 2.0 | 5 votes |
@Test public void shouldNotHaveEmptyStringQuoting() { OpenAPI3PathResolver resolver = instantiatePathResolver("path_multi_simple_label"); Optional<Pattern> optional = resolver.solve(); Pattern p = optional.get(); String pattern = p.toString(); assertThat(pattern.contains("\\Q\\E")).isFalse(); }
Example 15
Source Project: neoscada File: RuleItemProvider.java License: Eclipse Public License 1.0 | 5 votes |
protected String getTextFor ( final Pattern pattern ) { if ( pattern == null ) { return null; } else { return pattern.toString (); } }
Example 16
Source Project: tomcatsrc File: CustomObjectInputStream.java License: Apache License 2.0 | 5 votes |
/** * Construct a new instance of CustomObjectInputStream with filtering of * deserialized classes. * * @param stream The input stream we will read from * @param classLoader The class loader used to instantiate objects * @param log The logger to use to report any issues. It may only be null if * the filterMode does not require logging * @param allowedClassNamePattern The regular expression to use to filter * deserialized classes. The fully qualified * class name must match this pattern for * deserialization to be allowed if filtering * is enabled. * @param warnOnFailure Should any failures be logged? * * @exception IOException if an input/output error occurs */ public CustomObjectInputStream(InputStream stream, ClassLoader classLoader, Log log, Pattern allowedClassNamePattern, boolean warnOnFailure) throws IOException { super(stream); if (log == null && allowedClassNamePattern != null && warnOnFailure) { throw new IllegalArgumentException( sm.getString("customObjectInputStream.logRequired")); } this.classLoader = classLoader; this.log = log; this.allowedClassNamePattern = allowedClassNamePattern; if (allowedClassNamePattern == null) { this.allowedClassNameFilter = null; } else { this.allowedClassNameFilter = allowedClassNamePattern.toString(); } this.warnOnFailure = warnOnFailure; Set<String> reportedClasses; synchronized (reportedClassCache) { reportedClasses = reportedClassCache.get(classLoader); if (reportedClasses == null) { reportedClasses = Collections.newSetFromMap(new ConcurrentHashMap<String,Boolean>()); reportedClassCache.put(classLoader, reportedClasses); } } this.reportedClasses = reportedClasses; }
Example 17
Source Project: android-card-form File: CardTypeTest.java License: MIT License | 5 votes |
@Test public void allParametersSane() { for (final CardType cardType : CardType.values()) { final int minCardLength = cardType.getMinCardLength(); assertTrue(String.format("%s: Min card length %s too small", cardType, minCardLength), minCardLength >= MIN_MIN_CARD_LENGTH); final int maxCardLength = cardType.getMaxCardLength(); assertTrue(String.format("%s: Max card length %s too large", cardType, maxCardLength), maxCardLength <= MAX_MAX_CARD_LENGTH); assertTrue(String.format("%s: Min card length %s greater than its max %s", cardType, minCardLength, maxCardLength), minCardLength <= maxCardLength ); final int securityCodeLength = cardType.getSecurityCodeLength(); assertTrue(String.format("%s: Unusual security code length %s", cardType, securityCodeLength), securityCodeLength >= MIN_SECURITY_CODE_LENGTH && securityCodeLength <= MAX_SECURITY_CODE_LENGTH ); assertTrue(String.format("%s: No front resource declared", cardType), cardType.getFrontResource() != 0); assertTrue(String.format("%s: No Security code resource declared", cardType), cardType.getSecurityCodeName() != 0); if (cardType != CardType.UNKNOWN && cardType != CardType.EMPTY) { final Pattern pattern = cardType.getPattern(); final String regex = pattern.toString(); assertTrue(String.format("%s: Pattern must start with ^", cardType), regex.startsWith("^")); assertTrue(String.format("%s: Pattern must end with \\d*", cardType), regex.endsWith("\\d*")); } } }
Example 18
Source Project: vertx-web File: OpenAPI3PathResolverTest.java License: Apache License 2.0 | 5 votes |
@Test public void shouldNotHaveEmptyStringQuoting() { OpenAPI3PathResolver resolver = instantiatePathResolver("path_multi_simple_label"); Optional<Pattern> optional = resolver.solve(); Pattern p = optional.get(); String pattern = p.toString(); assertFalse(pattern.contains("\\Q\\E")); }
Example 19
Source Project: mongodb-orm File: RegexTypeHandler.java License: Apache License 2.0 | 4 votes |
@Override public Object resovleValue(Pattern target) { return target.toString(); }
Example 20
Source Project: orientqb File: Projection.java License: Apache License 2.0 | 4 votes |
public Clause matches(Pattern pattern) { return new AtomicClause(this, Operator.MATCHES, pattern.toString()); }