Java Code Examples for org.apache.commons.lang3.text.WordUtils#capitalizeFully()

The following examples show how to use org.apache.commons.lang3.text.WordUtils#capitalizeFully() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From SkyblockAddons with MIT License 6 votes vote down vote up
public String getReforgeFromItem(ItemStack item) {
    if (item.hasTagCompound()) {
        NBTTagCompound extraAttributes = item.getTagCompound();
        if (extraAttributes.hasKey("ExtraAttributes")) {
            extraAttributes = extraAttributes.getCompoundTag("ExtraAttributes");
            if (extraAttributes.hasKey("modifier")) {
                String reforge = WordUtils.capitalizeFully(extraAttributes.getString("modifier"));

                reforge = reforge.replace("_sword", ""); //fixes reforges like "Odd_sword"
                reforge = reforge.replace("_bow", "");

                return reforge;
            }
        }
    }
    return null;
}
 
Example 2
Source File: ResponseParser.java    From bunk with MIT License 6 votes vote down vote up
private Student processLogin(String loginJson) {
    JsonObject login;
    try {
        login = this.jsonParser.parse(loginJson).getAsJsonObject();
    } catch (Exception e) {
        throw new InvalidResponseException();
    }

    if (!login.has("status") || !login.has("name")) {
        throw new InvalidResponseException();
    }

    if (!login.get("status").getAsString().equals("success")) {
        throw new InvalidCredentialsException();
    }

    Student student = new Student();
    student.name = WordUtils.capitalizeFully(login.get("name").getAsString());

    return student;
}
 
Example 3
Source File: TypeChooser.java    From Shuffle-Move with GNU General Public License v3.0 6 votes vote down vote up
public void setSelectedType(PkmType type) {
   String toSelect = null;
   if (type != null) {
      if (shouldRebuild) {
         refill();
      }
      toSelect = WordUtils.capitalizeFully(type.toString());
      DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) getModel();
      if (model.getIndexOf(toSelect) == -1) {
         shouldRebuild = true;
         insertItemAt(toSelect, 0);
      } else {
         shouldRebuild = false;
      }
   }
   setSelectedItem(toSelect);
}
 
Example 4
Source File: CapitalizeWordsInSentence.java    From levelup-java-examples with Apache License 2.0 5 votes vote down vote up
@Test
public void capitalize_each_word_in_sentence_apache_commons () {
	
	String prideAndPrejudiceSentence = "It is a truth universally acknowledged, "
			+ "that a single man in possession of a good fortune, must be in want of a wife.";
	
	String eachWordCapitalized = WordUtils.capitalizeFully(prideAndPrejudiceSentence);
	
	assertEquals("It Is A Truth Universally Acknowledged, That A Single "
			+ "Man In Possession Of A Good Fortune, Must Be In Want Of A Wife.",
			eachWordCapitalized);
}
 
Example 5
Source File: RuleTemplateView.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
public void setRuleTemplate (@NonNull List<TemplateTextField> fields, OnTemplateFieldClickListener listener) {

        this.setText("");

        for (TemplateTextField thisField : fields) {

            // Capitalize proper nouns; lowercase all other editable fields.
            String displayText = thisField.getText();
            if (thisField.isEditable()) {
                displayText = thisField.isProperName() ? WordUtils.capitalizeFully(displayText) : displayText.toLowerCase();
            }

            SpannableStringBuilder span = SpannableStringBuilder.valueOf(displayText);

            if (thisField.isEditable()) {
                span.setSpan(new EditableSpan(thisField, listener), 0, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            int textColor = thisField.isEditable() ? Color.BLACK : Color.GRAY;
            span.setSpan(new ForegroundColorSpan(textColor), 0, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            this.append(span);
        }

        this.setHighlightColor(Color.TRANSPARENT);

        if (enabled) {
            this.setMovementMethod(LinkMovementMethod.getInstance());
        }
    }
 
Example 6
Source File: Words.java    From OpenModsLib with MIT License 5 votes vote down vote up
public static IGenerator capitalizeFully(IGenerator gen) {
	return new Transformer(gen) {
		@Override
		protected String transform(String input) {
			return WordUtils.capitalizeFully(input);
		}
	};
}
 
Example 7
Source File: EffectChooser.java    From Shuffle-Move with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Converts a given string, s, from the Enumerator name to an nicely legible name. Any occurrence
 * of "_P_" becomes a "+_". Then, any trailing "_P" become "+". Finally, all "_" are replaced by
 * spaces and the string is fully capitalized.
 * 
 * @param s
 * @return
 */
public static String convertToBox(String s) {
   String temp = s.replaceAll("_P_", "+_");
   if (temp.endsWith("_P")) {
      temp = temp.substring(0, temp.length() - 2) + "+";
   }
   temp = temp.replaceAll("_", " ");
   return WordUtils.capitalizeFully(temp);
}
 
Example 8
Source File: EditTeamService.java    From Shuffle-Move with GNU General Public License v3.0 5 votes vote down vote up
private void rebuildSelectedLabel() {
   String textToUse = getString(KEY_NONE_SELECTED);
   if (selectedSpecies != null) {
      String name = selectedSpecies.getLocalizedName();
      RosterManager rosterManager = getUser().getRosterManager();
      Integer thisLevel = rosterManager.getLevelForSpecies(selectedSpecies);
      int attack = selectedSpecies.getAttack(thisLevel);
      PkmType type = megaFilter.isSelected() ? selectedSpecies.getMegaType() : selectedSpecies.getType();
      String typeNice = WordUtils.capitalizeFully(type.toString());
      Effect effect = selectedSpecies.getEffect(getUser().getRosterManager());
      String effectNice = EffectChooser.convertToBox(effect.toString());
      textToUse = getString(KEY_SELECTED, name, attack, typeNice, effectNice);
   }
   selectedDisplayLabel.setText(textToUse);
}
 
Example 9
Source File: CalendarEvent.java    From canvas-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SerializedName("Group")
GROUP,
@SerializedName("User")
USER;

@Override
public String toString() { return WordUtils.capitalizeFully(name()); }
 
Example 10
Source File: AbstractOktaStateHandler.java    From cerberus with Apache License 2.0 5 votes vote down vote up
/**
 * Print a user-friendly name for a MFA device
 *
 * @param factor Okta MFA factor
 * @return Device name
 */
public String getDeviceName(final Factor factor) {

  Preconditions.checkArgument(factor != null, "Factor cannot be null.");

  final String factorKey = getFactorKey(factor);

  if (MFA_FACTOR_NAMES.containsKey(factorKey)) {
    return MFA_FACTOR_NAMES.get(factorKey);
  }
  return WordUtils.capitalizeFully(factorKey);
}
 
Example 11
Source File: LabelFallbackHandler.java    From ambari-logsearch with Apache License 2.0 5 votes vote down vote up
private String capitalize(String input, boolean capitalizeAll) {
  if (capitalizeAll) {
    return WordUtils.capitalizeFully(input);
  } else {
    Character firstLetter = Character.toUpperCase(input.charAt(0));
    return input.length() > 1 ? firstLetter + input.substring(1) : firstLetter.toString();
  }
}
 
Example 12
Source File: EditRosterService.java    From Shuffle-Move with GNU General Public License v3.0 4 votes vote down vote up
private void rebuildSelectedLabel() {
   String textToUse = getString(KEY_NONE_SELECTED);
   if (selectedSpecies != null) {
      String name = selectedSpecies.getLocalizedName();
      Integer thisLevel = myData.getLevelForSpecies(selectedSpecies);
      int attack = selectedSpecies.getAttack(thisLevel);
      PkmType type = megaFilter.isSelected() ? selectedSpecies.getMegaType() : selectedSpecies.getType();
      String typeNice = WordUtils.capitalizeFully(type.toString());
      Effect effect = selectedSpecies.getEffect(myData);
      String effectNice = EffectChooser.convertToBox(effect.toString());
      textToUse = getString(KEY_SELECTED, name, attack, typeNice, effectNice);
   }
   selectedDisplayLabel.setText(textToUse);
   final boolean isMega = selectedSpecies != null && selectedSpecies.getMegaName() != null;
   removeSpeedupsListener();
   speedups.setEnabled(isMega);
   speedups.removeAllItems();
   if (isMega) {
      int megaSpeedupCap = getUser().getEffectManager().getMegaSpeedupCap(selectedSpecies);
      for (int i = 0; i <= megaSpeedupCap; i++) {
         speedups.addItem(i);
      }
      int megaSpeedups = Math.min(myData.getMegaSpeedupsFor(selectedSpecies), megaSpeedupCap);
      speedups.setSelectedItem(megaSpeedups);
   }
   addSpeedupsListener();
   removeSkillLevelListener();
   skillLevels.setEnabled(selectedSpecies != null);
   skillLevels.removeAllItems();
   if (selectedSpecies != null) {
      for (int i = 1; i <= 5; i++) {
         skillLevels.addItem(i);
      }
      int skillLevel = Math.min(Math.max(myData.getSkillLevelForSpecies(selectedSpecies), 1), 5);
      skillLevels.setSelectedItem(skillLevel);
   }
   addSkillLevelListener();
   removeActiveEffectListener();
   if (selectedSpecies != null && selectedSpecies.getEffects().size() > 1) {
      activeEffect.setEnabled(true);
      activeEffect.setSpecies(selectedSpecies);
      activeEffect.setSelectedEffect(selectedSpecies.getEffect(myData));
   } else {
      activeEffect.removeAllItems();
      activeEffect.setEnabled(false);
   }
   addActiveEffectListener();
}
 
Example 13
Source File: Aspect.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
public String getName() {
	return WordUtils.capitalizeFully(tag);
}
 
Example 14
Source File: Aspect.java    From AdvancedMod with GNU General Public License v3.0 4 votes vote down vote up
public String getName() {
	return WordUtils.capitalizeFully(tag);
}
 
Example 15
Source File: Aspect.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
public String getName() {
	return WordUtils.capitalizeFully(tag);
}
 
Example 16
Source File: Aspect.java    From GardenCollection with MIT License 4 votes vote down vote up
public String getName() {
	return WordUtils.capitalizeFully(tag);
}
 
Example 17
Source File: Aspect.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
public String getName() {
	return WordUtils.capitalizeFully(tag);
}
 
Example 18
Source File: Aspect.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public String getName() {
	return WordUtils.capitalizeFully(tag);
}
 
Example 19
Source File: TitleCaseConverter.java    From tutorials with MIT License 4 votes vote down vote up
public static String convertToTileCaseWordUtilsFull(String text) {
    return WordUtils.capitalizeFully(text);
}
 
Example 20
Source File: SpliceStringFunctions.java    From spliceengine with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
    * Implements logic for the SQL function INITCAP.
    * 
    * @param source the String to be capitalized
    * 
    * @return the capitalized String
    */
public static String INITCAP(String source) {
	return WordUtils.capitalizeFully(source);
}