code: public static boolean containsOnly(String str, char[] valid) {
          // All these pre-checks are to maintain API with an older version
          if ((valid == null) || (str == null)) {
              return false;
          }
          if (str.length() == 0) {
              return true;
          }
          if (valid.length == 0) {
              return false;
          }
          return indexOfAnyBut(str, valid) == INDEX_NOT_FOUND;
      }
docs: <p>Checks if the String contains only certain characters.</p>
  
  <p>A <code>null</code> String will return <code>false</code>.
  A <code>null</code> valid character array will return <code>false</code>.
  An empty String (length()=0) always returns <code>true</code>.</p>
  
  <pre>
  StringUtils.containsOnly(null, *)       = false
  StringUtils.containsOnly(*, null)       = false
  StringUtils.containsOnly("", *)         = true
  StringUtils.containsOnly("ab", '')      = false
  StringUtils.containsOnly("abab", 'abc') = true
  StringUtils.containsOnly("ab1", 'abc')  = false
  StringUtils.containsOnly("abz", 'abc')  = false
  </pre>
  
  @param str  the String to check, may be null
  @param valid  an array of valid chars, may be null
  @return true if it only contains valid chars and is non-null