Example usage for java.util.regex Pattern toString

List of usage examples for java.util.regex Pattern toString

Introduction

In this page you can find the example usage for java.util.regex Pattern toString.

Prototype

public String toString() 

Source Link

Document

Returns the string representation of this pattern.

Usage

From source file:com.bc.fiduceo.ingest.IngestionToolTest.java

@Test
public void testGetPattern() {
    final Reader reader = mock(Reader.class);
    when(reader.getRegEx()).thenReturn("p*q");

    final Pattern pattern = IngestionTool.getPattern(reader);
    assertEquals("p*q", pattern.toString());
}

From source file:org.wikimedia.analytics.kraken.funnel.FunnelNode.java

public String toString() {
    StringBuilder sb = new StringBuilder(100);
    int e = 1;/*from  ww w.  j ava  2  s  .c o m*/
    for (ComponentType key : ComponentType.values()) {
        Pattern value = this.nodeDefinition.get(key);
        if (value != null) {
            sb.append(value.toString());
        }
        if (nodeDefinition.size() > 1 && e < nodeDefinition.size()) {
            sb.append(":");
        }
        e++;
    }
    return sb.toString();
}

From source file:org.xwoot.contentprovider.XWootContentProviderConfiguration.java

public void removeIgnorePattern(String pattern) {
    for (Pattern p : ignorePatterns) {
        if (p.toString().equals(pattern)) {
            ignorePatterns.remove(p);//  w  w w .java  2  s  . c o m
            break;
        }
    }
}

From source file:org.xwoot.contentprovider.XWootContentProviderConfiguration.java

public void removeAcceptPattern(String pattern) {
    for (Pattern p : acceptPatterns) {
        if (p.toString().equals(pattern)) {
            acceptPatterns.remove(p);/*www.  j  ava 2 s  .c  om*/
            break;
        }
    }
}

From source file:iTests.framework.utils.WebuiTestUtils.java

private static String findJarFilenameByRegexPattern(final String folderPath, final Pattern pattern)
        throws FileNotFoundException {

    final File folder = new File(folderPath);
    if (!folder.isDirectory()) {
        throw new FileNotFoundException(folder + " is not a directory.");
    }/*from  w ww. ja va  2  s  . c  o  m*/

    final File[] files = folder.listFiles(new FileFilter() {
        @Override
        public boolean accept(File file) {
            return pattern.matcher(file.getName()).matches();
        }
    });

    if (files.length != 1) {
        throw new FileNotFoundException("Folder " + folderPath
                + " should contain exactly one jar that satisfies the pattern " + pattern.toString());
    }

    return files[0].getName();
}

From source file:org.apache.falcon.replication.FeedReplicator.java

private String getFixedPath(String relativePath) throws IOException {
    String[] patterns = relativePath.split("/");
    int part = patterns.length - 1;
    for (int index = patterns.length - 1; index >= 0; index--) {
        String pattern = patterns[index];
        if (pattern.isEmpty()) {
            continue;
        }/*from   w w  w. j a va2s .c om*/
        Pattern r = FilteredCopyListing.getRegEx(pattern);
        if (!r.toString().equals("(" + pattern + "/)|(" + pattern + "$)")) {
            continue;
        }
        part = index;
        break;
    }
    StringBuilder resultBuffer = new StringBuilder();
    for (int index = 0; index <= part; index++) {
        resultBuffer.append(patterns[index]).append("/");
    }
    String result = resultBuffer.toString();
    return result.substring(0, result.lastIndexOf('/'));
}

From source file:org.apache.qpid.server.security.access.firewall.HostnameFirewallRule.java

@Override
public boolean matches(InetAddress remote) {
    String hostname = getHostname(remote);
    if (hostname == null) {
        throw new AccessControlFirewallException("DNS lookup failed for address " + remote);
    }/*from   www. jav a2  s  .  c  o m*/
    for (Pattern pattern : _hostnamePatterns) {
        boolean hostnameMatches = pattern.matcher(hostname).matches();

        if (hostnameMatches) {
            if (_logger.isDebugEnabled()) {
                _logger.debug("Hostname " + hostname + " matches rule " + pattern.toString());
            }
            return true;
        }
    }

    if (_logger.isDebugEnabled()) {
        _logger.debug("Hostname " + hostname + " matches no configured hostname patterns");
    }

    return false;
}

From source file:com.example.appengine.channel.Game.java

public void checkWin() {
    final Pattern[] wins;
    if (moveX) {/*from w  w w . j  a v  a 2 s  .  c om*/
        wins = XWins;
    } else {
        wins = OWins;
    }

    for (Pattern winPattern : wins) {
        if (winPattern.matcher(board).matches()) {
            if (moveX) {
                winner = userX;
            } else {
                winner = userO;
            }
            winningBoard = winPattern.toString();
        }
    }
}

From source file:org.openmrs.module.rheapocadapter.util.GetPatientUtil.java

/**
 * Given a string that contains at least one HL7 message, returns the
 * smallest string that contains the first of these messages.
 *///ww  w .  j  a v  a2 s.co  m
public String getMessageExtent(String theSource, Pattern theStartPattern) {
    Matcher startMatcher = theStartPattern.matcher(theSource);
    if (!startMatcher.find()) {
        throw new IllegalArgumentException(
                theSource + "does not contain message start pattern" + theStartPattern.toString());
    }

    int start = startMatcher.start();
    int end = theSource.length();
    if (startMatcher.find()) {
        end = startMatcher.start();
    }

    return theSource.substring(start, end).trim();
}