List of usage examples for java.lang String charAt
public char charAt(int index)
From source file:com.el.wordament.NodeLoader.java
private static Node createNodes(String line, Node current, int index) { if (index != line.length()) { Node next = current.createOrGet(line.charAt(index)); return createNodes(line, next, index + 1); } else {//from w w w .j ava2s . c om return current; } }
From source file:edu.illinois.cs.cogcomp.ner.StringStatisticsUtils.MyString.java
public static boolean hasDigits(String s) { for (int i = 0; i < s.length(); i++) if (Character.isDigit(s.charAt(i))) return true; return false; }
From source file:edu.mayo.cts2.framework.plugin.service.lexevs.uri.UriUtils.java
/** * Combine a URI and another token/string. * * @param uri the uri//from ww w.ja va 2s.c o m * @param tokenToAppend the token to append * @return the string */ public static String combine(String uri, String tokenToAppend) { char lastChar = uri.charAt(uri.length() - 1); if (SEPARATORS.contains(lastChar)) { return uri + tokenToAppend; } else { if (StringUtils.startsWithIgnoreCase(uri, URN_PREFIX)) { return uri + URN_SEPARATOR + tokenToAppend; } else { return uri + DEFAULT_SEPARATOR + tokenToAppend; } } }
From source file:Main.java
/** * Get field name of a bean class from a widget name. <br> * * @param widgetName wiget name. eg. tvBookName * @return bean filed. eg. bookName/*from ww w.j av a2 s . c o m*/ */ public static String getBeanFieldFromWidget(String widgetName, boolean upperFirstLetter) { int i; for (i = 0; i < widgetName.length(); i++) { char c = widgetName.charAt(i); if (c >= 'A' && c <= 'Z') { break; } } if (i < widgetName.length()) { String newWidgetName = widgetName.substring(i); return upperFirstLetter ? newWidgetName : lowerCaseFirstLetter(newWidgetName); } else { return widgetName; } }
From source file:Main.java
/** * Escape a string, do entity conversion. *///from w w w .jav a 2s . c o m static String escape(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (c) { case '<': sb.append("<"); break; case '>': sb.append(">"); break; case '&': sb.append("&"); break; case '\'': sb.append("""); break; default: sb.append(c); break; } } return sb.toString(); }
From source file:Main.java
public static String removeLastPath(String path) { String result = path; if (result == null) { return result; }//from ww w . j a va2 s . c o m if (!result.isEmpty() && result.charAt(result.length() - 1) == '/') { result = result.substring(0, result.length() - 2); } if (!result.contains("/")) { return result; } else { return result.substring(0, result.lastIndexOf("/")); } }
From source file:Main.java
public static boolean isEmptyStrict(String str) { if (isEmpty(str)) { return true; }/*ww w. j a v a 2 s .co m*/ for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { return false; } } return true; }
From source file:Main.java
/** convert given "directiveName" to "directive-name" */ private static String getDirectiveNameAsHtmlAttribute(String directiveName) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < directiveName.length(); i++) { char ch = directiveName.charAt(i); if (Character.isUpperCase(ch)) { sb.append('-'); ch = Character.toLowerCase(ch); }//from www . j av a 2s .com sb.append(ch); } return sb.toString(); }
From source file:Main.java
public static boolean isEmpty(String s) { if (s == null || "".equals(s)) { return true; }// www. j a v a 2 s .c o m for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c != ' ' && c != '\t' && c != '\n') { return false; } } return true; }
From source file:Main.java
private static String cleanUp(String p) { int oldLenght = p.length(); do {/*ww w.ja v a 2 s. c o m*/ p = p.trim(); oldLenght = p.length(); if ((p.charAt(0) == '(') && (p.charAt(p.length() - 1) == ')')) { p = p.substring(1, p.length() - 1); } } while (oldLenght != p.length()); return p.toLowerCase(); }