List of usage examples for java.lang Character isISOControl
public static boolean isISOControl(int codePoint)
From source file:hudson.model.Hudson.java
/** * Check if the given name is suitable as a name * for job, view, etc./*from w w w . j a va2 s. c o m*/ * * @throws ParseException * if the given name is not good */ public static void checkGoodName(String name) throws ParseException { if (name == null || name.length() == 0) throw new ParseException(Messages.Hudson_NoName(), 0); for (int i = 0; i < name.length(); i++) { char ch = name.charAt(i); if (Character.isISOControl(ch)) { throw new ParseException(Messages.Hudson_ControlCodeNotAllowed(toPrintableName(name)), i); } if ("?*/\\%!@#$^&|<>[]:;".indexOf(ch) != -1) throw new ParseException(Messages.Hudson_UnsafeChar(ch), i); } // looks good }
From source file:hudson.model.Hudson.java
private static String toPrintableName(String name) { StringBuilder printableName = new StringBuilder(); for (int i = 0; i < name.length(); i++) { char ch = name.charAt(i); if (Character.isISOControl(ch)) printableName.append("\\u").append((int) ch).append(';'); else//from w w w. j a v a 2s . c o m printableName.append(ch); } return printableName.toString(); }
From source file:jenkins.model.Jenkins.java
/** * Check if the given name is suitable as a name * for job, view, etc./*from ww w . j a v a 2 s . co m*/ * * @throws Failure * if the given name is not good */ public static void checkGoodName(String name) throws Failure { if (name == null || name.length() == 0) throw new Failure(Messages.Hudson_NoName()); if (".".equals(name.trim())) throw new Failure(Messages.Jenkins_NotAllowedName(".")); if ("..".equals(name.trim())) throw new Failure(Messages.Jenkins_NotAllowedName("..")); for (int i = 0; i < name.length(); i++) { char ch = name.charAt(i); if (Character.isISOControl(ch)) { throw new Failure(Messages.Hudson_ControlCodeNotAllowed(toPrintableName(name))); } if ("?*/\\%!@#$^&|<>[]:;".indexOf(ch) != -1) throw new Failure(Messages.Hudson_UnsafeChar(ch)); } // looks good }