List of usage examples for java.lang Character isLetterOrDigit
public static boolean isLetterOrDigit(int codePoint)
From source file:com.amazonaws.codepipeline.jenkinsplugin.Validation.java
public static void validateProjectName(final String projectName, final TaskListener listener) throws IllegalArgumentException { if (projectName.length() > MAX_PROJECT_NAME_LENGTH) { final String error = "Invalid project name: " + projectName + ". The AWS CodePipeline Jenkins plugin supports project names with a maximum of " + MAX_PROJECT_NAME_LENGTH + " characters."; LoggingHelper.log(listener, error); throw new IllegalArgumentException(error); }//from w w w . ja v a2 s. com for (final Character c : projectName.toCharArray()) { if (!Character.isLetterOrDigit(c) && c != '_' && c != '-') { final String error = "Invalid project name: " + projectName + ". The AWS CodePipeline Jenkins plugin supports project names with alphanumeric characters and the special " + "characters - (minus sign) and _ (underscore)."; LoggingHelper.log(listener, error); throw new IllegalArgumentException(error); } } }
From source file:net.sourceforge.pmd.lang.java.ast.CommentUtil.java
/** * Gets the next word (characters until next whitespace, punctuation, * or anything that is not a letter or digit) at the given position. * * @param text the complete text//from w w w . ja v a 2 s .c o m * @param position the position, at which the word starts * @return the word * * @deprecated This method is deprecated and will be removed with PMD 7.0.0. * This method has been intended to parse javadoc tags. * A more useful solution will be added around the AST node {@link FormalComment}, * which contains as children {@link JavadocElement} nodes, which in * turn provide access to the {@link JavadocTag}. */ @Deprecated // will be removed with PMD 7.0.0 public static String wordAfter(String text, int position) { if (text == null || position >= text.length()) { return null; } int newposition = position + 1; int end = newposition; char ch = text.charAt(end); while (Character.isLetterOrDigit(ch) && end < text.length()) { ch = text.charAt(++end); } return text.substring(newposition, end); }
From source file:com.yahoo.semsearch.fastlinking.utils.Normalize.java
License:asdf
/** * Normalizes and returns a span array//w w w. java 2 s .co m * @param args string to normalize * @return processed span array with (normalized) string chunks */ public static Span[] normalizeWithSpans(String args) { final StringBuilder t = new StringBuilder(); final int length = args.length(); List<Span> res = new ArrayList<Span>(); int pi = -1; for (int i = 0; i < length; i++) { char charAt = args.charAt(i); if (Character.isLetterOrDigit(charAt) && !Character.isWhitespace(charAt)) { if (pi < 0) pi = i; t.append(Character.toLowerCase(charAt)); } else { if (t.length() > 0) { res.add(new Span(t.toString(), pi, i)); pi = -1; t.setLength(0); } } } if (t.length() > 0) res.add(new Span(t.toString(), pi, length)); return res.toArray(new Span[0]); }
From source file:Palindrome.java
protected static String removeJunk(String string) { int i, len = string.length(); StringBuilder dest = new StringBuilder(len); char c;// w w w. j a va 2 s. c o m for (i = (len - 1); i >= 0; i--) { c = string.charAt(i); if (Character.isLetterOrDigit(c)) { dest.append(c); } } return dest.toString(); }
From source file:Palindrome.java
protected static String removeJunk(String string) { int i, len = string.length(); StringBuffer dest = new StringBuffer(len); char c;/* w w w .ja va 2s .c o m*/ for (i = (len - 1); i >= 0; i--) { c = string.charAt(i); if (Character.isLetterOrDigit(c)) { dest.append(c); } } return dest.toString(); }
From source file:io.spring.initializr.util.VersionProperty.java
private static String validateFormat(String property) { for (char c : property.toCharArray()) { if (Character.isUpperCase(c)) { throw new IllegalArgumentException( "Invalid property '" + property + "', must not contain upper case"); }// w ww .ja v a 2 s . c o m if (!Character.isLetterOrDigit(c) && !SUPPORTED_CHARS.contains(c)) { throw new IllegalArgumentException("Unsupported character '" + c + "' for '" + property + "'"); } } return property; }
From source file:org.apache.archiva.redback.policy.rules.AlphaNumericPasswordRule.java
public void testPassword(PasswordRuleViolations violations, User user) { char[] password = user.getPassword().toCharArray(); for (int i = 0; i < password.length; i++) { if (!Character.isLetterOrDigit(password[i])) { violations.addViolation(ALPHANUM_VIOLATION); return; }//w w w .j av a 2 s . c om } }
From source file:nl.strohalm.cyclos.utils.StringHelper.java
/** * Removes the given mask from the given value *///from w ww.j av a 2 s . c o m public static String applyMask(final String mask, final String value) { if (StringUtils.isEmpty(mask) || value == null) { return value; } final StringBuilder sb = new StringBuilder(); boolean nextIsLiteral = false; int pos = 0; for (int i = 0; i < mask.length(); i++) { final char c = mask.charAt(i); if (c == '\\') { nextIsLiteral = true; } else if (!nextIsLiteral && MASK_VARIABLES.indexOf(c) >= 0) { try { sb.append(value.charAt(pos++)); } catch (final StringIndexOutOfBoundsException e) { continue; } } else { nextIsLiteral = false; sb.append(c); if (Character.isLetterOrDigit(c)) { pos++; } } } return sb.toString(); }
From source file:Main.java
public void setEditor(ComboBoxEditor anEditor) { super.setEditor(anEditor); if (anEditor.getEditorComponent() instanceof JTextField) { tf = (JTextField) anEditor.getEditorComponent(); tf.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ev) { char key = ev.getKeyChar(); if (!(Character.isLetterOrDigit(key) || Character.isSpaceChar(key))) { return; }/*w w w .j a va 2 s. co m*/ String s = tf.getText(); caretPos = tf.getCaretPosition(); try { String text = tf.getText(0, caretPos); int n = getItemCount(); for (int i = 0; i < n; i++) { int ind = ((String) getItemAt(i)).indexOf(text); if (ind == 0) { setSelectedIndex(i); return; } } } catch (Exception ex) { ex.printStackTrace(); } } }); } }
From source file:Main.java
public static final boolean isNameChar(char c) { switch (c) {//w ww . j ava 2 s . c o m case '.': case '-': case '_': case ':': break; case 0x05BF: case 0x05C4: case 0x0670: case 0x093C: case 0x094D: case 0x09BC: case 0x09BE: case 0x09BF: case 0x09D7: case 0x0A02: case 0x0A3C: case 0x0A3E: case 0x0A3F: case 0x0ABC: case 0x0B3C: case 0x0BD7: case 0x0D57: case 0x0E31: case 0x0EB1: case 0x0F35: case 0x0F37: case 0x0F39: case 0x0F3E: case 0x0F3F: case 0x0F97: case 0x0FB9: case 0x20E1: case 0x3099: case 0x309A: // CombiningChar. break; case 0x00B7: case 0x02D0: case 0x02D1: case 0x0387: case 0x0640: case 0x0E46: case 0x0EC6: case 0x3005: // Extender. break; default: if (Character.isLetterOrDigit(c)) break; if ((c >= 0x0300 && c <= 0x0345) || (c >= 0x0360 && c <= 0x0361) || (c >= 0x0483 && c <= 0x0486) || (c >= 0x0591 && c <= 0x05A1) || (c >= 0x05A3 && c <= 0x05B9) || (c >= 0x05BB && c <= 0x05BD) || (c >= 0x05C1 && c <= 0x05C2) || (c >= 0x064B && c <= 0x0652) || (c >= 0x06D6 && c <= 0x06DC) || (c >= 0x06DD && c <= 0x06DF) || (c >= 0x06E0 && c <= 0x06E4) || (c >= 0x06E7 && c <= 0x06E8) || (c >= 0x06EA && c <= 0x06ED) || (c >= 0x0901 && c <= 0x0903) || (c >= 0x093E && c <= 0x094C) || (c >= 0x0951 && c <= 0x0954) || (c >= 0x0962 && c <= 0x0963) || (c >= 0x0981 && c <= 0x0983) || (c >= 0x09C0 && c <= 0x09C4) || (c >= 0x09C7 && c <= 0x09C8) || (c >= 0x09CB && c <= 0x09CD) || (c >= 0x09E2 && c <= 0x09E3) || (c >= 0x0A40 && c <= 0x0A42) || (c >= 0x0A47 && c <= 0x0A48) || (c >= 0x0A4B && c <= 0x0A4D) || (c >= 0x0A70 && c <= 0x0A71) || (c >= 0x0A81 && c <= 0x0A83) || (c >= 0x0ABE && c <= 0x0AC5) || (c >= 0x0AC7 && c <= 0x0AC9) || (c >= 0x0ACB && c <= 0x0ACD) || (c >= 0x0B01 && c <= 0x0B03) || (c >= 0x0B3E && c <= 0x0B43) || (c >= 0x0B47 && c <= 0x0B48) || (c >= 0x0B4B && c <= 0x0B4D) || (c >= 0x0B56 && c <= 0x0B57) || (c >= 0x0B82 && c <= 0x0B83) || (c >= 0x0BBE && c <= 0x0BC2) || (c >= 0x0BC6 && c <= 0x0BC8) || (c >= 0x0BCA && c <= 0x0BCD) || (c >= 0x0C01 && c <= 0x0C03) || (c >= 0x0C3E && c <= 0x0C44) || (c >= 0x0C46 && c <= 0x0C48) || (c >= 0x0C4A && c <= 0x0C4D) || (c >= 0x0C55 && c <= 0x0C56) || (c >= 0x0C82 && c <= 0x0C83) || (c >= 0x0CBE && c <= 0x0CC4) || (c >= 0x0CC6 && c <= 0x0CC8) || (c >= 0x0CCA && c <= 0x0CCD) || (c >= 0x0CD5 && c <= 0x0CD6) || (c >= 0x0D02 && c <= 0x0D03) || (c >= 0x0D3E && c <= 0x0D43) || (c >= 0x0D46 && c <= 0x0D48) || (c >= 0x0D4A && c <= 0x0D4D) || (c >= 0x0E34 && c <= 0x0E3A) || (c >= 0x0E47 && c <= 0x0E4E) || (c >= 0x0EB4 && c <= 0x0EB9) || (c >= 0x0EBB && c <= 0x0EBC) || (c >= 0x0EC8 && c <= 0x0ECD) || (c >= 0x0F18 && c <= 0x0F19) || (c >= 0x0F71 && c <= 0x0F84) || (c >= 0x0F86 && c <= 0x0F8B) || (c >= 0x0F90 && c <= 0x0F95) || (c >= 0x0F99 && c <= 0x0FAD) || (c >= 0x0FB1 && c <= 0x0FB7) || (c >= 0x20D0 && c <= 0x20DC) || (c >= 0x302A && c <= 0x302F)) // CombiningChar break; if ((c >= 0x3031 && c <= 0x3035) || (c >= 0x309D && c <= 0x309E) || (c >= 0x30FC && c <= 0x30FE)) // Extender. break; return false; } return true; }