List of usage examples for java.lang Character toUpperCase
public static int toUpperCase(int codePoint)
From source file:it.d4nguard.rgrpg.util.StringCompiler.java
/** * Checks the contents of this builder against another to see if they * contain the same character content ignoring case. * //from ww w. jav a 2 s .com * @param other * the object to check, null returns false * @return true if the builders contain the same characters in the same * order */ public boolean equalsIgnoreCase(StringCompiler other) { if (this == other) { return true; } if (this.size != other.size) { return false; } char thisBuf[] = this.buffer; char otherBuf[] = other.buffer; for (int i = size - 1; i >= 0; i--) { char c1 = thisBuf[i]; char c2 = otherBuf[i]; if (c1 != c2 && Character.toUpperCase(c1) != Character.toUpperCase(c2)) { return false; } } return true; }
From source file:net.sf.jabref.gui.JabRefFrame.java
public static JMenu subMenu(String name) { int i = name.indexOf('&'); JMenu res;// www . j av a 2 s. c o m if (i >= 0) { res = new JMenu(name.substring(0, i) + name.substring(i + 1)); char mnemonic = Character.toUpperCase(name.charAt(i + 1)); res.setMnemonic((int) mnemonic); } else { res = new JMenu(name); } return res; }
From source file:com.evolveum.icf.dummy.connector.DummyConnector.java
private String varyLetterCase(String name) { StringBuilder sb = new StringBuilder(name.length()); for (char c : name.toCharArray()) { double a = Math.random(); if (a < 0.4) { c = Character.toLowerCase(c); } else if (a > 0.7) { c = Character.toUpperCase(c); }// ww w. j a v a 2 s. c o m sb.append(c); } return sb.toString(); }
From source file:de.uni_koblenz.jgralab.utilities.rsa2tg.Rsa2Tg.java
/** * Handles a 'uml:Association' or a 'uml:AssociationClass' element by * creating a corresponding {@link EdgeClass} element. * /*from w ww.ja v a2s .c o m*/ * @param xmiId * XMI ID in XMI file. * @return Created EdgeClass as {@link Vertex}. * @throws XMLStreamException */ private Vertex handleAssociation(String xmiId) throws XMLStreamException { // create an EdgeClass at first, probably, this has to // become an Aggregation or Composition later... AttributedElement<?, ?> ae = idMap.get(xmiId); EdgeClass ec = null; if (ae != null) { if (!(ae instanceof EdgeClass)) { throw new ProcessingException(getParser(), getFilename(), "The XMI id " + xmiId + " must denonte an EdgeClass, but is " + ae.getAttributedElementClass().getQualifiedName()); } assert preliminaryVertices.contains(ae); preliminaryVertices.remove(ae); ec = (EdgeClass) ae; } else { ec = sg.createEdgeClass(); } currentClassId = xmiId; currentClass = ec; String abs = getAttribute(UML_ATTRIBUTE_IS_ABSRACT); ec.set_abstract((abs != null) && abs.equals(UML_TRUE)); String n = getAttribute(UML_ATTRIBUTE_NAME); n = n == null ? "" : n.trim(); if (n.length() > 0) { n = Character.toUpperCase(n.charAt(0)) + n.substring(1); } ec.set_qualifiedName(getQualifiedName(n)); sg.createContainsGraphElementClass(packageStack.peek(), ec); String memberEnd = getAttribute(UML_MEMBER_END); // An association have to have a end member. if (memberEnd == null) { throw new ProcessingException(getParser(), getFilename(), "The association with ID '" + xmiId + "' has no end member. (EdgeClass)"); } memberEnd = memberEnd.trim().replaceAll("\\s+", " "); int p = memberEnd.indexOf(' '); String targetEnd = memberEnd.substring(0, p); String sourceEnd = memberEnd.substring(p + 1); IncidenceClass inc = (IncidenceClass) idMap.get(sourceEnd); if (inc == null) { VertexClass vc = sg.createVertexClass(); preliminaryVertices.add(vc); vc.set_qualifiedName("preliminary for source end " + sourceEnd); inc = sg.createIncidenceClass(); inc.set_aggregation(AggregationKind.NONE); inc.set_min(DEFAULT_MIN_MULTIPLICITY); inc.set_max(DEFAULT_MAX_MULTIPLICITY); sg.createComesFrom(ec, inc); sg.createEndsAt(inc, vc); idMap.put(sourceEnd, inc); } inc = (IncidenceClass) idMap.get(targetEnd); if (inc != null) { assert inc.isValid(); assert getDirection(inc) == EdgeDirection.OUT; IncidenceClass to = sg.createIncidenceClass(); IncidenceClass from = inc; sg.createGoesTo(ec, to); sg.createEndsAt(to, (VertexClass) from.getFirstEndsAtIncidence().getThat()); to.set_aggregation(from.get_aggregation()); to.set_max(from.get_max()); to.set_min(from.get_min()); to.set_roleName(from.get_roleName()); if (ownedEnds.contains(from)) { ownedEnds.remove(from); ownedEnds.add(to); } inc.delete(); idMap.put(targetEnd, to); } else { VertexClass vc = sg.createVertexClass(); preliminaryVertices.add(vc); vc.set_qualifiedName("preliminary for target end " + targetEnd); inc = sg.createIncidenceClass(); inc.set_aggregation(AggregationKind.NONE); inc.set_min(DEFAULT_MIN_MULTIPLICITY); inc.set_max(DEFAULT_MAX_MULTIPLICITY); sg.createGoesTo(ec, inc); sg.createEndsAt(inc, vc); idMap.put(targetEnd, inc); } String isDerived = getAttribute(UML_ATTRIBUTE_ISDERIVED); boolean derived = (isDerived != null) && isDerived.equals(UML_TRUE); if (derived) { derivedGraphElementClasses.add(ec); } return ec; }
From source file:com.strathclyde.highlightingkeyboard.SoftKeyboardService.java
/** * Handle the input of any normal character * @param primaryCode the button key code * @param keyCodes the characters associated with the button key code *//*from w w w . j a va 2s . c o m*/ private void handleCharacter(int primaryCode, int[] keyCodes) { if (isInputViewShown()) { if (mInputView.isShifted()) { primaryCode = Character.toUpperCase(primaryCode); //Log.i("Handle Character", "it is "+(char)primaryCode); } } if (isAlphabet(primaryCode) && mPredictionOn) { if (coreEngine != null) coreEngine.addChar((char) primaryCode, false, false, false); mComposing.append((char) primaryCode); ic.setComposingText(mComposing, 1); updateShiftKeyState(getCurrentInputEditorInfo()); updateCandidates(); } else { //Log.i("handleCharacter", "adding "+(char) primaryCode+" to mComposing"); mComposing.append((char) primaryCode); ic.setComposingText(mComposing, 1); } }
From source file:me.ububble.speakall.fragment.ConversationGroupFragment.java
public void showMensajeText(int position, Context context, final MsgGroups message, View rowView, TextView icnMessageArrow) {//from ww w . j a v a2s. c om 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); final TextView messageContent = (TextView) rowView.findViewById(R.id.message_content); 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); 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, messageContent, 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, prevMessages, TFCache.TF_WHITNEY_MEDIUM); TFCache.apply(context, messageDate, TFCache.TF_WHITNEY_MEDIUM); TFCache.apply(context, userName, TFCache.TF_WHITNEY_MEDIUM); 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)) { messageContent.setText(message.mensaje); int status = 0; try { JSONArray contactos = new JSONArray(message.receptores); for (int i = 0; i < contactos.length(); i++) { JSONObject contacto = contactos.getJSONObject(i); Log.w("STATUS", contacto.getInt("status") + contacto.getString("name")); 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() { 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(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 != 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_lang", message.emisorLang); data.put("source_email", message.emisorEmail); data.put("message", message.mensaje); 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(); } messageContent.setText(message.mensajeTrad); 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() { 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; } }); } if (message.orientation == 0) { messageContent.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (messageContent.getLineCount() > 1) { mensajeLayout.setOrientation(LinearLayout.VERTICAL); messageContent.setPadding(0, messageContent.getPaddingTop(), 0, 0); new Update(Message.class).set("orientation = ?", 2) .where("mensajeId = ?", message.mensajeId).execute(); messageContent.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { new Update(Message.class).set("orientation = ?", 1) .where("mensajeId = ?", message.mensajeId).execute(); messageContent.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } }); } else { if (message.orientation == 2) { mensajeLayout.setOrientation(LinearLayout.VERTICAL); messageContent.setPadding(0, messageContent.getPaddingTop(), 0, 0); } } icnMesajeCopy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ClipData clip = ClipData.newPlainText("text", messageContent.getText().toString()); ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(clip); Toast.makeText(activity, "Copiado", Toast.LENGTH_SHORT).show(); } }); 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)) { 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_lang", mensaje.emisorLang); data.put("message", mensaje.mensaje); data.put("translation_required", mensaje.translation); data.put("message_id", mensaje.mensajeId); data.put("source_email", message.emisorEmail); data.put("targets", new JSONArray(mensaje.receptores)); 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(); } } } }); }
From source file:jp.terasoluna.fw.web.struts.form.FieldChecksEx.java
/** * z?ERNVvf??\bh?B/* w w w . ja va 2 s.co m*/ * * <b>?\bhANVtH?[? tH?[O?Ap?s???B</b> * * @param va * Strutsp<code>ValidatorAction</code> * @param paramClass * ?NXz * @return ??\bhIuWFNg */ protected static Method getMethod(ValidatorAction va, Class[] paramClass) { String methodNameSource = va.getName(); if (methodNameSource == null || "".equals(methodNameSource)) { // ?\bhwnullnullp?B return null; } // name?"Array"??\bh?? // xxxxArray?validateXxxx 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 = FieldChecksEx.class.getMethod(methodName, paramClass); } catch (NoSuchMethodException e) { try { method = ValidWhen.class.getMethod(methodName, paramClass); } catch (NoSuchMethodException e1) { log.error("", e); log.error("", e1); return null; } } return method; }
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryFieldPanel.java
/** * Split apart the name keying on upper case * @param nameToFix the name of the field * @return the split apart name/* w w w.j ava 2 s . c o m*/ */ protected String fixName(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:com.jaredrummler.android.device.DeviceName.java
/** * <p>Capitalizes getAllProcesses the whitespace separated words in a String. Only the first * letter of each word is changed.</p> * * Whitespace is defined by {@link Character#isWhitespace(char)}. * * @param str//from w w w. j a va2s .c o m * the String to capitalize * @return capitalized The capitalized String */ private static String capitalize(String str) { if (TextUtils.isEmpty(str)) { return str; } char[] arr = str.toCharArray(); boolean capitalizeNext = true; String phrase = ""; for (char c : arr) { if (capitalizeNext && Character.isLetter(c)) { phrase += Character.toUpperCase(c); capitalizeNext = false; continue; } else if (Character.isWhitespace(c)) { capitalizeNext = true; } phrase += c; } return phrase; }
From source file:de.uni_koblenz.jgralab.utilities.rsa2tg.Rsa2Tg.java
/** * Creates {@link EdgeClass} names for all EdgeClass objects, which do have * an empty String or a String, which ends with a '.'. *//*w ww .j ava2 s . com*/ private void createEdgeClassNames() { System.out.println("Creating missing edge class names..."); for (EdgeClass ec : sg.getEdgeClassVertices()) { String name = ec.get_qualifiedName().trim(); // invent an edgeclass name String ecName = null; Matcher m = GENNAME_PATTERN.matcher(name); if (m.matches()) { name = m.group(1); ecName = m.group(m.groupCount()); } if (!name.equals("") && !name.endsWith(".")) { continue; } IncidenceClass to = (IncidenceClass) ec.getFirstGoesToIncidence().getThat(); IncidenceClass from = (IncidenceClass) ec.getFirstComesFromIncidence().getThat(); String toRole = to.get_roleName(); if ((toRole == null) || toRole.equals("")) { toRole = ((VertexClass) to.getFirstEndsAtIncidence().getThat()).get_qualifiedName(); int p = toRole.lastIndexOf('.'); if (p >= 0) { toRole = toRole.substring(p + 1); } } else { toRole = Character.toUpperCase(toRole.charAt(0)) + toRole.substring(1); } // There must be a 'to' role name, which is different than null and // not empty. if ((toRole == null) || (toRole.length() <= 0)) { throw new ProcessingException(getFilename(), "There is no role name 'to' for the edge '" + name + "' defined."); } if (ecName == null) { if ((from.get_aggregation() != AggregationKind.NONE) || (to.get_aggregation() != AggregationKind.NONE)) { if (to.get_aggregation() != AggregationKind.NONE) { ecName = "Contains" + toRole; } else { ecName = "IsPartOf" + toRole; } } else { ecName = "LinksTo" + toRole; } } else { ecName += toRole; } if (isUseFromRole()) { String fromRole = from.get_roleName(); if ((fromRole == null) || fromRole.equals("")) { fromRole = ((VertexClass) from.getFirstEndsAtIncidence().getThat()).get_qualifiedName(); int p = fromRole.lastIndexOf('.'); if (p >= 0) { fromRole = fromRole.substring(p + 1); } } else { fromRole = Character.toUpperCase(fromRole.charAt(0)) + fromRole.substring(1); } // There must be a 'from' role name, which is different than // null and not empty. if ((fromRole == null) || (fromRole.length() <= 0)) { throw new ProcessingException(getFilename(), "There is no role name of 'from' for the edge '" + name + "' defined."); } name += fromRole; } assert (ecName != null) && (ecName.length() > 0); ec.set_qualifiedName(name + ecName); } }