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

This code example shows how to use the following methods:or
  } 
 
  private static final CharMatcher BASH_SPECIAL_CHARS =
      CharMatcher
          .anyOf("<>|!?*[]$\\(){}\"'`&;=")
          .or(CharMatcher.WHITESPACE);
 
  /** 
   * Bash quoting {@link com.google.common.base.Function Function} which can be passed to 
   * {@link com.google.common.collect.Iterables#transform Iterables.transform()}. 
   */ 
  public static final Function<String, String> BASH_ESCAPER =
      escaper(Quoter.SINGLE, BASH_SPECIAL_CHARS);
 
  public static final Function<String, String> JAVA_ESCAPER =
      new Function<String, String>() { 
        @Override 
        public String apply(String input) { 
          return escapeAsJavaString(input); 
        } 
5
CodeRank
This code example shows how to use the following methods:or
   private static final int MINIMUM_TRADER_NAME_LENGTH = 3;
   private static final CharMatcher VALID_USER_CHARS =
         inRange('a', 'z')
               .or(inRange('A', 'Z'))
               .or(DIGIT)
               .or(WHITESPACE)
               .or(anyOf("._-"));
 
 
   public static boolean isValidTraderName(String name) {
      // Allow a-z, A-Z, 0-9, dot, underbar, and dash 
      return name != null && name.length() >= MINIMUM_TRADER_NAME_LENGTH && name.length() <= MAXIMUM_TRADER_NAME_LENGTH
            && WHITESPACE.trimFrom(name).equals(name) // must not
            // start or 
            // end with 
            // whitespace 
            && VALID_USER_CHARS.matchesAllOf(name);
   } 
} 
5
CodeRank
This code example shows how to use the following methods:or
        /* 
         * This doesn't include the %: percent-encoded sequences will be 
         * handled in the appropriate template parser 
         */ 
        final CharMatcher other = CharMatcher.anyOf("\"'<>\\^`{|}");
        LITERALS = ctl.or(spc).or(other).negate().precomputed();
    } 
} 
4
CodeRank
This code example shows how to use the following methods:or
        assertThat(CharMatcher.DIGIT.retainFrom("Hello 1234 567")).isEqualTo("1234567");
    } 
 
    @Test
    public void shouldRetainDigitsOrWhiteSpaces() throws Exception {
        assertThat(CharMatcher.DIGIT.or(CharMatcher.WHITESPACE).retainFrom("Hello 1234 567")).isEqualTo(" 1234 567");
    } 
 
    @Test
    public void shouldRetainNothingAsConstrainsAreExcluding() throws Exception {
        assertThat(CharMatcher.DIGIT.and(CharMatcher.JAVA_LETTER).retainFrom("Hello 1234 567")).isEqualTo("");
    } 
 
    @Test
    public void shouldRetainLettersAndDigits() throws Exception {
        assertThat(CharMatcher.DIGIT.or(CharMatcher.JAVA_LETTER).retainFrom("Hello 1234 567")).isEqualTo("Hello1234567");
    } 
 
    @Test
    public void shouldCollapseAllDigitsByX() throws Exception {
3
CodeRank
This code example shows how to use the following methods:or
    return true; 
  } 
 
  private static final CharMatcher DASH_MATCHER = CharMatcher.anyOf("-_");
 
  private static final CharMatcher PART_CHAR_MATCHER =
      CharMatcher.JAVA_LETTER_OR_DIGIT.or(DASH_MATCHER);
 
  /** 
   * Helper method for {@link #validateSyntax(List)}. Validates that one part of 
   * a domain name is valid. 
   * 
   * @param part The domain name part to be validated 
   * @param isFinalPart Is this the final (rightmost) domain part? 
   * @return Whether the part is valid 
   */ 
  private static boolean validatePart(String part, boolean isFinalPart) {
 
    // These tests could be collapsed into one big boolean expression, but 
    // they have been left as independent tests for clarity. 
4
CodeRank
This code example shows how to use the following methods:or
 
public class GroupsService extends AbstractPathBasedColllectionService { 
 
    private static final Logger logger = LoggerFactory.getLogger( GroupsService.class );
 
    static CharMatcher matcher = CharMatcher.JAVA_LETTER_OR_DIGIT.or( CharMatcher.anyOf( "-./" ) );
 
 
    public GroupsService() { 
        super(); 
        logger.info( "/groups" ); 
 
        // rolenames is the one case of Entity Dictionary name not equal to path segment 
        declareEntityDictionary( new EntityDictionaryEntry( "rolenames", "roles" ) ); 
 
        declareEntityDictionaries( Arrays.asList( "permissions" ) );
    } 
 
 
    @Override 
3
CodeRank
This code example shows how to use the following methods:or
or Method Overview
Returns a matcher that matches any character matched by either this matcher or other.
See Code Examples for other Guava CharMatcher Methods: