CharMatcher matches - 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 matches method.

This code example shows how to use the following methods:matches
	public void setObserver(Appendable appendable) {
		this.writer = appendable == null ? NullWriter.NULL_WRITER : appendable;
	} 
 
	public boolean nextCharMatches(CharMatcher matcher) {
		return matcher.matches((char)peek());
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:matches
     * (for example, "3com.com"). It's important to disallow an initial digit in 
     * the last part; it's the only thing that stops an IPv4 numeric address 
     * like 127.0.0.1 from looking like a valid domain name. 
     */ 
 
    if (isFinalPart && CharMatcher.DIGIT.matches(part.charAt(0))) {
      return false; 
    } 
 
    return true; 
  } 
 
  /** 
   * Returns the individual components of this domain name, normalized to all 
   * lower case. For example, for the domain name {@code mail.google.com}, this 
   * method returns the list {@code ["mail", "google", "com"]}. 
   */ 
  public ImmutableList<String> parts() {
    return parts;
  } 
4
CodeRank
This code example shows how to use the following methods:matches
              } 
              return -1; 
            } 
            readChars++;
            char ch = (char) readChar;
            if (paddingMatcher.matches(ch)) {
              if (!hitPadding
                  && (readChars == 1 || !alphabet.isValidPaddingStartPosition(readChars - 1))) {
                throw new DecodingException("Padding cannot start at index " + readChars);
              } 
              hitPadding = true;
            } else if (hitPadding) {
              throw new DecodingException( 
                  "Expected padding character but found '" + ch + "' at index " + readChars);
            } else { 
              bitBuffer <<= alphabet.bitsPerChar;
              bitBuffer |= alphabet.decode(ch);
              bitBufferLength += alphabet.bitsPerChar;
 
              if (bitBufferLength >= 8) {
3
CodeRank
This code example shows how to use the following methods:matches
 
	public static final WordDetector INSTANCE = new DefaultWordDetector();
 
	@Override 
	public boolean isWordStart(char c) {
		return CharMatcher.JAVA_LETTER.matches(c);
	} 
 
	@Override 
	public boolean isWordPart(char c) {
		return CharMatcher.JAVA_LETTER.matches(c);
	} 
} 
4
CodeRank
This code example shows how to use the following methods:matches
    { 
        final char c = buffer.charAt(0);
        final TemplateParser parser;
        if (CharMatchers.LITERALS.matches(c))
            parser = new LiteralParser();
        else if (BEGIN_EXPRESSION.matches(c))
            parser = new ExpressionParser();
        else 
            throw new URITemplateParseException( 
                BUNDLE.getMessage("parse.noParser"), buffer);
        return parser;
    } 
} 
4
CodeRank
This code example shows how to use the following methods:matches
    } 
  } 
 
  private boolean addSimpleMatch( 
      String pattern, String part, Map<String, String> storage) {
    if (VAR_START.matches(pattern.charAt(0))) {
      storage.put(pattern.substring(1), part);
      return true; 
    } else { 
      // not a captured part, verify it matches the pattern 
      return pattern.equals(part);
    } 
  } 
 
  private static void addAuthority(URI uri, Map<String, String> storage) {
    if (uri.getHost() != null) {
      storage.put(HOST, uri.getHost());
    } 
    if (uri.getPort() >= 0) {
      storage.put(PORT, String.valueOf(uri.getPort()));
3
CodeRank
This code example shows how to use the following methods:matches
   * @return the length of the token in the input character stream 
   */ 
  int render(TokenBuilder builder, CharMatcher asLiteral)
  { 
    char ch = (char) character;
    if (asLiteral.matches(ch))
    { 
      builder.append(ch);
    } 
    else 
    { 
      //TODO could normalize space end chars 
      builder.append(sequence);
    } 
    return sequence.length() - 1;
  } 
 
  @Override 
  public String toString()
  { 
3
CodeRank
This code example shows how to use the following methods:matches
    } 
  } 
 
  private static boolean addSimpleMatch( 
      String pattern, String part, Map<String, String> storage) {
    if (VAR_START.matches(pattern.charAt(0))) {
      storage.put(pattern.substring(1), part);
      return true; 
    } else { 
      // not a captured part, verify it matches the pattern 
      return pattern.equals(part);
    } 
  } 
 
  private static void addAuthority(URI uri, Map<String, String> storage) {
    if (uri.getHost() != null) {
      storage.put(HOST, uri.getHost());
    } 
    if (uri.getPort() >= 0) {
      storage.put(PORT, String.valueOf(uri.getPort()));
2
CodeRank
matches Method Overview
Determines a true or false value for the given character.
See Code Examples for other Guava CharMatcher Methods: