List of usage examples for java.lang Character isLetterOrDigit
public static boolean isLetterOrDigit(int codePoint)
From source file:com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute.java
/** * Return the requested number of characters of the text associated to this attribute, in the current * language purged by the HTML tags, if any. * @param n The number of characters to return * @return The string of text with the desired length. * @deprecated It might return less characters than requested. Use the getHeadEscaped instead *//*from www . j a v a 2 s .co m*/ public String getHead(int n) { HtmlHandler htmlhandler = new HtmlHandler(); String parsedText = htmlhandler.getParsedText(super.getText()); String head = parsedText; if (n < parsedText.length()) { while ((Character.isLetterOrDigit(parsedText.charAt(n)) || (parsedText.charAt(n) == ';')) && (n < parsedText.length())) { n++; } head = parsedText.substring(0, n); } return head; }
From source file:org.jboss.tools.openshift.common.core.utils.StringUtils.java
public static boolean isAlphaNumericOrUnderscore(String value) { for (int i = 0; i < value.length(); ++i) { final char c = value.charAt(i); if (c != '_') { if (!Character.isLetterOrDigit(c)) { return false; }/* ww w . ja v a 2 s . co m*/ } } return true; }
From source file:ed.util.LicenseHeaderCheck.java
boolean skip(File f) { final String fString = f.toString(); if (fString.contains("/.git")) return true; for (String test : _skip) if (fString.contains(test)) return true; final String name = f.getName(); if (name.endsWith("~")) return true; if (name.equals("db") || name.equals("README")) return true; if (name.equals("_init.js")) return false; if (!Character.isLetterOrDigit(name.charAt(0))) return true; if (name.toLowerCase().startsWith("makefile") || name.toLowerCase().startsWith("oplog")) return true; if (name.contains(".")) { final String ext = ed.appserver.MimeTypes.getExtension(f); if (_skipExtensions.contains(ext)) return true; }//from w ww. ja v a2 s . c om return false; }
From source file:org.silverpeas.core.util.EncodingUtil.java
/** * If the value contains one character which is neither an alphanumeric, neither a whitespace * neither a punctuation character, then the encoding has to be checked * @param value the value to verify./* w ww . ja v a 2 s .co m*/ * @return true if the encoding of the given value has to be checked. */ private static boolean hasEncodingToBeChecked(String value) { if (value != null) { char[] chars = value.toCharArray(); for (char currentChar : chars) { if (!Character.isLetterOrDigit(currentChar) && !Character.isWhitespace(currentChar) && !ArrayUtils.contains(PUNCTUATION, currentChar)) { return true; } } } return false; }
From source file:com.linuxbox.enkive.docsearch.indri.IndriQueryComposer.java
/** * Sanitize search term by only allowing letters, digits, and a small subset * of symbols./*from w w w . ja v a2 s. c o m*/ * * @param buffer */ protected static void sanitizeStringBuffer(StringBuffer buffer) { for (int i = buffer.length() - 1; i >= 0; i--) { Character c = buffer.charAt(i); if (!Character.isLetterOrDigit(c) && !allowableSymbols.contains(c)) { buffer.deleteCharAt(i); } } }
From source file:de.innovationgate.webgate.api.jdbc.PortletRegistryImplV4.java
public static String buildNamespacePrefix(String dbkey) { dbkey = dbkey.toLowerCase();//from w ww. j av a 2 s . c om String prefix = StringUtils.left(dbkey, 1) + StringUtils.right(dbkey, 2); if (prefix.length() < 3) { prefix += StringUtils.repeat("x", 3 - prefix.length()); } // Escape non alphanumeric characters as x char[] chars = prefix.toCharArray(); for (int i = 0; i < chars.length; i++) { if (!Character.isLetterOrDigit(chars[i])) { chars[i] = 'x'; } } return new String(chars); }
From source file:co.uk.sentinelweb.drawcustom.api.DrawCustomSetTemplate.java
public static boolean checkTypeName(Context c, String s) throws Exception { if (s == null) { throw new Exception("typeName is null"); }//from ww w . j a v a2s.com String fullName = getFullName(c, s); String typeName = getTypeFromFull(fullName); for (int i = typeName.length() - 1; i > 0; i--) { if (!Character.isLetterOrDigit(typeName.charAt(i)) && typeName.charAt(i) != '_') { throw new Exception("Illegal type name, letters, digits or underscores only"); } } return true; }
From source file:net.jforum.util.URLNormalizer.java
/** * //from w ww . j a va2 s . co m * @param url the url to normalize * @param limit do not process more than <code>limit + 1</code> chars * @param friendlyTruncate If <code>true</code>, will try to not cut a word if * more than <code>limit</code> chars were processed. It will stop in the next * special char * @return the normalized url */ public static String normalize(String url, int limit, boolean friendlyTruncate) { char[] chars = url.toCharArray(); StringBuffer sb = new StringBuffer(url.length()); for (int i = 0; i < chars.length; i++) { if (i <= limit || (friendlyTruncate && i > limit && sb.charAt(sb.length() - 1) != '_')) { if (Character.isSpaceChar(chars[i]) || chars[i] == '-') { if (friendlyTruncate && i > limit) { break; } if (i > 0 && sb.charAt(sb.length() - 1) != '_') { sb.append('_'); } } if (Character.isLetterOrDigit(chars[i])) { sb.append(chars[i]); } else if (friendlyTruncate && i > limit) { break; } } } return sb.toString().toLowerCase(); }
From source file:Main.java
/** * Find the start of the next token. A token is composed of letters and numbers. Any other * character are considered delimiters.//from w w w . java 2s .co m * * @param line The string to search for the next token. * @param startIndex The index to start searching. 0 based indexing. * @return The index for the start of the next token. line.length() if next token not found. */ @VisibleForTesting static int findNextTokenStart(String line, int startIndex) { int index = startIndex; // If already in token, eat remainder of token. while (index <= line.length()) { if (index == line.length()) { // No more tokens. return index; } final int codePoint = line.codePointAt(index); if (!Character.isLetterOrDigit(codePoint)) { break; } index += Character.charCount(codePoint); } // Out of token, eat all consecutive delimiters. while (index <= line.length()) { if (index == line.length()) { return index; } final int codePoint = line.codePointAt(index); if (Character.isLetterOrDigit(codePoint)) { break; } index += Character.charCount(codePoint); } return index; }
From source file:com.pfarrell.utils.misc.TextTools.java
/** * make a string with no whitespace at all * @param arg string/*from w ww .j a v a2 s .c o m*/ * @return string with no whitespace */ public static String justLettersOrDigits(String arg) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < arg.length(); i++) { int c = arg.codePointAt(i); if (Character.isLetterOrDigit(c)) { sb.appendCodePoint(c); } } return sb.toString(); }