java.util.regex.Pattern#toString ( )源码实例Demo

下面列出了java.util.regex.Pattern#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: kylin-on-parquet-v2   文件: KylinConfigBase.java
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();
    }
}
 
源代码2 项目: neoscada   文件: IncludeItemProvider.java
/**
 * 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;
}
 
源代码3 项目: neoscada   文件: PatternFilterItemProvider.java
/**
 * 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;
}
 
源代码4 项目: neoscada   文件: ExcludeItemProvider.java
/**
 * 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;
}
 
源代码5 项目: systemsgenetics   文件: Strings.java
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();
}
 
源代码6 项目: neoscada   文件: AknProxyItemProvider.java
/**
 * 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;
}
 
源代码7 项目: opentest   文件: CustomConditions.java
/**
 * 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();
        }
    };
}
 
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);
}
 
源代码9 项目: java-docs-samples   文件: Game.java
/**
 * 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();
    }
  }
}
 
源代码10 项目: systemsgenetics   文件: Strings.java
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();
}
 
源代码11 项目: Kylin   文件: KylinConfig.java
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();
    }
}
 
/**
 * 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;
}
 
源代码13 项目: spring-localstack   文件: Container.java
/**
 * 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.");
}
 
源代码14 项目: vertx-web   文件: OpenAPI3PathResolverTest.java
@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();
}
 
源代码15 项目: neoscada   文件: RuleItemProvider.java
protected String getTextFor ( final Pattern pattern )
{
    if ( pattern == null )
    {
        return null;
    }
    else
    {
        return pattern.toString ();
    }
}
 
源代码16 项目: tomcatsrc   文件: CustomObjectInputStream.java
/**
 * 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;
}
 
源代码17 项目: android-card-form   文件: CardTypeTest.java
@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*"));
        }
    }
}
 
源代码18 项目: vertx-web   文件: OpenAPI3PathResolverTest.java
@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"));
}
 
源代码19 项目: mongodb-orm   文件: RegexTypeHandler.java
@Override
public Object resovleValue(Pattern target) {
  return target.toString();
}
 
源代码20 项目: orientqb   文件: Projection.java
public Clause matches(Pattern pattern) {
	return new AtomicClause(this, Operator.MATCHES, pattern.toString());
}