List of usage examples for java.lang Character isLetter
public static boolean isLetter(int codePoint)
From source file:ca.mcgill.cs.swevo.qualyzer.editors.RTFDocumentProvider2.java
private ParserPair handleControl(InputStream contentStream, int startChar, String startControl, Map<String, Integer> state) throws IOException { StringBuilder controlWord = new StringBuilder(startControl); int c = startChar; char ch;//from w w w . ja va 2 s. co m while (c != -1) { ch = (char) c; if (ch == UNICODE && isEmpty(controlWord)) { // This is potentially an unicode char ParserPair pair = getUnicode(contentStream, state); c = pair.fChar; controlWord = new StringBuilder(pair.fString); break; } else if (Character.isLetter(ch)) { // Start of a control word controlWord.append(ch); } else if (ch == ESCAPE_8BIT && isEmpty(controlWord)) { // This is an escaped 8bit char ParserPair pair = get8Bit(contentStream); c = pair.fChar; controlWord = new StringBuilder(pair.fString); break; } else if (Character.isDigit(ch)) { // Unit of control word controlWord.append(ch); } else if (ch == MINUS) { controlWord.append(ch); } else { if (isEmpty(controlWord)) { controlWord.append(ch); c = contentStream.read(); } else if (Character.isWhitespace(ch)) { // This is a delimiter. Skip it c = contentStream.read(); } break; } c = contentStream.read(); } return new ParserPair(c, controlWord.toString()); }
From source file:com.prowidesoftware.swift.model.Tag.java
/** * Iterate the current tagname and return only letters as told by {@link Character#isLetter(char)} * /*from w w w . ja v a2 s .c o m*/ * @return a string containing only letter characters of the tagname or <code>null</code> if no letters are found */ public String getLetterOption() { if (this.name != null) { final StringBuilder sb = new StringBuilder(); for (int i = 0; i < this.name.length(); i++) { char c = this.name.charAt(i); if (Character.isLetter(c)) { sb.append(c); } } if (sb.length() > 0) { return sb.toString(); } } return null; }
From source file:com.commander4j.util.JUtility.java
static String capitalize(String input) { String str = input.toLowerCase(); String result = ""; char ch;/*from w w w.j a v a 2 s.c o m*/ char prevCh; int i; prevCh = '.'; for (i = 0; i < str.length(); i++) { ch = str.charAt(i); if (Character.isLetter(ch) && !Character.isLetter(prevCh)) { result = result + Character.toUpperCase(ch); } else { result = result + ch; } prevCh = ch; } return result; }
From source file:org.exoplatform.ecm.webui.component.explorer.control.UIAddressBar.java
public static String UppercaseFirstLetters(String str) { boolean prevWasWhiteSp = true; char[] chars = str.toCharArray(); for (int i = 0; i < chars.length; i++) { if (Character.isLetter(chars[i])) { if (prevWasWhiteSp) { chars[i] = Character.toUpperCase(chars[i]); }/*from w w w .j a v a2 s . c o m*/ prevWasWhiteSp = false; } else { prevWasWhiteSp = Character.isWhitespace(chars[i]); } } return new String(chars); }
From source file:org.apache.oozie.store.StoreStatusFilter.java
private static Date parseCreatedTimeString(String time) throws Exception { Date createdTime = null;/*from www. j av a2s. c om*/ int offset = 0; if (Character.isLetter(time.charAt(time.length() - 1))) { switch (time.charAt(time.length() - 1)) { case 'd': offset = Integer.parseInt(time.substring(0, time.length() - 1)); if (offset > 0) { throw new IllegalArgumentException("offset must be minus from currentTime."); } createdTime = org.apache.commons.lang.time.DateUtils.addDays(new Date(), offset); break; case 'h': offset = Integer.parseInt(time.substring(0, time.length() - 1)); if (offset > 0) { throw new IllegalArgumentException("offset must be minus from currentTime."); } createdTime = org.apache.commons.lang.time.DateUtils.addHours(new Date(), offset); break; case 'm': offset = Integer.parseInt(time.substring(0, time.length() - 1)); if (offset > 0) { throw new IllegalArgumentException("offset must be minus from currentTime."); } createdTime = org.apache.commons.lang.time.DateUtils.addMinutes(new Date(), offset); break; case 'Z': createdTime = DateUtils.parseDateUTC(time); break; default: throw new IllegalArgumentException("Unsupported time format: " + time + TIME_FORMAT); } } else { throw new IllegalArgumentException("The format of time is wrong: " + time + TIME_FORMAT); } return createdTime; }
From source file:com.welfare.common.util.UtilValidate.java
/** * Returns true if character c is an English letter (A .. Z, a..z). * <p>//from w w w. j av a 2s.c o m * NOTE: Need i18n version to support European characters. * This could be tricky due to different character * sets and orderings for various languages and platforms. */ public static boolean isLetter(char c) { return Character.isLetter(c); }
From source file:app.sunstreak.yourpisd.net.Parser.java
public static String toTitleCase(String str) { StringBuilder sb = new StringBuilder(str.length()); boolean capitalize = false; for (int charNum = 0; charNum < str.length(); charNum++) { capitalize = (charNum == 0 || !Character.isLetter(str.charAt(charNum - 1)) || (str.substring(charNum - 1, charNum + 1).equals("AP") || str.substring(charNum - 1, charNum + 1).equals("IB") || str.substring(charNum - 1, charNum + 1).equals("IH")) && (charNum + 2 >= str.length() || !Character.isLetter(str.charAt(charNum + 1)))); if (capitalize) sb.append(Character.toUpperCase(str.charAt(charNum))); else// w ww.j ava 2 s . c om sb.append(Character.toLowerCase(str.charAt(charNum))); } return sb.toString(); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLAnchorElement.java
/** * Returns the protocol portion of the link's URL, including the trailing ':'. * @return the protocol portion of the link's URL, including the trailing ':' * @throws Exception if an error occurs//from www . j a v a2 s . c om * @see <a href="http://msdn.microsoft.com/en-us/library/ms534353.aspx">MSDN Documentation</a> */ @JsxGetter public String getProtocol() throws Exception { try { if (getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL)) { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); final String href = anchor.getHrefAttribute().toLowerCase(Locale.ROOT); if (href.length() > 1 && Character.isLetter(href.charAt(0)) && ':' == href.charAt(1)) { return "file:"; } } return getUrl().getProtocol() + ":"; } catch (final MalformedURLException e) { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); if (anchor.getHrefAttribute().startsWith("http") && getBrowserVersion().hasFeature(JS_ANCHOR_PROTOCOL_COLON_FOR_BROKEN_URL)) { return ":"; } return StringUtils.substringBefore(anchor.getHrefAttribute(), "/"); } }
From source file:CharUtils.java
/** * True if first letter in a string is uppercase. * //from w ww . j a v a 2s . c o m * @param s * String to check for initial uppercase letter. * * @return true if first letter in string is uppercase. * * <p> * Leading non-letters are ignored. If none of the characters in the * string is a letters, false is returned. * </p> */ public static boolean isFirstLetterCapital(String s) { boolean result = false; String ts = s.trim(); for (int i = 0; i < ts.length(); i++) { if (Character.isLetter(ts.charAt(i))) { result = Character.isUpperCase(ts.charAt(i)); break; } } return result; }
From source file:ru.goodfil.catalog.ui.forms.FiltersPanel.java
private static String mask(String source) { StringBuilder sb = new StringBuilder(); for (char c : source.toCharArray()) { if (Character.isLetter(c) || Character.isDigit(c)) { sb.append(c);/* ww w. j a va 2s . co m*/ } } return sb.toString().trim().toUpperCase(); }