CharMatcher matchesAllOf - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for CharMatcher matchesAllOf method.

This code example shows how to use the following methods:matchesAllOf, negate
                .putArgument("actual", input.length())
                .putArgument("expected", length));
            return; 
        } 
 
        if (HEX_CHARS.matchesAllOf(input))
            return; 
 
        final int index = HEX_CHARS.negate().indexIn(input);
 
        report.error(newMsg(data, bundle, "err.format.hexString.illegalChar")
            .putArgument("character", Character.toString(input.charAt(index)))
            .putArgument("index", index));
    } 
} 
5
CodeRank
This code example shows how to use the following methods:matchesAllOf
This code example shows how to use the following methods:matchesAllOf
            throw new IllegalArgumentException( "You must provide a 'path' property when creating a group" );
        } 
 
        logger.info( "Creating group with path {}", path );
 
        Preconditions.checkArgument( matcher.matchesAllOf( path ), "Illegal characters found in group name: " + path );
 
        return super.postCollection( context );
    } 
 
 
    public ServiceResults getGroupRoles( UUID groupId ) throws Exception {
        Map<String, Role> roles = em.getGroupRolesWithTitles( groupId );
        ServiceResults results = genericServiceResults().withData( roles );
        return results;
    } 
 
 
    public ServiceResults getApplicationRolePermissions( String roleName ) throws Exception {
        Set<String> permissions = em.getRolePermissions( roleName );
3
CodeRank
This code example shows how to use the following methods:matchesAllOf
   * Check if host is set 
   * 
   * @return true if host is set 
   */ 
  public boolean hasHost() { 
    return host != null && !CharMatcher.WHITESPACE.matchesAllOf(host);
  } 
 
  @Override 
  public boolean equals(Object obj) { 
    if (this == obj) {
      return true; 
    } 
    if (obj instanceof MetastoreDesc) { 
      MetastoreDesc other = (MetastoreDesc) obj;
      return Objects.equal(host, other.host) &&
          port == other.port;
    } 
    return false; 
  } 
4
CodeRank
This code example shows how to use the following methods:matchesAllOf
        this.rootDirectory = Preconditions.checkNotNull(rootDirectory, "Root Directory cannot be null");
        this.prefix = prefix;
        Preconditions.checkArgument(cleanupAgeMillis > 0, "cleanup age millis (%s) should be greater than zero", cleanupAgeMillis);
        Preconditions.checkArgument(rootDirectory.isDirectory(), "File %s should be a directory", rootDirectory.getAbsolutePath());
        Preconditions.checkArgument(rootDirectory.exists(), "File %s should exists", rootDirectory.getAbsolutePath());
        Preconditions.checkArgument(!CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(prefix)), "Prefix should not be empty");
    } 
 
    @Override 
    public File createWorkspace(String suffix, boolean deleteIfExists) throws IOException {
        checkShutdownState(); 
        return createWorkspace(prefix, suffix, rootDirectory, deleteIfExists);
    } 
 
    @Override 
    public boolean deleteWorkspaceQuietly(final String suffix) {
        checkShutdownState(); 
        final File dir = getUserDirectory(prefix, suffix, rootDirectory);
        if (dir.exists()) {
            return deleteUserDirectoryQuietly(suffix, dir);
3
CodeRank
This code example shows how to use the following methods:matchesAllOf
    public DelegationIdentity(String dn, String delegationId) throws DelegationException
    { 
        _dn = checkNotNull(dn);
        _delegationId = checkNotNull(delegationId);
 
        assertThat(VALID_DELEGATION_ID_CHARACTERS.matchesAllOf(delegationId),
                "delegationID \"" + delegationId + "\" is not valid");
    } 
 
    public String getDn()
    { 
        return _dn;
    } 
 
    public String getDelegationId()
    { 
        return _delegationId;
    } 
 
    @Override 
4
CodeRank
This code example shows how to use the following methods:matchesAllOf
        assertThat(CharMatcher.noneOf("xZ").matchesAnyOf("anything")).isTrue();
    } 
 
    @Test
    public void shouldMatchAny() throws Exception {
        assertThat(CharMatcher.ANY.matchesAllOf("anything")).isTrue();
    } 
 
    @Test
    public void shouldMatchBreakingWhitespace() throws Exception {
        assertThat(CharMatcher.BREAKING_WHITESPACE.matchesAllOf("\r\n\r\n")).isTrue();
    } 
 
    @Test
    public void shouldMatchDigits() throws Exception {
        assertThat(CharMatcher.DIGIT.matchesAllOf("1231212")).isTrue();
    } 
 
    @Test
    public void shouldMatchDigitsWithWhitespace() throws Exception {
4
CodeRank
This code example shows how to use the following methods:matchesAllOf
    /** 
     * input must be an ASCII string representing a percent-encoded UTF-8 byte sequence 
     */ 
    private static String percentDecode(String encoded)
    { 
        Preconditions.checkArgument(CharMatcher.ASCII.matchesAllOf(encoded), "string must be ASCII");
 
        ByteArrayOutputStream out = new ByteArrayOutputStream(encoded.length());
        for (int i = 0; i < encoded.length(); i++) {
            char c = encoded.charAt(i);
 
            if (c == '%') {
                Preconditions.checkArgument(i + 2 < encoded.length(), "percent encoded value is truncated");
 
                int high = Character.digit(encoded.charAt(i + 1), 16);
                int low = Character.digit(encoded.charAt(i + 2), 16);
 
                Preconditions.checkArgument(high != -1 && low != -1, "percent encoded value is not a valid hex string: ", encoded.substring(i, i + 2));
 
                int value = (high << 4) | (low);
4
CodeRank
This code example shows how to use the following methods:matchesAllOf
 
    @Override 
    public void init(final ServletConfig config) throws ServletException {
        super.init(config);
        final String proctorSpecPathParameter = config.getInitParameter("proctorSpecPath");
        if (! CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(proctorSpecPathParameter))) {
            proctorSpecPath = proctorSpecPathParameter;
        } 
    } 
 
    @Override 
    protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/plain;charset=UTF-8");
 
        final InputStream resourceAsStream;
        if (proctorSpecPath.startsWith("classpath:")) {
            final String proctorSpecClassPath = proctorSpecPath.substring("classpath:".length());
            resourceAsStream = getClass().getClassLoader().getResourceAsStream(proctorSpecClassPath);
        } else { 
            resourceAsStream = getServletContext().getResourceAsStream(proctorSpecPath);
4
CodeRank
This code example shows how to use the following methods:matchesAllOf
    @Override 
    public void handleDirEntry(SVNDirEntry svnDirEntry) throws SVNException {
        // from the svn docs: The directory entry for url is reported using an empty path. 
        // If SVNDepth.IMMEDIATES, lists its immediate file and directory entries 
        // So identify the parent as the one with an empty relative path 
        if (CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(svnDirEntry.getRelativePath()))) {
            this.parent = svnDirEntry;
        } else if (childFilter.apply(svnDirEntry)) {
            this.children.add(svnDirEntry);
        } 
    } 
 
    public SVNDirEntry getParent() { 
        return parent;
    } 
 
    public List<SVNDirEntry> getChildren() {
        return children;
    } 
} 
4
CodeRank
matchesAllOf Method Overview
Returns true if a character sequence contains only matching characters.
See Code Examples for other Guava CharMatcher Methods: