List of usage examples for java.lang Character isLetter
public static boolean isLetter(int codePoint)
From source file:gov.nih.nci.ncicb.cadsr.evs.LexEVSQueryServiceImpl.java
private String findBestContainsAlgorithm(String matchText) { if (matchText == null) return "nonLeadingWildcardLiteralSubString"; matchText = matchText.trim();// w ww . j av a 2s .c om if (matchText.length() == 0) return "nonLeadingWildcardLiteralSubString"; // or null if (matchText.length() > 1) return "nonLeadingWildcardLiteralSubString"; char ch = matchText.charAt(0); if (Character.isDigit(ch)) return "literal"; else if (Character.isLetter(ch)) return "LuceneQuery"; else return "literalContains"; }
From source file:org.mitre.opensextant.util.TextUtils.java
/** * Normalization: Clean the ends, Remove Line-endings from middle of entity. * <pre>//from w w w. j a v a2s .c o m * Example: * TEXT: **The Daily Newsletter of \n\rBarbara, So.** * CLEAN: __The Daily Newsletter of __Barbara, So___ * * Where "__" represents omitted characters. * </pre> */ public static String normalize_text_entity(String str) { if (StringUtils.isBlank(str)) { return null; } char[] chars = str.toCharArray(); int s1 = 0, s2 = chars.length - 1; int end = s2; while (s1 < s2 && !(Character.isLetter(chars[s1]) || Character.isDigit(chars[s1]))) { ++s1; } // No text found if (s1 == s2) { return null; } while (s2 > s1 && !(Character.isLetter(chars[s2]) || Character.isDigit(chars[s2]))) { --s2; } if (s1 == 0 && s2 == end) { // No cleanup to do. return squeeze_whitespace(str); } // NOT possible, I hope... if (s2 <= s1) { return null; } // Some cleanup was done on ends of String. Now clear up whitespace. // return squeeze_whitespace(str.substring(s1, s2 + 1)); }
From source file:r.parser.RLexer.java
private int consumeNextToken() { int c;//ww w .j a va 2 s . c o m if (savedToken != 0) { c = savedToken; yylval = savedLVal; savedLVal = R_NilValue; savedToken = 0; tokenBegin = savedTokenPos; return c; } xxcharsave = xxcharcount; /* want to be able to go back one token */ c = skipSpace(); if (c == '\r') { c = xxgetc(); if (c != '\n') { xxungetc(c); c = '\r'; } } if (c == '#') c = skipComment(); tokenBegin.line = srcRef.xxlineno; tokenBegin.column = srcRef.xxcolno; tokenBegin.byteIndex = srcRef.xxbyteno; if (c == R_EOF) return END_OF_INPUT; /* Either digits or symbols can start with a "." */ /* so we need to decide which it is and jump to */ /* the correct spot. */ if (c == '.' && typeofnext() >= 2) { return consumeSymbolValue(c); } /* literal numbers */ if (c == '.') { return consumeNumericValue(c); } /* We don't care about other than ASCII digits */ if (isDigit(c)) { return consumeNumericValue(c); } /* literal strings */ if (c == '\"' || c == '\'') { return consumeStringValue(c, false); } /* special functions */ if (c == '%') return consumeSpecialValue(c); /* functions, constants and variables */ if (c == '`') { return consumeStringValue(c, true); } if (Character.isLetter(c)) { return consumeSymbolValue(c); } /* compound tokens */ switch (c) { case '<': if (nextchar('=')) { yylval = install("<="); return LE; } if (nextchar('-')) { yylval = install("<-"); return LEFT_ASSIGN; } if (nextchar('<')) { if (nextchar('-')) { yylval = install("<<-"); return LEFT_ASSIGN; } else return ERROR; } yylval = install("<"); return LT; case '-': if (nextchar('>')) { if (nextchar('>')) { yylval = install("<<-"); return RIGHT_ASSIGN; } else { yylval = install("<-"); return RIGHT_ASSIGN; } } yylval = install("-"); return '-'; case '>': if (nextchar('=')) { yylval = install(">="); return GE; } yylval = install(">"); return GT; case '!': if (nextchar('=')) { yylval = install("!="); return NE; } yylval = install("!"); return '!'; case '=': if (nextchar('=')) { yylval = install("=="); return EQ; } yylval = install("="); return EQ_ASSIGN; case ':': if (nextchar(':')) { if (nextchar(':')) { yylval = install(":::"); return NS_GET_INT; } else { yylval = install("::"); return NS_GET; } } if (nextchar('=')) { yylval = install(":="); return LEFT_ASSIGN; } yylval = install(":"); return ':'; case '&': if (nextchar('&')) { yylval = install("&&"); return AND2; } yylval = install("&"); return AND; case '|': if (nextchar('|')) { yylval = install("||"); return OR2; } yylval = install("|"); return OR; case LBRACE: yylval = install("{"); return c; case RBRACE: return c; case '(': yylval = install("("); return c; case ')': return c; case '[': if (nextchar('[')) { yylval = install("[["); return LBB; } yylval = install("["); return c; case ']': return c; case '?': yylval = install("?"); return c; case '*': /* Replace ** by ^. This has been here since 1998, but is undocumented (at least in the obvious places). It is in the index of the Blue Book with a reference to p. 431, the help for 'Deprecated'. S-PLUS 6.2 still allowed this, so presumably it was for compatibility with S. */ if (nextchar('*')) { c = '^'; } yylval = install(codePointToString(c)); return c; case '+': case '/': case '^': case '~': case '$': case '@': yylval = install(codePointToString(c)); return c; default: return c; } }
From source file:org.plasma.text.lang3gl.java.DefaultFactory.java
protected String toConstantName(String name) { name = name.trim();//from www.j a v a 2 s.c o m StringBuilder buf = new StringBuilder(); char[] array = name.toCharArray(); for (int i = 0; i < array.length; i++) { String lit = reservedJavaCharToLiteralMap.get(Character.valueOf(array[i])); if (lit != null) { buf.append(lit.toUpperCase()); continue; } if (i > 0) { if (Character.isLetter(array[i]) && Character.isUpperCase(array[i])) { if (!Character.isUpperCase(array[i - 1])) buf.append("_"); } } if (Character.isLetterOrDigit(array[i])) { buf.append(Character.toUpperCase(array[i])); } else buf.append("_"); } return buf.toString(); }
From source file:autohit.common.deployment.DeploymentConfigure.java
/** * Parse the config line// w w w . j a va 2 s . c o m */ private String[] parseConfigLine(BufferedReader inR) { String t[] = new String[3]; String working = null; StringTokenizer st; try { working = inR.readLine(); while ((working.length() == 0) || (working.charAt(0) == '#') || (!Character.isLetter(working.charAt(0)))) { working = inR.readLine(); } // Working should be a valid line try { st = new StringTokenizer(working); t[0] = st.nextToken(); t[1] = st.nextToken(); // the third field doesn't matter for checkpointing try { t[2] = st.nextToken(); } catch (Exception e) { t[2] = null; } } catch (Exception e) { System.out.println("BAD line in Files:\n" + working); throw e; } } catch (Exception e) { // Quit for ANY exception return null; } return t; }
From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLAnchorElement.java
/** * Returns the pathname portion of the link's URL. * @return the pathname portion of the link's URL * @throws Exception if an error occurs/*from w w w . j a v a 2 s . c o m*/ * @see <a href="http://msdn.microsoft.com/en-us/library/ms534332.aspx">MSDN Documentation</a> */ @JsxGetter public String getPathname() throws Exception { try { final URL url = getUrl(); if (!url.getProtocol().startsWith("http") && getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_NONE_FOR_NONE_HTTP_URL)) { return ""; } if (getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL)) { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); String href = anchor.getHrefAttribute(); if (href.length() > 1 && Character.isLetter(href.charAt(0)) && ':' == href.charAt(1)) { if (getBrowserVersion().hasFeature(JS_ANCHOR_PROTOCOL_COLON_UPPER_CASE_DRIVE_LETTERS)) { href = StringUtils.capitalize(href); } if (getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_PREFIX_WIN_DRIVES_URL)) { href = "/" + href; } return href; } } return url.getPath(); } catch (final MalformedURLException e) { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); if (anchor.getHrefAttribute().startsWith("http") && getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_NONE_FOR_BROKEN_URL)) { return ""; } return "/"; } }
From source file:org.tapestry.surveys.DoSurveyAction.java
private static boolean isFirstQuestionId(String str, char c) { boolean isFirst = false; int length = str.length(); //'1' is only digital in string for backward direction, and '0' for forward direction if ((str.charAt(length - 1) == c) && Character.isLetter(str.charAt(length - 2))) isFirst = true;/*from ww w. j a v a 2 s . c om*/ return isFirst; }
From source file:org.wso2.carbon.governance.list.ui.internal.GovernanceListUIServiceComponent.java
private String convertName(String[] nameParts) { String convertedName = null;/* ww w .j a v a2 s . com*/ // making widget name camel case for (String namePart : nameParts) { int i; for (i = 0; i < namePart.length(); i++) { char c = namePart.charAt(i); if (!Character.isLetter(c) || Character.isLowerCase(c)) { break; } } if (namePart.equals(nameParts[0])) { namePart = namePart.substring(0, i).toLowerCase() + namePart.substring(i); } if (convertedName == null) { convertedName = namePart; } else { convertedName += namePart; } } return convertedName; }
From source file:gov.nih.nci.caIMAGE.util.SafeHTMLUtil.java
public static boolean isLetter(String input) { for (int i = 0; i < input.length(); i++) { if (!Character.isLetter(input.charAt(i))) return false; }/*from www. j a v a 2 s . c om*/ return true; }
From source file:tufts.vue.URLResource.java
/** * Set the local file that refers to this resource, if there is one. * If mFile is set, mDataFile will always to same. If this is a packaged * resource, mFile will NOT be set, but mDataFile should be set to the package file *///from ww w. j av a 2s . c o m private Object setDataFile(File file, Object type) { // TODO performance: can skip isDirectory and exists tests if we // know this came from a LocalCabinet, which may speed up that // dog-slow code when expanding big directories. if (type == FILE_DIRECTORY || (type == FILE_UNKNOWN && file.isDirectory())) { if (DEBUG.RESOURCE && DEBUG.META) out("setDataFile: ignoring directory: " + file); //Log.warn("directory as data-file: " + file, new Throwable()); //if (DEBUG.RESOURCE) out("no use for directory data files"); return FILE_DIRECTORY; } final String path = file.toString(); if (path.length() == 3 && Character.isLetter(path.charAt(0)) && path.endsWith(":\\")) { // Check for A:\, etc. // special case to ignore / prevent testing Windows currently in-accessable mount points // File.exists may take a while to time-out on these. if (DEBUG.Enabled) out_info("setDataFile: ignoring Win mount: " + file); return FILE_DIRECTORY; } if (type == FILE_UNKNOWN) { if (DEBUG.IO) out("testing " + file); if (!file.exists()) { // todo: could attempt decodings if a '%' is present // todo: if any SPECIAL chars present, could attempt encoding in all formats and then DECODING to at least the platform format out_warn(TERM_RED + "no such active data file: " + file + TERM_CLEAR); //Util.printStackTrace("HERE"); //throw new IllegalStateException(this + "; no such active data file: " + file); return FILE_UNKNOWN; } } mDataFile = file; if (mDataFile != mFile) { if (DEBUG.IO) dumpField("scanning mDataFile ", mDataFile); setByteSize(mDataFile.length()); mLastModified = mDataFile.lastModified(); } if (DEBUG.RESOURCE) { dumpField("setDataFile", file); setDebugProperty("file.data", file); } return FILE_NORMAL; }