List of usage examples for java.lang Character toUpperCase
public static int toUpperCase(int codePoint)
From source file:com.redhat.rhn.frontend.taglibs.list.DataSetManipulator.java
/** * Gets the set of characters that will be active on the alpha bar * @return the set of characters that are active *//*from w w w.j ava2s. c om*/ public Set<Character> getAlphaBarIndex() { Set<Character> chars = new HashSet<Character>(); int i = 0; for (Object inputRow : dataset) { String value = getAlphaValue(inputRow); if (!StringUtils.isBlank(value)) { // Make sure that the alpha inputs are converted // to uppercase char val = value.charAt(0); val = Character.toUpperCase(val); if (!chars.contains(val)) { // add the character to the set chars.add(val); } } i++; } return chars; }
From source file:asterix.parser.classad.Value.java
public static boolean convertValueToRealValue(Value value, Value realValue) throws HyracksDataException { boolean could_convert; AMutableCharArrayString buf = new AMutableCharArrayString(); int endIndex; char end;/*from www. ja v a 2s .co m*/ AMutableInt64 ivalue = new AMutableInt64(0); ClassAdTime atvalue = new ClassAdTime(); MutableBoolean bvalue = new MutableBoolean(); double rvalue; NumberFactor nf = NumberFactor.NO_FACTOR; switch (value.getType()) { case UNDEFINED_VALUE: realValue.setUndefinedValue(); could_convert = false; break; case ERROR_VALUE: case CLASSAD_VALUE: case LIST_VALUE: case SLIST_VALUE: realValue.setErrorValue(); could_convert = false; break; case STRING_VALUE: could_convert = true; value.isStringValue(buf); endIndex = buf.fistNonDoubleDigitChar(); if (endIndex < 0) { // no non digit String buffString = buf.toString(); if (buffString.contains("INF")) { buffString = buffString.replace("INF", "Infinity"); } rvalue = Double.parseDouble(buffString); nf = NumberFactor.NO_FACTOR; } else { rvalue = Double.parseDouble(buf.substr(0, endIndex)); end = buf.charAt(endIndex); switch (Character.toUpperCase(end)) { case 'B': nf = NumberFactor.B_FACTOR; break; case 'K': nf = NumberFactor.K_FACTOR; break; case 'M': nf = NumberFactor.M_FACTOR; break; case 'G': nf = NumberFactor.G_FACTOR; break; case 'T': nf = NumberFactor.T_FACTOR; break; case '\0': nf = NumberFactor.NO_FACTOR; break; default: nf = NumberFactor.NO_FACTOR; break; } } if (could_convert) { realValue.setRealValue(rvalue * Value.ScaleFactor[nf.ordinal()]); } break; case BOOLEAN_VALUE: value.isBooleanValue(bvalue); realValue.setRealValue(bvalue.booleanValue() ? 1.0 : 0.0); could_convert = true; break; case INTEGER_VALUE: value.isIntegerValue(ivalue); realValue.setRealValue((double) ivalue.getLongValue()); could_convert = true; break; case REAL_VALUE: realValue.copyFrom(value); could_convert = true; break; case ABSOLUTE_TIME_VALUE: value.isAbsoluteTimeValue(atvalue); realValue.setRealValue(atvalue.getTimeInMillis() / 1000.0); could_convert = true; break; case RELATIVE_TIME_VALUE: value.isRelativeTimeValue(atvalue); realValue.setRealValue(atvalue.getRelativeTime() / 1000.0); could_convert = true; break; default: could_convert = false; // Make gcc's -Wuninitalized happy throw new HyracksDataException("Should not reach here"); } return could_convert; }
From source file:de.codesourcery.springmass.springmass.SimulationParamsBuilder.java
private String extractParameterName(Method m) { Method methodWithLabel = null; if (isParameterGetter(m)) { // look for @Label on corresponding setter if (m.getName().startsWith("get") || m.getName().startsWith("is")) { final int charsToRemove = m.getName().startsWith("get") ? 3 : 2; final String setterName = "set" + m.getName().substring(charsToRemove); try { methodWithLabel = m.getDeclaringClass().getMethod(setterName, new Class<?>[] { m.getReturnType() }); } catch (NoSuchMethodException | SecurityException e) { /* ok */ } }/*from w w w . j a v a 2s. c o m*/ } else { methodWithLabel = m; } if (methodWithLabel != null) { final Label label = methodWithLabel.getAnnotation(Label.class); if (label != null && !StringUtils.isBlank(label.value())) { return label.value(); } } String name; if (m.getName().startsWith("set") || m.getName().startsWith("get")) { name = m.getName().substring(3); } else if (m.getName().startsWith("is")) { name = m.getName().substring(2); } else { throw new IllegalArgumentException("Invalid method name: " + m); } name = Character.toUpperCase(name.charAt(0)) + name.substring(1); final List<String> split = new ArrayList<>(); final StringBuffer buffer = new StringBuffer(); for (char s : name.toCharArray()) { if (Character.isUpperCase(s)) { if (buffer.length() > 1) { split.add(buffer.toString()); buffer.setLength(0); buffer.append(Character.toLowerCase(s)); continue; } } if (split.isEmpty()) { buffer.append(s); } else { buffer.append(Character.toLowerCase(s)); } } if (buffer.length() > 0) { split.add(buffer.toString()); } return StringUtils.join(split, " "); }
From source file:com.hiperium.dao.common.generic.GenericDAO.java
/** * Gets the entity properties of the object. * //from w ww . j a va 2 s . co m * @param object * entity that contains the properties. * @param primaryKey * the primary key fields. * * @return map with the properties and values to be used in the construction * of the criteria object and the searching execution. */ @SuppressWarnings("unchecked") private <E> Map<String, Object> getEntityProperties(Object object, String... primaryKey) { Class<E> classType = (Class<E>) object.getClass(); Field[] fields = classType.getDeclaredFields(); Map<String, Object> fieldsMap = new HashMap<String, Object>(fields.length); for (Field field : fields) { Boolean isLob = Boolean.FALSE; Annotation[] annotationsArray = field.getAnnotations(); for (Annotation annotation : annotationsArray) { if ("@javax.persistence.Lob()".equals(annotation.toString()) || "@javax.persistence.Transient()".equals(annotation.toString())) { isLob = Boolean.TRUE; break; } } if (!isLob) { String fieldName = field.getName(); String methodName = "get" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); try { Method method = classType.getMethod(methodName, new Class[] {}); Object result = method.invoke(object, new Object[] {}); if (result != null) { if (primaryKey != null && primaryKey.length == 1) { fieldsMap.put(primaryKey[0] + "." + field.getName(), result); } else { fieldsMap.put(field.getName(), result); } } } catch (RuntimeException e) { continue; } catch (NoSuchMethodException e) { continue; } catch (IllegalAccessException e) { continue; } catch (InvocationTargetException e) { continue; } } } return fieldsMap; }
From source file:QCodec.java
/** * Encodes byte into its quoted-printable representation. * //ww w . ja va2 s. c o m * @param b * byte to encode * @param buffer * the buffer to write to */ private static final void encodeQuotedPrintable(int b, ByteArrayOutputStream buffer) { buffer.write(ESCAPE_CHAR); char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, 16)); char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, 16)); buffer.write(hex1); buffer.write(hex2); }
From source file:com.board.games.handler.xbtit.XbtitPokerLoginServiceImpl.java
static int hexToInt(char ch) { if (ch >= '0' && ch <= '9') return ch - '0'; ch = Character.toUpperCase(ch); if (ch >= 'A' && ch <= 'F') return ch - 'A' + 0xA; throw new IllegalArgumentException("Not a hex character: " + ch); }
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/*from ww w. jav a 2s .co m*/ sb.append(Character.toLowerCase(str.charAt(charNum))); } return sb.toString(); }
From source file:com.shishu.utility.string.StringUtil.java
/** * ?????//from www. ja v a 2 s . c o m * * @param word * @return */ public static String wordMapping(String word) { return Character.toUpperCase(word.charAt(0)) + word.substring(1, word.length()).toLowerCase(); }
From source file:com.netspective.commons.text.TextUtils.java
/** * Given a text string that defines a SQL table name or column name or other SQL identifier, * return a string that would be suitable for that string to be used as a caption or plain text. */// w w w . j a v a 2 s . c om public String sqlIdentifierToText(String original, boolean uppercaseEachWord) { if (original == null || original.length() == 0) return original; StringBuffer text = new StringBuffer(); text.append(Character.toUpperCase(original.charAt(0))); boolean wordBreak = false; for (int i = 1; i < original.length(); i++) { char ch = original.charAt(i); if (ch == '_') { text.append(' '); wordBreak = true; } else if (wordBreak) { text.append(uppercaseEachWord ? Character.toUpperCase(ch) : Character.toLowerCase(ch)); wordBreak = false; } else text.append(Character.toLowerCase(ch)); } return text.toString(); }
From source file:mobisocial.musubi.identity.AphidIdentityProvider.java
private byte[] getAphidResultForIdentity(IBIdentity ident, String property) throws IdentityProviderException { Log.d(TAG, "Getting key for " + ident.principal_); // Populate tokens from identity providers (only Google and Facebook for now) try {/* w ww .j a va2 s . c o m*/ cacheGoogleTokens(); } catch (IdentityProviderException.Auth e) { // No need to continue if this is our identity and token fetch failed if (e.identity.equalsStable(ident)) { throw new IdentityProviderException.Auth(ident); } } catch (IdentityProviderException.NeedsRetry e) { if (e.identity.equalsStable(ident)) { throw new IdentityProviderException.NeedsRetry(ident); } } try { cacheCurrentFacebookToken(); } catch (IdentityProviderException e) { // No need to continue if this is our identity and token fetch failed if (e.identity.equalsStable(ident)) { throw new IdentityProviderException.Auth(ident); } } String aphidType = null; String aphidToken = null; // Get a service-specific token if it exists Pair<Authority, String> userProperties = new Pair<Authority, String>(ident.authority_, ident.principal_); if (mKnownTokens.containsKey(userProperties)) { aphidToken = mKnownTokens.get(userProperties); } // The IBE server has its own identifiers for providers switch (ident.authority_) { case Facebook: aphidType = "facebook"; break; case Email: if (mKnownTokens.containsKey(userProperties)) { aphidType = "google"; } break; case PhoneNumber: // Aphid doesn't return keys for a phone number without verification throw new IdentityProviderException.TwoPhase(ident); } // Do not ask the server for identities we don't know how to handle if (aphidType == null || aphidToken == null) { throw new IdentityProviderException(ident); } // Bundle arguments as JSON JSONObject jsonObj = new JSONObject(); try { jsonObj.put("type", aphidType); jsonObj.put("token", aphidToken); jsonObj.put("starttime", ident.temporalFrame_); } catch (JSONException e) { Log.e(TAG, e.toString()); } JSONArray userinfo = new JSONArray(); userinfo.put(jsonObj); // Contact the server try { JSONObject resultObj = getAphidResult(userinfo); if (resultObj == null) { throw new IdentityProviderException.NeedsRetry(ident); } String encodedKey = resultObj.getString(property); boolean hasError = resultObj.has("error"); if (!hasError) { long temporalFrame = resultObj.getLong("time"); if (encodedKey != null && temporalFrame == ident.temporalFrame_) { // Success! return Base64.decode(encodedKey, Base64.DEFAULT); } else { // Might have jumped the gun a little bit, so try again later throw new IdentityProviderException.NeedsRetry(ident); } } else { // Aphid authentication error means Musubi has a bad token String error = resultObj.getString("error"); if (error.contains("401")) { // Authentication errors require user action String accountType = Character.toString(Character.toUpperCase(aphidType.charAt(0))) + aphidType.substring(1); sendNotification(accountType); throw new IdentityProviderException.Auth(ident); } else { // Other failures should be retried silently throw new IdentityProviderException.NeedsRetry(ident); } } } catch (IOException e) { Log.e(TAG, e.toString()); } catch (JSONException e) { Log.e(TAG, e.toString()); } throw new IdentityProviderException.NeedsRetry(ident); }