List of usage examples for java.lang Character isJavaIdentifierPart
public static boolean isJavaIdentifierPart(int codePoint)
From source file:org.apache.maven.plugin.javadoc.JavadocUtil.java
private static boolean isValidClassName(String str) { if (StringUtils.isEmpty(str) || !Character.isJavaIdentifierStart(str.charAt(0))) { return false; }/* ww w . j ava2 s. co m*/ for (int i = str.length() - 1; i > 0; i--) { if (!Character.isJavaIdentifierPart(str.charAt(i))) { return false; } } return true; }
From source file:org.apache.manifoldcf.agents.output.solr.HttpPoster.java
/** See CONNECTORS-956. Make a safe lucene field name from a possibly * unsafe input field name from a repository connector. *//*from www.java 2 s . co m*/ protected static String makeSafeLuceneField(String inputField) { StringBuilder sb = new StringBuilder(); boolean isFirst = true; for (int i = 0; i < inputField.length(); i++) { char x = inputField.charAt(i); if (isFirst && !Character.isJavaIdentifierStart(x) || !isFirst && !Character.isJavaIdentifierPart(x)) { // Check for exceptions for Lucene if (!isFirst && (x == '.' || x == '-')) sb.append(x); else sb.append('_'); } else { // Check for exceptions for Lucene if (isFirst && x == '$') sb.append('_'); else sb.append(x); } isFirst = false; } return sb.toString(); }