List of usage examples for java.lang Character toUpperCase
public static int toUpperCase(int codePoint)
From source file:forge.game.card.Card.java
private String formatSpellAbility(final SpellAbility sa) { final StringBuilder sb = new StringBuilder(); final String elementText = sa.toString(); //Determine if a card has multiple choices, then format it in an easier to read list. if (ApiType.Charm.equals(sa.getApi())) { // Only split once! Otherwise some Charm spells looks broken final String[] splitElemText = elementText.split("-", 2); final String chooseText = splitElemText[0].trim(); final String[] choices = splitElemText.length > 1 ? splitElemText[1].split(";") : null; sb.append(chooseText);/*w ww . j a v a 2 s.co m*/ if (choices != null) { sb.append(" \u2014\r\n"); for (int i = 0; i < choices.length; i++) { String choice = choices[i].trim(); if (choice.startsWith("Or ") || choice.startsWith("or ")) { choice = choice.substring(3); } sb.append("\u2022 ").append(Character.toUpperCase(choice.charAt(0))) .append(choice.substring(1)); if (i < choices.length - 1) { sb.append("."); } sb.append("\r\n"); } } } else { sb.append(elementText).append("\r\n"); } return sb.toString(); }
From source file:edu.utah.further.core.api.text.StringUtil.java
/** * Converts a string to first character capitalized case. That is the first letter * capitalized and the rest lower case./*from w w w . j ava 2s. co m*/ * * * <code> * StringUtils.toLowercaseFirstCharUppercase("HELLO WORLD); //prints Hello world * </code> * * @param string * the String to convert to first char uppercase and rest lowercase * @return */ public static String toLowercaseFirstCharUppercase(final String string) { final String lower = string.toLowerCase(); return Character.toUpperCase(lower.charAt(0)) + lower.substring(1); }
From source file:edu.ku.brc.ui.UIHelper.java
/** * Takes a string and separates the 'names' inside by the capitial letters. * @param nameToFix the name to fix// w w w . j ava 2 s . c o m * @return the new name with spaces in it */ public static String makeNamePretty(final String nameToFix) { StringBuilder s = new StringBuilder(); for (int i = 0; i < nameToFix.length(); i++) { if (i == 0) { s.append(Character.toUpperCase(nameToFix.charAt(i))); } else { char c = nameToFix.charAt(i); if (Character.isUpperCase(c)) { s.append(' '); } s.append(c); } } return s.toString(); }
From source file:jp.terasoluna.fw.validation.FieldChecks.java
/** * ??????// w w w.j av a 2s.co m * * @param va ValidatorAction * @param paramClass ? * @return */ protected Method getMethod(ValidatorAction va, @SuppressWarnings("rawtypes") Class[] paramClass) { String methodNameSource = va.getName(); if (methodNameSource == null || "".equals(methodNameSource)) { // ???null???????null? return null; } // name?"Array"?????? // xxxxArrayvalidateXxxx char[] chars = methodNameSource.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); String validate = "validate" + new String(chars); String methodName = validate.substring(0, validate.length() - "Array".length()); Method method = null; try { method = FieldChecks.class.getMethod(methodName, paramClass); } catch (NoSuchMethodException e) { return null; } return method; }
From source file:me.ububble.speakall.fragment.ConversationGroupFragment.java
public void showMensajeContact(int position, final Context context, final MsgGroups message, View rowView, TextView icnMessageArrow) {//ww w . j a v a 2 s. c o m final TextView prevMessages = (TextView) rowView.findViewById(R.id.showprev_messages); TextView messageTime = (TextView) rowView.findViewById(R.id.message_time); final TextView icnMesajeCopy = (TextView) rowView.findViewById(R.id.icn_message_copy); final TextView icnMesajeBack = (TextView) rowView.findViewById(R.id.icn_message_back); TextView messageStatus = (TextView) rowView.findViewById(R.id.message_status); final LinearLayout messageMenu = (LinearLayout) rowView.findViewById(R.id.messages_menu_layout); final LinearLayout mensajeLayout = (LinearLayout) rowView.findViewById(R.id.mensaje_layout); TextView messageDate = (TextView) rowView.findViewById(R.id.message_date); TextView contactPhoto = (TextView) rowView.findViewById(R.id.contact_photo); final TextView contactName = (TextView) rowView.findViewById(R.id.contact_name); final TextView contactPhone = (TextView) rowView.findViewById(R.id.contact_phone); final CircleImageView imageUser = (CircleImageView) rowView.findViewById(R.id.chat_row_user_pic); final TextView userName = (TextView) rowView.findViewById(R.id.username_text); TFCache.apply(context, messageTime, TFCache.TF_WHITNEY_MEDIUM); TFCache.apply(context, icnMesajeCopy, TFCache.TF_SPEAKALL); TFCache.apply(context, icnMesajeBack, TFCache.TF_SPEAKALL); TFCache.apply(context, messageStatus, TFCache.TF_SPEAKALL); TFCache.apply(context, contactPhoto, TFCache.TF_SPEAKALL); TFCache.apply(context, prevMessages, TFCache.TF_WHITNEY_MEDIUM); TFCache.apply(context, messageDate, TFCache.TF_WHITNEY_MEDIUM); TFCache.apply(context, contactName, TFCache.TF_WHITNEY_MEDIUM); TFCache.apply(context, contactPhone, TFCache.TF_WHITNEY_MEDIUM); TFCache.apply(context, userName, TFCache.TF_WHITNEY_MEDIUM); try { JSONObject contactData = new JSONObject(message.mensaje); contactName.setText(contactData.getString("nombre")); contactPhone.setText(Html.fromHtml("<u>" + contactData.getString("telefono") + "</u>")); if (contactPhone.length() > 0) { contactPhone.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) activity).dontClose = true; hideKeyBoard(); Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + contactPhone.getText().toString())); context.startActivity(intent); } }); } } catch (JSONException e) { e.printStackTrace(); } if (position == 0) { if (mensajesTotal > mensajesOffset) { prevMessages.setVisibility(View.VISIBLE); prevMessages.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { prevMessages.setVisibility(View.GONE); if (mensajesTotal - mensajesOffset >= 10) { mensajesLimit = 10; mensajesOffset += mensajesLimit; showPreviousMessages(mensajesOffset); } else { mensajesLimit = mensajesTotal - mensajesOffset; mensajesOffset += mensajesLimit; showPreviousMessages(mensajesOffset); } } }); } } DateFormat dateDay = new SimpleDateFormat("d"); DateFormat dateDayText = new SimpleDateFormat("EEEE"); DateFormat dateMonth = new SimpleDateFormat("MMMM"); DateFormat dateYear = new SimpleDateFormat("yyyy"); DateFormat timeFormat = new SimpleDateFormat("h:mm a"); Calendar fechamsj = Calendar.getInstance(); fechamsj.setTimeInMillis(message.emitedAt); String time = timeFormat.format(fechamsj.getTime()); String dayMessage = dateDay.format(fechamsj.getTime()); String monthMessage = dateMonth.format(fechamsj.getTime()); String yearMessage = dateYear.format(fechamsj.getTime()); String dayMessageText = dateDayText.format(fechamsj.getTime()); char[] caracteres = dayMessageText.toCharArray(); caracteres[0] = Character.toUpperCase(caracteres[0]); dayMessageText = new String(caracteres); Calendar fechaActual = Calendar.getInstance(); String dayActual = dateDay.format(fechaActual.getTime()); String monthActual = dateMonth.format(fechaActual.getTime()); String yearActual = dateYear.format(fechaActual.getTime()); String fechaMostrar = ""; if (dayMessage.equals(dayActual) && monthMessage.equals(monthActual) && yearMessage.equals(yearActual)) { fechaMostrar = getString(R.string.messages_today); } else if (monthMessage.equals(monthActual) && yearMessage.equals(yearActual)) { int days = Integer.parseInt(dayActual) - Integer.parseInt(dayMessage); if (days < 7) { switch (days) { case 1: fechaMostrar = getString(R.string.messages_yesterday); break; default: fechaMostrar = dayMessageText; break; } } else { fechaMostrar = (dayMessage + " " + monthMessage + " " + yearMessage).toUpperCase(); } } else { fechaMostrar = (dayMessage + " " + monthMessage + " " + yearMessage).toUpperCase(); } messageDate.setText(fechaMostrar); if (position != -1) { if (itemAnterior != null) { if (!fechaMostrar.equals(fechaAnterior)) { itemAnterior.findViewById(R.id.message_date).setVisibility(View.VISIBLE); } else { itemAnterior.findViewById(R.id.message_date).setVisibility(View.GONE); } } itemAnterior = rowView; fechaAnterior = fechaMostrar; } else { View v = messagesList.getChildAt(messagesList.getChildCount() - 1); if (v != null) { TextView tv = (TextView) v.findViewById(R.id.message_date); if (tv.getText().toString().equals(fechaMostrar)) { messageDate.setVisibility(View.GONE); } else { messageDate.setVisibility(View.VISIBLE); } } } messageTime.setText(time); if (message.emisor.equals(u.id)) { int status = 0; try { JSONArray contactos = new JSONArray(message.receptores); for (int i = 0; i < contactos.length(); i++) { JSONObject contacto = contactos.getJSONObject(i); if (status == 0 || contacto.getInt("status") <= status) { status = contacto.getInt("status"); } } } catch (JSONException e) { e.printStackTrace(); } if (status != -1) { rowView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (messageSelected != null) { View vista = messagesList.findViewWithTag(messageSelected); vista.findViewById(messageMenu.getId()).setVisibility(View.INVISIBLE); messageSelected = message.mensajeId; ((MainActivity) activity).setOnBackPressedListener(new BackPressedListener(activity) { @Override public void doBack() { View vista = messagesList.findViewWithTag(messageSelected); vista.findViewById(messageMenu.getId()).setVisibility(View.INVISIBLE); ((MainActivity) activity).setOnBackPressedListener(null); messageSelected = null; } }); } else { messageSelected = message.mensajeId; ((MainActivity) activity).setOnBackPressedListener(new BackPressedListener(activity) { @Override public void doBack() { if (messageSelected != null) { View vista = messagesList.findViewWithTag(messageSelected); vista.findViewById(messageMenu.getId()).setVisibility(View.INVISIBLE); ((MainActivity) activity).setOnBackPressedListener(null); messageSelected = null; } } }); } Vibrator x = (Vibrator) activity.getApplicationContext() .getSystemService(Context.VIBRATOR_SERVICE); x.vibrate(30); MsgGroups mensaje = new Select().from(MsgGroups.class) .where("mensajeId = ?", message.mensajeId).executeSingle(); int status = 0; try { JSONArray contactos = new JSONArray(message.receptores); for (int i = 0; i < contactos.length(); i++) { JSONObject contacto = contactos.getJSONObject(i); if (status == 0 || contacto.getInt("status") <= status) { status = contacto.getInt("status"); } } } catch (JSONException e) { e.printStackTrace(); } if (status != 4) { icnMesajeCopy.setVisibility(View.VISIBLE); icnMesajeBack.setVisibility(View.VISIBLE); messageMenu.setVisibility(View.VISIBLE); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(icnMesajeCopy, "alpha", 0, 1), ObjectAnimator.ofFloat(icnMesajeBack, "alpha", 0, 1), ObjectAnimator.ofFloat(messageMenu, "alpha", 0, 1), ObjectAnimator.ofFloat(icnMesajeCopy, "translationX", 100, 0), ObjectAnimator.ofFloat(icnMesajeBack, "translationX", 50, 0)); set.setDuration(200).start(); } else { icnMesajeCopy.setVisibility(View.VISIBLE); icnMesajeBack.setVisibility(View.VISIBLE); messageMenu.setVisibility(View.VISIBLE); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(icnMesajeCopy, "alpha", 0, 1), ObjectAnimator.ofFloat(icnMesajeBack, "alpha", 0, 1), ObjectAnimator.ofFloat(messageMenu, "alpha", 0, 1), ObjectAnimator.ofFloat(icnMesajeCopy, "translationX", 100, 0), ObjectAnimator.ofFloat(icnMesajeBack, "translationX", 50, 0)); set.setDuration(200).start(); } return false; } }); } if (status == 1) { messageStatus.setTextSize(16); mensajeLayout.setBackgroundResource(R.drawable.message_out_background); icnMessageArrow.setTextColor(getResources().getColor(R.color.speak_all_red)); messageStatus.setTextColor(getResources().getColor(R.color.speak_all_ligh_gray)); messageStatus.setText(Finder.STRING.ICN_MSJ_SENDING.toString()); ValueAnimator colorAnim = ObjectAnimator.ofFloat(messageStatus, "alpha", 1, 0); colorAnim.setRepeatCount(ValueAnimator.INFINITE); colorAnim.setRepeatMode(ValueAnimator.REVERSE); colorAnim.setDuration(1000).start(); animaciones.put(message.mensajeId, colorAnim); JSONObject data = new JSONObject(); try { data.put("type", message.tipo); data.put("group_id", message.grupoId); data.put("group_name", grupo.nombreGrupo); data.put("source", message.emisor); data.put("source_email", message.emisorEmail); data.put("message", message.mensaje); data.put("source_lang", message.emisorLang); data.put("translation_required", message.translation); data.put("message_id", message.mensajeId); data.put("delay", message.delay); JSONArray targets = new JSONArray(); JSONArray contactos = new JSONArray(grupo.targets); if (SpeakSocket.mSocket != null) { if (SpeakSocket.mSocket.connected()) { for (int i = 0; i < contactos.length(); i++) { JSONObject contacto = contactos.getJSONObject(i); JSONObject newContact = new JSONObject(); Contact contact = new Select().from(Contact.class) .where("id_contact = ?", contacto.getString("name")).executeSingle(); if (contact != null) { if (!contact.idContacto.equals(u.id)) { if (message.translation) newContact.put("lang", contact.lang); else newContact.put("lang", u.lang); newContact.put("name", contact.idContacto); newContact.put("screen_name", contact.screenName); newContact.put("status", 1); targets.put(targets.length(), newContact); } } } data.put("targets", targets); message.receptores = targets.toString(); message.save(); SpeakSocket.mSocket.emit("message", data); } else { for (int i = 0; i < contactos.length(); i++) { JSONObject contacto = contactos.getJSONObject(i); JSONObject newContact = new JSONObject(); Contact contact = new Select().from(Contact.class) .where("id_contact = ?", contacto.getString("name")).executeSingle(); if (contact != null) { if (!contact.idContacto.equals(u.id)) { if (message.translation) newContact.put("lang", contact.lang); else newContact.put("lang", u.lang); newContact.put("name", contact.idContacto); newContact.put("screen_name", contact.screenName); newContact.put("status", -1); targets.put(targets.length(), newContact); } } } message.receptores = targets.toString(); message.save(); } changeStatus(message.mensajeId); } } catch (JSONException e) { e.printStackTrace(); } } if (status == -1) { messageStatus.setTextSize(11); mensajeLayout.setBackgroundResource(R.drawable.message_errorout_background); icnMessageArrow.setTextColor(getResources().getColor(R.color.speak_all_disable_red)); messageStatus.setText(Finder.STRING.ICN_MSJ_ERROR.toString()); } if (status == 2) { messageStatus.setTextSize(16); mensajeLayout.setBackgroundResource(R.drawable.message_out_background); icnMessageArrow.setTextColor(getResources().getColor(R.color.speak_all_red)); messageStatus.setText(Finder.STRING.ICN_MSJ_SEND.toString()); } if (status == 3) { messageStatus.setTextSize(11); mensajeLayout.setBackgroundResource(R.drawable.message_out_background); icnMessageArrow.setTextColor(getResources().getColor(R.color.speak_all_red)); messageStatus.setText(Finder.STRING.ICN_MSJ_CLOSED.toString()); } if (status == 4) { messageStatus.setTextSize(11); mensajeLayout.setBackgroundResource(R.drawable.message_out_background); icnMessageArrow.setTextColor(getResources().getColor(R.color.speak_all_red)); messageStatus.setText(Finder.STRING.ICN_MSJ_OPENED.toString()); } } else { final Contact contacto = new Select().from(Contact.class).where(" id_contact= ?", message.emisor) .executeSingle(); if (contacto != null) { new Thread(new Runnable() { @Override public void run() { activity.runOnUiThread(new Runnable() { @Override public void run() { if (contacto.photo != null) { Bitmap bmp = BitmapFactory.decodeByteArray(contacto.photo, 0, contacto.photo.length); imageUser.setImageBitmap(bmp); userName.setText(contacto.fullName); } } }); } }).start(); } rowView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (messageSelected != null) { longclick = true; View vista = messagesList.findViewWithTag(messageSelected); vista.findViewById(messageMenu.getId()).setVisibility(View.INVISIBLE); messageSelected = message.mensajeId; ((MainActivity) activity).setOnBackPressedListener(new BackPressedListener(activity) { @Override public void doBack() { View vista = messagesList.findViewWithTag(messageSelected); vista.findViewById(messageMenu.getId()).setVisibility(View.INVISIBLE); ((MainActivity) activity).setOnBackPressedListener(null); messageSelected = null; } }); } else { messageSelected = message.mensajeId; ((MainActivity) activity).setOnBackPressedListener(new BackPressedListener(activity) { @Override public void doBack() { View vista = messagesList.findViewWithTag(messageSelected); vista.findViewById(messageMenu.getId()).setVisibility(View.INVISIBLE); ((MainActivity) activity).setOnBackPressedListener(null); messageSelected = null; } }); } Vibrator x = (Vibrator) activity.getApplicationContext() .getSystemService(Context.VIBRATOR_SERVICE); x.vibrate(20); icnMesajeCopy.setVisibility(View.VISIBLE); icnMesajeBack.setVisibility(View.VISIBLE); messageMenu.setVisibility(View.VISIBLE); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(icnMesajeCopy, "alpha", 0, 1), ObjectAnimator.ofFloat(icnMesajeBack, "alpha", 0, 1), ObjectAnimator.ofFloat(messageMenu, "alpha", 0, 1), ObjectAnimator.ofFloat(icnMesajeCopy, "translationX", -100, 0), ObjectAnimator.ofFloat(icnMesajeBack, "translationX", -150, 0)); set.setDuration(200).start(); return false; } }); } icnMesajeBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (message.emisor.equals(u.id)) { getFragmentManager().beginTransaction() .replace(R.id.container3, ForwarForFragment.newInstance(message.mensaje)) .addToBackStack(null).commit(); ((MainActivity) activity).setOnBackPressedListener(null); } else { getFragmentManager().beginTransaction() .replace(R.id.container3, ForwarForFragment.newInstance(message.mensajeTrad)) .addToBackStack(null).commit(); ((MainActivity) activity).setOnBackPressedListener(null); } } }); rowView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (messageSelected != null) { View vista = messagesList.findViewWithTag(messageSelected); if (!messageSelected.equals(message.mensajeId)) { longclick = true; vista.findViewById(messageMenu.getId()).setVisibility(View.INVISIBLE); ((MainActivity) activity).setOnBackPressedListener(null); messageSelected = null; } } MsgGroups mensaje = new Select().from(MsgGroups.class).where("mensajeId = ?", message.mensajeId) .executeSingle(); int status = 0; try { JSONArray contactos = new JSONArray(mensaje.receptores); for (int i = 0; i < contactos.length(); i++) { JSONObject contacto = contactos.getJSONObject(i); if (status == 0 || contacto.getInt("status") <= status) { status = contacto.getInt("status"); } } } catch (JSONException e) { e.printStackTrace(); } if (status == -1) { JSONObject data = new JSONObject(); try { data.put("type", mensaje.tipo); data.put("group_id", mensaje.grupoId); data.put("group_name", grupo.nombreGrupo); data.put("source", mensaje.emisor); data.put("source_email", mensaje.emisorEmail); data.put("source_lang", mensaje.emisorLang); data.put("message", mensaje.mensaje); data.put("translation_required", mensaje.translation); data.put("message_id", mensaje.mensajeId); data.put("delay", mensaje.delay); JSONArray targets = new JSONArray(); JSONArray contactos = new JSONArray(grupo.targets); if (SpeakSocket.mSocket != null) { if (SpeakSocket.mSocket.connected()) { for (int i = 0; i < contactos.length(); i++) { JSONObject contacto = contactos.getJSONObject(i); JSONObject newContact = new JSONObject(); Contact contact = new Select().from(Contact.class) .where("id_contact = ?", contacto.getString("name")).executeSingle(); if (contact != null) { if (!contact.idContacto.equals(u.id)) { if (mensaje.translation) newContact.put("lang", contact.lang); else newContact.put("lang", u.lang); newContact.put("name", contact.idContacto); newContact.put("screen_name", contact.screenName); newContact.put("status", 1); targets.put(targets.length(), newContact); } } } data.put("targets", targets); mensaje.receptores = targets.toString(); mensaje.save(); SpeakSocket.mSocket.emit("message", data); } else { for (int i = 0; i < contactos.length(); i++) { JSONObject contacto = contactos.getJSONObject(i); JSONObject newContact = new JSONObject(); Contact contact = new Select().from(Contact.class) .where("id_contact = ?", contacto.getString("name")).executeSingle(); if (contact != null) { if (!contact.idContacto.equals(u.id)) { if (mensaje.translation) newContact.put("lang", contact.lang); else newContact.put("lang", u.lang); newContact.put("name", contact.idContacto); newContact.put("screen_name", contact.screenName); newContact.put("status", -1); targets.put(targets.length(), newContact); } } } mensaje.receptores = targets.toString(); mensaje.save(); } changeStatus(mensaje.mensajeId); } } catch (JSONException e) { e.printStackTrace(); } if (!mensaje.emisor.equals(u.id)) { if (!longclick) { showDialogAddContact(mensaje.mensaje); } longclick = false; } } } }); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclarationTest.java
private static boolean isDefaultGetter(final List<String> lines, final PropertyInfo info) { for (int i = 0; i < lines.size(); i++) { final String line = lines.get(i); final String nextLine = i + 1 < lines.size() ? lines.get(i + 1) : null; if (line.startsWith(" public ") && line.contains(" " + info.getReadMethod().getName() + "(") && nextLine != null && nextLine.contains(" return getStyleAttribute(") && lines.get(i + 2).equals(" }")) { final String styleName = nextLine.substring(nextLine.indexOf('(' + 1), nextLine.indexOf(')')); try { final String attributeName = Definition.valueOf(styleName).getAttributeName(); final String methodName = "get" + Character.toUpperCase(attributeName.charAt(0)) + attributeName.substring(1); if (info.getReadMethod().getName().equals(methodName)) { return true; }/*w w w. j a va 2 s. com*/ } catch (final Exception e) { // ignore } } } return false; }
From source file:de.innovationgate.utils.WGUtils.java
/** * Removes all characters from a string that are not legal as JavaScript identifier * Interprets an underscore as the next character being forced to upper case. * The upper case rules, that are enforced when param enforceUpperCaseRules is true are: * <ul>// w w w .ja v a 2 s . c o m * <li>Non-alphabetic characters at the beginning are stripped off * <li>The first alphabetic character is uppercase * <li>An alphabetic character preceded by an underscore (which is removed) will also be uppercase * <li>All other alphabetic characters are lowercase * </ul> * @param txt The string * @param enforceUpperCaseRules If true enforces the upper case rules described above, meant to transfor, a lowercase design reference to an Object Identifier with cases in an reversible way. * In that case the created string can be reverted to the original by using {@link #fromJSIdentifier(String)}. * @return The string converted to a valid JS identifier */ public static String toJSIdentifier(String txt, boolean enforceUpperCaseRules) { StringBuilder out = new StringBuilder(); // Flags for enforceUpperCaseRules boolean upperCase = true; // First character is uppercase boolean startCharacter = true; for (int i = 0; i < txt.length(); i++) { Character c = txt.charAt(i); if (enforceUpperCaseRules) { // Must start with a letter if (startCharacter && !Character.isLetter(c)) { continue; } // Convert letters to uppercase, depending on flag if (Character.isLetter(c)) { if (upperCase) { c = Character.toUpperCase(c); upperCase = false; } else { c = Character.toLowerCase(c); } } // Trigger the next letter to be uppercase else if (c == '_') { upperCase = true; continue; } } Pattern p = (startCharacter ? JS_IDENTIFIER_FIRSTCHARS : JS_IDENTIFIER_CHARS); if (p.matcher(c.toString()).matches()) { out.append(c); startCharacter = false; } else if (enforceUpperCaseRules) { throw new IllegalArgumentException( "This string cannot be transformed to a reversible JS identifier because it contains invalid characters: " + txt); } } return out.toString(); }
From source file:me.ububble.speakall.fragment.ConversationChatFragment.java
public void contactLastSeen(JSONObject json) { try {// www . ja v a 2 s . c o m boolean isOnline = json.getBoolean("connected"); Log.e("Respuesta lastseen", json.toString()); if (isOnline) { activity.runOnUiThread(new Runnable() { @Override public void run() { if (ConversationChatFragment.this.isVisible()) { ((MainActivity) activity).actionBarDesc.setVisibility(View.VISIBLE); ((MainActivity) activity).actionBarDesc.setText(getString(R.string.online_status)); } } }); } else { String lastSeen = json.getString("last_seen"); SimpleDateFormat formateador1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'", Locale.getDefault()); formateador1.setTimeZone(TimeZone.getTimeZone("UTC")); String tiempo = lastSeen.substring(0, 23) + "Z"; Calendar fecha = Calendar.getInstance(); Date fecha1 = formateador1.parse(tiempo); fecha.setTimeZone(TimeZone.getDefault()); fecha.setTimeInMillis(fecha1.getTime()); String time = timeFormat1.format(fecha.getTime()); String dayMessage = dateDay1.format(fecha.getTime()); String monthMessage = dateMonth1.format(fecha.getTime()); String yearMessage = dateYear1.format(fecha.getTime()); String dayMessageText = dateDayText1.format(fecha.getTime()); char[] caracteres = dayMessageText.toCharArray(); caracteres[0] = Character.toUpperCase(caracteres[0]); dayMessageText = new String(caracteres); Calendar fechaActual = Calendar.getInstance(); String dayActual = dateDay1.format(fechaActual.getTime()); String monthActual = dateMonth1.format(fechaActual.getTime()); String yearActual = dateYear1.format(fechaActual.getTime()); String fechaMostrar = ""; if (dayMessage.equals(dayActual) && monthMessage.equals(monthActual) && yearMessage.equals(yearActual)) { fechaMostrar = getString(R.string.messages_today); } else if (monthMessage.equals(monthActual) && yearMessage.equals(yearActual)) { int days = Integer.parseInt(dayActual) - Integer.parseInt(dayMessage); if (days < 7) { switch (days) { case 1: fechaMostrar = getString(R.string.messages_yesterday); break; default: fechaMostrar = dayMessageText; break; } } else { fechaMostrar = (dayMessage + " " + monthMessage + " " + yearMessage).toUpperCase(); } } else { fechaMostrar = (dayMessage + " " + monthMessage + " " + yearMessage).toUpperCase(); } final String finalFechaMostrar = fechaMostrar + " (" + time + ")"; activity.runOnUiThread(new Runnable() { @Override public void run() { ((MainActivity) activity).actionBarDesc.setVisibility(View.VISIBLE); ((MainActivity) activity).actionBarDesc.setText(finalFechaMostrar); } }); } } catch (JSONException e) { } catch (ParseException e) { e.printStackTrace(); } }
From source file:self.philbrown.javaQuery.$.java
/** * Capitalizes the first letter of the given string. * @param string the string whose first letter should be capitalized * @return the given string with its first letter capitalized * @throws NullPointerException if the string is null or empty *//*from w w w .j av a 2s .c o m*/ public static String capitalize(String string) { if (string == null || string.trim().length() == 0) throw new NullPointerException("Cannot handle null or empty string"); StringBuilder strBuilder = new StringBuilder(string); strBuilder.setCharAt(0, Character.toUpperCase(strBuilder.charAt(0))); return strBuilder.toString(); }
From source file:me.ububble.speakall.fragment.ConversationGroupFragment.java
public void showMensajeMember(int position, Context context, final MsgGroups message, View rowView) { final TextView prevMessages = (TextView) rowView.findViewById(R.id.showprev_messages); TextView messageDate = (TextView) rowView.findViewById(R.id.message_date); TextView messageMember = (TextView) rowView.findViewById(R.id.message_member); TFCache.apply(context, prevMessages, TFCache.TF_WHITNEY_MEDIUM); TFCache.apply(context, messageDate, TFCache.TF_WHITNEY_MEDIUM); TFCache.apply(context, messageMember, TFCache.TF_WHITNEY_MEDIUM); if (position == 0) { if (mensajesTotal > mensajesOffset) { prevMessages.setVisibility(View.VISIBLE); prevMessages.setOnClickListener(new View.OnClickListener() { @Override//from w ww .ja v a2 s. c o m public void onClick(View v) { prevMessages.setVisibility(View.GONE); if (mensajesTotal - mensajesOffset >= 10) { mensajesLimit = 10; mensajesOffset += mensajesLimit; showPreviousMessages(mensajesOffset); } else { mensajesLimit = mensajesTotal - mensajesOffset; mensajesOffset += mensajesLimit; showPreviousMessages(mensajesOffset); } } }); } } DateFormat dateDay = new SimpleDateFormat("d"); DateFormat dateDayText = new SimpleDateFormat("EEEE"); DateFormat dateMonth = new SimpleDateFormat("MMMM"); DateFormat dateYear = new SimpleDateFormat("yyyy"); DateFormat timeFormat = new SimpleDateFormat("h:mm a"); Calendar fechamsj = Calendar.getInstance(); fechamsj.setTimeInMillis(message.emitedAt); String time = timeFormat.format(fechamsj.getTime()); String dayMessage = dateDay.format(fechamsj.getTime()); String monthMessage = dateMonth.format(fechamsj.getTime()); String yearMessage = dateYear.format(fechamsj.getTime()); String dayMessageText = dateDayText.format(fechamsj.getTime()); char[] caracteres = dayMessageText.toCharArray(); caracteres[0] = Character.toUpperCase(caracteres[0]); dayMessageText = new String(caracteres); Calendar fechaActual = Calendar.getInstance(); String dayActual = dateDay.format(fechaActual.getTime()); String monthActual = dateMonth.format(fechaActual.getTime()); String yearActual = dateYear.format(fechaActual.getTime()); String fechaMostrar = ""; if (dayMessage.equals(dayActual) && monthMessage.equals(monthActual) && yearMessage.equals(yearActual)) { fechaMostrar = getString(R.string.messages_today); } else if (monthMessage.equals(monthActual) && yearMessage.equals(yearActual)) { int days = Integer.parseInt(dayActual) - Integer.parseInt(dayMessage); if (days < 7) { switch (days) { case 1: fechaMostrar = getString(R.string.messages_yesterday); break; default: fechaMostrar = dayMessageText; break; } } else { fechaMostrar = (dayMessage + " " + monthMessage + " " + yearMessage).toUpperCase(); } } else { fechaMostrar = (dayMessage + " " + monthMessage + " " + yearMessage).toUpperCase(); } messageDate.setText(fechaMostrar); if (position != -1) { if (itemAnterior != null) { if (!fechaMostrar.equals(fechaAnterior)) { itemAnterior.findViewById(R.id.message_date).setVisibility(View.VISIBLE); } else { itemAnterior.findViewById(R.id.message_date).setVisibility(View.GONE); } } itemAnterior = rowView; fechaAnterior = fechaMostrar; } else { View v = messagesList.getChildAt(messagesList.getChildCount() - 1); if (v != null) { TextView tv = (TextView) v.findViewById(R.id.message_date); if (tv.getText().toString().equals(fechaMostrar)) { messageDate.setVisibility(View.GONE); } else { messageDate.setVisibility(View.VISIBLE); } } } messageMember.setText(message.mensaje); }