List of usage examples for org.apache.commons.lang WordUtils capitalize
public static String capitalize(String str)
Capitalizes all the whitespace separated words in a String.
From source file:com.tengel.time.MobControl.java
public String getName(LivingEntity creature) { String name = creature.getType().name(); name = name.toLowerCase();/*from w ww . j av a 2 s. c om*/ name = WordUtils.capitalize(name); return name.replaceAll("_", " "); }
From source file:net.amigocraft.unusuals.Main.java
public ItemStack createUnusual(Material type, String effect) { UnusualEffect uEffect = effects.get(effect); if (effect != null) { ItemStack is = new ItemStack(type, 1); ItemMeta meta = is.getItemMeta(); meta.setDisplayName("" + UNUSUAL_COLOR + "Unusual " + WordUtils.capitalize(type.toString().toLowerCase().replace("_", " "))); List<String> lore = new ArrayList<String>(); lore.add("" + EFFECT_COLOR + "Effect: " + effect); meta.setLore(lore);// ww w . j a v a 2 s . c o m is.setItemMeta(meta); return is; } else throw new IllegalArgumentException("Effect \"" + effect + "\" does not exist!"); }
From source file:net.dmulloy2.ultimatearena.types.ArenaClass.java
/** * Attempts to load this class//from w w w. ja v a2 s .c o m * * @return Whether or not loading was successful */ public final boolean load() { Validate.isTrue(!loaded, "This class has already been loaded!"); // Initialize variables this.armor = new HashMap<>(); this.tools = new HashMap<>(); try { boolean changes = false; YamlConfiguration config = new YamlConfiguration(); config.load(file); Map<String, Object> values = config.getValues(false); if (isSet(values, "armor")) { for (Entry<String, Object> entry : getSection(values, "armor").entrySet()) { String value = entry.getValue().toString(); ItemStack item = null; try { // Attempt to parse regularly item = ItemUtil.readItem(value); } catch (Throwable ex) { } if (item != null) { armor.put(entry.getKey(), item); continue; } // Read legacy Material material = null; short data = 0; Map<Enchantment, Integer> enchants = new HashMap<>(); value = value.replaceAll(" ", ""); if (value.contains(",")) { String str = value.substring(0, value.indexOf(",")); MyMaterial myMat = MyMaterial.fromString(str); material = myMat.getMaterial(); data = myMat.isIgnoreData() ? 0 : myMat.getData(); enchants = readArmorEnchantments(value.substring(value.indexOf(",") + 1)); } else { MyMaterial myMat = MyMaterial.fromString(value); material = myMat.getMaterial(); data = myMat.isIgnoreData() ? 0 : myMat.getData(); } item = new ItemStack(material, 1, data); if (!enchants.isEmpty()) item.addUnsafeEnchantments(enchants); armor.put(entry.getKey(), item); // Convert config.set("armor." + entry.getKey().toLowerCase(), ItemUtil.serialize(item)); changes = true; } } if (isSet(values, "tools")) { int nextSlot = 0; for (Entry<String, Object> entry : getSection(values, "tools").entrySet()) { int slot = NumberUtil.toInt(entry.getKey()); String value = entry.getValue().toString(); ItemStack stack = ItemUtil.readItem(value, plugin); if (stack != null) tools.put(slot == -1 ? nextSlot : slot - 1, stack); nextSlot++; } } if (isSet(values, "useEssentials")) { config.set("useEssentials", null); changes = true; } essKitName = getString(values, "essentialsKit", ""); useEssentials = !essKitName.isEmpty() && plugin.isEssentialsEnabled(); if (useEssentials) { essentialsKit = plugin.getEssentialsHandler().readEssentialsKit(essKitName); } if (isSet(values, "hasPotionEffects")) { config.set("hasPotionEffects", null); changes = true; } if (isSet(values, "potionEffects")) { String effects = getString(values, "potionEffects", ""); hasPotionEffects = !effects.isEmpty(); if (hasPotionEffects) potionEffects = readPotionEffects(effects); } useHelmet = getBoolean(values, "useHelmet", true); if (isSet(values, "permissionNode")) { if (!getString(values, "permissionNode", "").isEmpty()) config.set("needsPermission", true); config.set("permissionNode", null); changes = true; } needsPermission = getBoolean(values, "needsPermission", false); permissionNode = "ultimatearena.class." + name.toLowerCase().replaceAll("\\s", "_"); if (isSet(values, "icon")) { icon = ItemUtil.readItem(getString(values, "icon", ""), plugin); } if (icon == null) { icon = new ItemStack(Material.PAPER, 1); } title = FormatUtil.format(getString(values, "title", "&e" + WordUtils.capitalize(name))); if (isSet(values, "description")) { for (String line : getStringList(values, "description")) description.add(FormatUtil.format("&7" + line)); } cost = getDouble(values, "cost", -1.0D); ItemMeta meta = icon.getItemMeta(); meta.setDisplayName(title); meta.setLore(description); icon.setItemMeta(meta); maxHealth = getDouble(values, "maxHealth", 20.0D); try { if (changes) config.save(file); } catch (Throwable ex) { plugin.getLogHandler().log(Level.WARNING, Util.getUsefulStack(ex, "saving changes for class \"" + name + "\"")); } } catch (Throwable ex) { plugin.getLogHandler().log(Level.SEVERE, Util.getUsefulStack(ex, "loading class \"" + name + "\"")); return false; } plugin.getLogHandler().debug("Successfully loaded class {0}!", name); return true; }
From source file:net.sourceforge.fenixedu.util.StringFormatter.java
/** * Capitalizes a string according to its type. The first letter is changed * to title case (no other letters are changed) if the string isn't supposed * to be in upper (e.g.: roman numeration) or lower case (e.g.: articles and * prepositions)./*w w w . j a v a 2 s .c o m*/ * * @param uglyWord * the string to capitalize * @param originalWordEndsWithSpecialChar * @return the capitalized word */ public static String capitalizeWord(String uglyWord, boolean originalWordEndsWithSpecialChar) { StringBuilder prettyWord = new StringBuilder(); if (allCapSet.contains(uglyWord)) { prettyWord.append(uglyWord.toUpperCase()); } else { if (!originalWordEndsWithSpecialChar && allLowerSet.contains(uglyWord)) { prettyWord.append(uglyWord); } else { prettyWord.append(WordUtils.capitalize(uglyWord)); } } return prettyWord.toString(); }
From source file:com.cloudera.whirr.cm.integration.BaseITServer.java
private String getTestName() { String qualifier = WordUtils.capitalize(System.getProperty(TEST_CM_VERSION)) + WordUtils.capitalize(System.getProperty(TEST_CM_API_VERSION)) + WordUtils.capitalize(System.getProperty(TEST_CM_CDH_VERSION)) + WordUtils.capitalize(System.getProperty(TEST_PLATFORM)); return WordUtils.capitalize(test.getMethodName()) + (qualifier.equals("") ? "" : "-" + qualifier); }
From source file:gov.redhawk.ide.internal.ui.templates.ResourceControlPanelTemplateSection.java
/** * @return/* w w w. j ava 2s . c o m*/ */ public String getName() { String name; EObject selection = getSelection(); if (selection instanceof SoftPkg) { name = ((SoftPkg) selection).getName(); } else if (selection instanceof SoftwareAssembly) { name = ((SoftwareAssembly) selection).getName(); } else if (selection instanceof DeviceConfiguration) { name = ((DeviceConfiguration) selection).getName(); } else { name = "ControlPanel"; } return makeNameSafe(WordUtils.capitalize(name.trim()).replace(" ", "").replaceAll("[^a-zA-Z0-9]", "_") .replaceAll("_*_", "_")); }
From source file:com.jaspersoft.studio.wizards.functions.FunctionsLibraryInformationPage.java
private void createCategoryLabelAndDescControls(Composite parent, int cols) { Label categoryLabelLbl = new Label(parent, SWT.NONE); categoryLabelLbl.setText("Category Label:"); categoryLabelLbl.setToolTipText("The text shown in the Expression Editor categories list"); categoryLabelLbl.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); categoryLabel = new Text(parent, SWT.BORDER); categoryLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, cols - 1, 1)); categoryLabel.addModifyListener(new ModifyListener() { @Override/*from w w w . j av a2 s . c o m*/ public void modifyText(ModifyEvent e) { // Try to guess the category name // Capitalize the first character of each word // and remove the whitespaces String nameTxt = categoryLabel.getText(); nameTxt = WordUtils.capitalize(nameTxt).replaceAll("\\s", ""); // suggest the class String txt = getPackageText(); if (!txt.isEmpty()) txt += "."; categoryClass.setText(txt + nameTxt); doStatusUpdate(); } }); Label categoryDescriptionLbl = new Label(parent, SWT.NONE); categoryDescriptionLbl.setText("Category Description:"); categoryDescriptionLbl.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); categoryDescriptionLbl.setToolTipText("Additional details regarding the category"); categoryDescription = new Text(parent, SWT.BORDER); categoryDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, cols - 1, 1)); }
From source file:com.liferay.ide.project.core.util.ProjectUtil.java
public static String convertToDisplayName(String name) { if (CoreUtil.isNullOrEmpty(name)) { return StringPool.EMPTY; }/*from www . j av a 2 s.com*/ String displayName = removePluginSuffix(name); displayName = displayName.replaceAll("-", " ").replaceAll("_", " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ displayName = WordUtils.capitalize(displayName); return displayName; }
From source file:net.sourceforge.fenixedu.presentationTier.docs.academicAdministrativeOffice.Diploma.java
@Override protected void setPersonFields() { final Person person = getDocumentRequest().getPerson(); addParameter("name", StringFormatter.prettyPrint(person.getName())); addParameter("nameOfFather", StringFormatter.prettyPrint(person.getNameOfFather())); addParameter("nameOfMother", StringFormatter.prettyPrint(person.getNameOfMother())); String country;/*from w w w . j av a 2 s. c o m*/ String countryUpperCase; if (person.getCountry() != null) { countryUpperCase = person.getCountry().getCountryNationality().getContent(getLanguage()).toLowerCase(); country = WordUtils.capitalize(countryUpperCase); } else { throw new DomainException("error.personWithoutParishOfBirth"); } String nationality = BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "diploma.nationality"); addParameter("birthLocale", MessageFormat.format(nationality, country)); }
From source file:Controlador.ControladorPropiedad.java
/** * Actualiza los datos de una propiedad y crea las nuevas imagenes que * tendra, tambien elimina las imagenes que el usuario decidio eliminar. * * @param propiedad La propiedad a actualizar con sus datos. * @param todosImagenes Todas las imagenes que posee la propiedad(actuales). * @param imagenesElegidos Las imagenes elegidas para guardar. * @param ambientesElegidos Los ambientes elegidos para guardar. * @param serviciosElegidos Los servicios elegidos para guardar- * @param sesion La sesion actual//from www.ja va 2s . c o m * @param imagen Las imagenes nuevas. * @param imagenFileName El nombre de las nuevas imagenes. */ public void actualizar(Propiedad propiedad, List<ImagenPropiedad> todosImagenes, String[] imagenesElegidos, String[] ambientesElegidos, String[] serviciosElegidos, Map<String, Object> sesion, List<File> imagen, List<String> imagenFileName) { //OBTENGO TODAS LAS IMAGENES QUE POSEE LA PROPIEDAD Map<Integer, ImagenPropiedad> mapImagenes = new HashMap<Integer, ImagenPropiedad>(); todosImagenes = controladorImagenPropiedad.getTodos(propiedad.getIdPropiedad()); for (ImagenPropiedad i : todosImagenes) { mapImagenes.put(i.getIdImagenPropiedad(), i); } //OBTENGO LAS IMAGENES QUE EL USUARIO NO QUIERE ELIMINAR boolean cambioCodigo = false; int codigoOriginal = 0; int codigoNuevo = 0; List<ImagenPropiedad> imagenesDeLaPropiedad = new ArrayList<ImagenPropiedad>(); //SE TIENEN Q ELIMINAR TODAS LAS IMAGENES DE LA BD... if (imagenesElegidos != null) { if (!imagenesElegidos[0].equals("false")) { for (String cadaImageneElegido : imagenesElegidos) { int id = Integer.parseInt(cadaImageneElegido); ImagenPropiedad p = controladorImagenPropiedad.getOne(id); Propiedad original = (Propiedad) sesion.get("propiedadOriginal"); //SI EL CODIGO CAMBIO MODIFICAR LOS CODIGOS EN LAS IMAGENES BD.. if (original.getCodigoPropiedad() != propiedad.getCodigoPropiedad()) { String rutaOriginal = p.getRuta(); String rutamodificada = rutaOriginal.replaceAll("codigo_" + original.getCodigoPropiedad(), "codigo_" + propiedad.getCodigoPropiedad()); p.setRuta(rutamodificada); if (!cambioCodigo) { codigoOriginal = original.getCodigoPropiedad(); codigoNuevo = propiedad.getCodigoPropiedad(); } cambioCodigo = true; } imagenesDeLaPropiedad.add(p); //SACO DEL MAPA LAS IMAGENES QUE NO QUIERO ELIMINAR mapImagenes.remove(p.getIdImagenPropiedad()); } } } if (imagenesElegidos != null && imagenesElegidos.length != 1 && !imagenesElegidos[0].equals("false")) { } propiedad.setImagenes(imagenesDeLaPropiedad); //PROCEDO A ELIMINAR TODAS LAS IMAGENES QUE EL USUARIO NO "SELECCIONO" for (Map.Entry<Integer, ImagenPropiedad> cadaImagen : mapImagenes.entrySet()) { ImagenPropiedad imagenPropiedad = cadaImagen.getValue(); Archivo.delete(imagenPropiedad.getRuta()); } if (cambioCodigo) { String ruta = SingletonRuta.getInstancia().getSTORAGE_PATH() + "ImagenPropiedad/codigo_"; String rutaOriginal = ruta + codigoOriginal; String rutaNueva = ruta + codigoNuevo; Archivo.renombrarCarpeta(rutaOriginal, rutaNueva); } //AGREGO LAS NUEVAS IMAGENES String ruta = SingletonRuta.getInstancia().getSTORAGE_PATH() + "ImagenPropiedad/codigo_" + propiedad.getCodigoPropiedad(); if (imagen != null) { for (int i = 0; i < imagen.size(); i++) { File cadaImagen = imagen.get(i); ImagenPropiedad imagenPropiedad = new ImagenPropiedad(); imagenPropiedad.setRuta(Archivo.crearImagen(ruta, cadaImagen, imagenFileName.get(i))); imagenPropiedad.setSize(cadaImagen.length()); propiedad.addImagenPropiedad(imagenPropiedad); } } //GUARDO LOS NUEVOS SERVICIOS ELEGIDOS A LA PROPIEDAD List<Servicio> temp = new ArrayList<Servicio>(); if (serviciosElegidos != null) { for (String cadaServicioElegido : serviciosElegidos) { int id = Integer.parseInt(cadaServicioElegido); Servicio s = controladorServicio.getOne(id); temp.add(s); } propiedad.setServicios(temp); } else { propiedad.setServicios(temp); } //GUARDO LOS NUEVOS AMBIENTES ELEGIDOS A LA PROPIEDAD List<Ambiente> temp2 = new ArrayList<Ambiente>(); if (ambientesElegidos != null) { for (String cadaAmbienteElegido : ambientesElegidos) { int id = Integer.parseInt(cadaAmbienteElegido); Ambiente a = controladorAmbiente.getOne(id); temp2.add(a); } propiedad.setAmbientes(temp2); } else { propiedad.setAmbientes(temp2); } propiedad.setDireccion(WordUtils.capitalize(propiedad.getDireccion())); propiedadDAO.actualizar(propiedad); }