List of usage examples for java.lang Character toUpperCase
public static int toUpperCase(int codePoint)
From source file:com.mcxiaoke.next.http.util.URLUtils.java
private static String urlEncode(final String content, final Charset charset, final BitSet safechars, final boolean blankAsPlus) { if (content == null) { return null; }//from w ww. jav a 2 s . c om final StringBuilder buf = new StringBuilder(); final ByteBuffer bb = charset.encode(content); while (bb.hasRemaining()) { final int b = bb.get() & 0xff; if (safechars.get(b)) { buf.append((char) b); } else if (blankAsPlus && b == ' ') { buf.append('+'); } else { buf.append("%"); final char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX)); final char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX)); buf.append(hex1); buf.append(hex2); } } return buf.toString(); }
From source file:com.neutti.webframe.util.StringUtil.java
public static String toCamelCase(String value) { StringBuilder sb = new StringBuilder(); final char delimChar = '_'; boolean lower = false; for (int charInd = 0; charInd < value.length(); ++charInd) { final char valueChar = value.charAt(charInd); if (valueChar == delimChar) { lower = false;//w w w. ja v a2 s .c o m } else if (lower) { sb.append(Character.toLowerCase(valueChar)); } else { sb.append(Character.toUpperCase(valueChar)); lower = true; } } String str = sb.toString(); return str.substring(0, 1).toLowerCase() + str.substring(1); }
From source file:com.redhat.rhn.frontend.taglibs.list.DataSetManipulator.java
/** * Finds the first instance of an entry in DataSet that starts with the letter * "alphaPosition"// w w w . j a v a 2s .com * @return int the position within the DataSet of that entry */ public int findAlphaPosition() { AlphaBarHelper helper = AlphaBarHelper.getInstance(); if (helper.isSelected(uniqueName, request)) { if (alphaPosition > -1) { return alphaPosition; } char alpha = Character.toUpperCase(helper.getAlphaValue(uniqueName, request).charAt(0)); int i = 0; for (Object inputRow : dataset) { String value = getAlphaValue(inputRow); if (!StringUtils.isBlank(value)) { char val = value.charAt(0); val = Character.toUpperCase(val); if (val == alpha) { alphaPosition = i; return i; } } i++; } } return -1; }
From source file:gov.nih.nci.cabig.caaers.web.admin.CTEPDataInitializationAjaxFacade.java
private String getServiceNameFromEntityAndOperation(String entity, String operation) { if (operation.equalsIgnoreCase("updateStudy") || operation.equalsIgnoreCase("createStudy")) { return "GetStudyDetails"; }/*from w w w .ja v a 2 s .com*/ StringBuffer serviceName = new StringBuffer( Character.toString((Character.toUpperCase(operation.charAt(0))))); serviceName.append(operation.substring(1)); return serviceName.toString(); }
From source file:com.openerp.addons.messages.Message.java
public static String capitalizeString(String string) { char[] chars = string.toLowerCase().toCharArray(); boolean found = false; for (int i = 0; i < chars.length; i++) { if (!found && Character.isLetter(chars[i])) { chars[i] = Character.toUpperCase(chars[i]); found = true;/* www . j a v a 2 s . co m*/ } else if (Character.isWhitespace(chars[i]) || chars[i] == '.' || chars[i] == '\'') { // You can add other chars here found = false; } } return String.valueOf(chars); }
From source file:com.hybridbpm.core.util.HybridbpmCoreUtil.java
public static String generateClassName(String name, String version) { StringBuilder nameValue = new StringBuilder(); nameValue.append(name != null ? name : "").append("_").append(version != null ? version : "_"); StringBuilder result = new StringBuilder(); for (Character c : nameValue.toString().toCharArray()) { if (Character.isJavaIdentifierPart(c)) { result.append(c);/* w ww .j a v a 2s .c o m*/ } else { result.append("_"); } } while (!Character.isJavaIdentifierStart(result.charAt(0))) { result.deleteCharAt(0); } return Character.toUpperCase(result.charAt(0)) + result.substring(1); }
From source file:com.hiperium.dao.common.generic.GenericDAO.java
/** * Gets the columns that form the primary key of an entity. * //from w ww . j a va 2 s. com * @param object * Entity that contains the primary fields. * @return the list of primary key fields. */ @SuppressWarnings("unchecked") private <E> List<String> getIdFields(Object object) { Class<E> classe = (Class<E>) object.getClass(); Field[] fields = classe.getDeclaredFields(); List<String> primaryKeys = new ArrayList<String>(); for (Field field : fields) { Annotation[] annotationArray = field.getAnnotations(); for (Annotation annotation : annotationArray) { if ("@javax.persistence.Id()".equals(annotation.toString())) { primaryKeys.add(field.getName()); break; } else if ("@javax.persistence.EmbeddedId()".equals(annotation.toString())) { String fieldName = field.getName(); String methodName = "get" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); try { Method method = classe.getMethod(methodName, new Class[] {}); Object result = method.invoke(object, new Object[] {}); Class<E> classe1 = (Class<E>) result.getClass(); Field[] fields1 = classe1.getDeclaredFields(); for (Field fieldPK : fields1) { if (!"serialVersionUID".equals(fieldPK.getName())) { primaryKeys.add(fieldName + "." + fieldPK.getName()); } } } catch (RuntimeException e) { continue; } catch (NoSuchMethodException e) { continue; } catch (IllegalAccessException e) { continue; } catch (InvocationTargetException e) { continue; } } } } return primaryKeys; }
From source file:com.hybridbpm.core.util.HybridbpmCoreUtil.java
public static String checkClassName(String name) { name = name.replaceAll("\\s+", "").replaceAll("\\W", ""); StringBuilder result = new StringBuilder(); for (Character c : name.toCharArray()) { if (Character.isJavaIdentifierPart(c)) { result.append(c);/* w ww .j a va2s .c o m*/ } else { result.append("_"); } } while (!Character.isJavaIdentifierStart(result.charAt(0))) { result.deleteCharAt(0); } return Character.toUpperCase(result.charAt(0)) + result.substring(1); }
From source file:com.prowidesoftware.swift.model.SwiftBlock2Output.java
/** * Sets the block's attributes by parsing the string argument containing the blocks value.<br /> * This value can be in different flavors because some fields are optional.<br /> * Example of supported values:<br /> * <pre>/*from w w w.ja va2s .c o m*/ * "O1001200970103BANKBEBBAXXX22221234569701031201" (46) or * "2:O1001200970103BANKBEBBAXXX22221234569701031201" (48) // used for service/system messages * "O1001200970103BANKBEBBAXXX22221234569701031201N" (47) or * "2:O1001200970103BANKBEBBAXXX22221234569701031201N" (49) * </pre><br /> * * @param value string containing the entire blocks value * @param lenient if true the value will be parsed with a best effort heuristic, if false it will throw a IllegalArgumentException if the value has an invalid total size */ public void setValue(final String value, boolean lenient) { if (lenient) { //leave all attributes as null (cleaning defaults) clean(); } else { // check parameters Validate.notNull(value, "value must not be null"); } if (value != null) { int slen = value.length(); if (!lenient) { // check parameters Validate.notNull(value, "value must not be null"); Validate.isTrue(slen == 46 || slen == 48 || slen == 47 || slen == 49, "expected a string value of 46 and up to 49 chars and obtained a " + slen + " chars string: '" + value + "'"); } // figure out the starting point and check the input value has proper optional int offset = 0; if (value.startsWith("2:")) { // accept 2:... offset = 2; } slen -= offset; if (!lenient) { if (slen != 46 && slen != 47) { throw new IllegalArgumentException("Value must match: O<mt><time><mir><date><time>[<pri>]"); } if (Character.toUpperCase(value.charAt(offset)) != 'O') { throw new IllegalArgumentException("Value must match: O<mt><time><mir><date><time>[<pri>]"); } } offset++; // skip the output mark // separate value fragments int len = 3; this.setMessageType(this.getValuePart(value, offset, len)); offset += len; len = 4; this.setSenderInputTime(this.getValuePart(value, offset, len)); offset += len; len = 28; this.setMIR(this.getValuePart(value, offset, len), lenient); offset += len; len = 6; this.setReceiverOutputDate(this.getValuePart(value, offset, len)); offset += len; len = 4; this.setReceiverOutputTime(this.getValuePart(value, offset, len)); offset += len; if (lenient) { //get all remaining text this.setMessagePriority(this.getValuePart(value, offset)); } else { len = 1; this.setMessagePriority(this.getValuePart(value, offset, len)); offset += len; // optional (system messages) } } }
From source file:de.homelab.madgaksha.lotsofbs.util.LocaleRootWordUtils.java
/** * <p>//from w w w . j a v a2s . co m * Swaps the case of a String using a word based algorithm. * </p> * * <ul> * <li>Upper case character converts to Lower case</li> * <li>Title case character converts to Lower case</li> * <li>Lower case character after Whitespace or at start converts to Title * case</li> * <li>Other Lower case character converts to Upper case</li> * </ul> * * <p> * Whitespace is defined by {@link Character#isWhitespace(char)}. A * <code>null</code> input String returns <code>null</code>. * </p> * * <pre> * StringUtils.swapCase(null) = null * StringUtils.swapCase("") = "" * StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone" * </pre> * * @param str * the String to swap case, may be null * @return the changed String, <code>null</code> if null String input */ public static String swapCase(final String str) { if (StringUtils.isEmpty(str)) { return str; } final char[] buffer = str.toCharArray(); boolean whitespace = true; for (int i = 0; i < buffer.length; i++) { final char ch = buffer[i]; if (Character.isUpperCase(ch)) { buffer[i] = Character.toLowerCase(ch); whitespace = false; } else if (Character.isTitleCase(ch)) { buffer[i] = Character.toLowerCase(ch); whitespace = false; } else if (Character.isLowerCase(ch)) { if (whitespace) { buffer[i] = Character.toTitleCase(ch); whitespace = false; } else { buffer[i] = Character.toUpperCase(ch); } } else { whitespace = Character.isWhitespace(ch); } } return new String(buffer); }