List of usage examples for org.apache.commons.lang3 StringUtils capitalize
public static String capitalize(final String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:io.bibleget.VersionsSelect.java
public VersionsSelect() throws ClassNotFoundException { biblegetDB = BibleGetDB.getInstance(); String bibleVersionsStr = biblegetDB.getMetaData("VERSIONS"); JsonReader jsonReader = Json.createReader(new StringReader(bibleVersionsStr)); JsonObject bibleVersionsObj = jsonReader.readObject(); Set<String> versionsabbrev = bibleVersionsObj.keySet(); bibleVersions = new BasicEventList<>(); if (!versionsabbrev.isEmpty()) { for (String s : versionsabbrev) { String versionStr = bibleVersionsObj.getString(s); //store these in an array String[] array;/*from w ww . ja va 2 s . co m*/ array = versionStr.split("\\|"); bibleVersions.add(new BibleVersion(s, array[0], array[1], StringUtils.capitalize(new Locale(array[2]).getDisplayLanguage()))); } } versionsByLang = new SeparatorList<>(bibleVersions, new VersionComparator(), 1, 1000); int listLength = versionsByLang.size(); enabledFlags = new boolean[listLength]; ListIterator itr = versionsByLang.listIterator(); while (itr.hasNext()) { int idx = itr.nextIndex(); Object next = itr.next(); enabledFlags[idx] = !(next.getClass().getSimpleName().equals("GroupSeparator")); if (enabledFlags[idx]) { versionCount++; } else { versionLangs++; } } this.setModel(new DefaultEventListModel<>(versionsByLang)); this.setCellRenderer(new VersionCellRenderer()); this.setSelectionModel(new DisabledItemSelectionModel()); }
From source file:com.thoughtworks.go.config.exceptions.EntityType.java
public String deleteSuccessful(String id) { return format("%s %s '%s' was deleted successfully!", StringUtils.capitalize(this.entityType), this.nameOrId.descriptor, id); }
From source file:com.zack6849.alphabot.listeners.MessageEvent.java
@Override public void onMessage(org.pircbotx.hooks.events.MessageEvent event) { String trigger = config.getTrigger(); if (event.getMessage().startsWith(trigger)) { try {//w w w .j av a 2 s . c om String commandname = event.getMessage().split(" ")[0].substring(config.getTrigger().length()) .toLowerCase(); File commandfile = new File( "commands/" + event.getChannel().getName() + "/" + commandname + ".cmd"); if (commandfile.exists()) { BufferedReader in = new BufferedReader(new FileReader(commandfile)); String tmp; while ((tmp = in.readLine()) != null) { event.getChannel().send().message(commandname + ": " + tmp); } in.close(); } String classname = StringUtils .capitalize(event.getMessage().split(" ")[0].substring(config.getTrigger().length())); String permission = "command." + classname.toLowerCase(); if (manager.getUserGroup(event.getUser()).hasPermission(new Permission(permission, false))) { Command command = CommandRegistry.getCommand(classname); if (!command.execute(event)) { event.getChannel().send().message(Colors.RED + "An error occurred! " + command.getHelp()); return; } } else { event.getUser().send().notice( config.getPermissionDenied().replaceAll("%USERNAME%", event.getUser().getNick())); } } catch (Exception e) { /* * Unknown command * >implying i give a fuck * */ Logger.getLogger(MessageEvent.class.getName()).log(Level.SEVERE, null, e); } } for (String word : event.getMessage().split(" ")) { if (Utils.isUrl(word)) { event.getChannel().send() .message(Utils.munge(event.getUser().getNick()) + "'s URL: " + Utils.getTitle(word)); } } }
From source file:com.fdorigo.rmfly.jpa.entities.Judge.java
public void setFirstName(String firstName) { this.firstName = StringUtils.capitalize(firstName.toLowerCase()); }
From source file:info.magnolia.integrationtests.uitest.CategoriesAppUITest.java
@Test public void verifyBasicCreateReadUpdateDelete() { // GIVEN/*from w ww . j av a2 s . co m*/ final String testName = "TestCategory"; getAppIcon("Categories").click(); waitUntil(appIsLoaded()); assertAppOpen("Categories"); getActionBarItem("Add folder").click(); waitUntil(elementToBeClickable(getTreeTableItem("untitled"))); getActionBarItem("Add category").click(); waitUntil(appIsLoaded()); getFormTextField("Category name").sendKeys(testName); getFormTextField("Display name").sendKeys(StringUtils.capitalize(testName)); getFormTextField("Category name").click(); // WHEN getDialogButton("v-button-commit").click(); waitUntil(appIsLoaded()); // we expect preloader to show up when heading back to browser subapp // THEN expandTreeAndSelectAnElement(testName, "untitled"); assertTrue(isExisting(getTreeTableItem(testName))); // GIVEN - rename final String renamedName = "RenamedFrom" + testName; getActionBarItem("Edit category").click(); waitUntil(appIsLoaded()); WebElement categoryNameField = getFormTextField("Category name"); categoryNameField.clear(); categoryNameField.sendKeys(renamedName); getFormTextField("Display name").click(); // WHEN getDialogButton("v-button-commit").click(); waitUntil(appIsLoaded()); // we expect preloader to show up when heading back to browser subapp // THEN assertTrue(isExisting(getTreeTableItem(renamedName))); // GIVEN - delete if (!isTreeTableItemSelected("untitled")) { getTreeTableItem("untitled").click(); } getActionBarItem("Delete folder").click(); getDialogButtonWithCaption("Yes, delete").click(); waitUntil(elementIsGone(byDialogButtonWithCaption("Yes, delete"))); // WHEN getActionBarItem("Publish deletion").click(); // THEN waitUntil(15, elementIsGone( String.format("//*[contains(@class, 'v-table-cell-wrapper') and text() = '%s']", "untitled"))); }
From source file:com.nerve.commons.repository.utils.reflection.ReflectionUtils.java
/** * Setter, ???/*from w w w .j a v a 2 s . c o m*/ * ???.??. */ public static void invokeSetter2(Object obj, String propertyName, Object value) { Object object = obj; String[] names = StringUtils.split(propertyName, "."); for (int i = 0; i < names.length; i++) { if (i < names.length - 1) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); } else { String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); invokeMethodByName(object, setterMethodName, new Object[] { value }); } } }
From source file:com.volumetricpixels.vitals.commands.AdminCommands.java
@Command(aliases = { "weather" }, usage = "<weather type>", desc = "Change the weather.", min = 1, max = 1) @CommandPermissions("vitals.command.weather") public void weather(CommandContext args, CommandSource source) throws CommandException { if (source instanceof Player) { // Getting the sky VanillaSky sky = VanillaSky.getSky(((Player) source).getWorld()); // Get the weather String wName = args.getString(0); Weather w = Weather.valueOf(wName.toUpperCase()); if (w == null) { source.sendMessage(ChatStyle.GRAY, "Unknown weather type '" + ChatStyle.RED + wName + ChatStyle.GRAY + "'. Available weather types: " + ChatStyle.RED, Joiner.on(' ').join(Weather.values())); return; }//from w w w . ja va 2 s . c o m sky.setWeather(w); source.sendMessage(ChatStyle.GRAY, "Weather set to '" + ChatStyle.RED, StringUtils.capitalize(w.toString()) + "'."); } }
From source file:com.thoughtworks.go.config.exceptions.EntityType.java
public String deleteSuccessful(List<?> ids) { return format("%ss %ss '%s' were deleted successfully!", StringUtils.capitalize(this.entityType), this.nameOrId.descriptor, StringUtils.join(ids, ", ")); }
From source file:cn.afterturn.easypoi.excel.html.css.impl.BorderCssConverImpl.java
@Override public void convertToExcel(Cell cell, CellStyle cellStyle, CellStyleEntity style) { if (style == null || style.getBorder() == null) { return;/*from w ww .java 2 s .co m*/ } CellStyleBorderEntity border = style.getBorder(); for (String pos : new String[] { TOP, RIGHT, BOTTOM, LEFT }) { String posName = StringUtils.capitalize(pos.toLowerCase()); // color String colorAttr = null; try { colorAttr = (String) MethodUtils.invokeMethod(border, "getBorder" + posName + "Color"); } catch (Exception e) { log.error("Set Border Style Error Caused.", e); } if (StringUtils.isNotEmpty(colorAttr)) { if (cell instanceof HSSFCell) { HSSFColor poiColor = PoiCssUtils.parseColor((HSSFWorkbook) cell.getSheet().getWorkbook(), colorAttr); if (poiColor != null) { try { MethodUtils.invokeMethod(cellStyle, "set" + posName + "BorderColor", poiColor.getIndex()); } catch (Exception e) { log.error("Set Border Color Error Caused.", e); } } } if (cell instanceof XSSFCell) { XSSFColor poiColor = PoiCssUtils.parseColor(colorAttr); if (poiColor != null) { try { MethodUtils.invokeMethod(cellStyle, "set" + posName + "BorderColor", poiColor); } catch (Exception e) { log.error("Set Border Color Error Caused.", e); } } } } // width int width = 0; try { String widthStr = (String) MethodUtils.invokeMethod(border, "getBorder" + posName + "Width"); if (PoiCssUtils.isNum(widthStr)) { width = Integer.parseInt(widthStr); } } catch (Exception e) { log.error("Set Border Style Error Caused.", e); } String styleValue = null; try { styleValue = (String) MethodUtils.invokeMethod(border, "getBorder" + posName + "Style"); } catch (Exception e) { log.error("Set Border Style Error Caused.", e); } BorderStyle shortValue = BorderStyle.NONE; // empty or solid if (StringUtils.isBlank(styleValue) || "solid".equals(styleValue)) { if (width > 2) { shortValue = BorderStyle.THICK; } else if (width > 1) { shortValue = BorderStyle.MEDIUM; } else { shortValue = BorderStyle.THIN; } } else if (ArrayUtils.contains(new String[] { NONE, HIDDEN }, styleValue)) { shortValue = BorderStyle.NONE; } else if (DOUBLE.equals(styleValue)) { shortValue = BorderStyle.DOUBLE; } else if (DOTTED.equals(styleValue)) { shortValue = BorderStyle.DOTTED; } else if (DASHED.equals(styleValue)) { if (width > 1) { shortValue = BorderStyle.MEDIUM_DASHED; } else { shortValue = BorderStyle.DASHED; } } // border style if (shortValue != BorderStyle.NONE) { try { MethodUtils.invokeMethod(cellStyle, "setBorder" + posName, shortValue); } catch (Exception e) { log.error("Set Border Style Error Caused.", e); } } } }
From source file:com.cryart.sabbathschool.viewmodel.SSLessonItemViewModel.java
public String getDate() { String startDateOut = DateTimeFormat.forPattern(SSConstants.SS_DATE_FORMAT_OUTPUT) .print(DateTimeFormat.forPattern(SSConstants.SS_DATE_FORMAT).parseLocalDate(ssLesson.start_date)); String endDateOut = DateTimeFormat.forPattern(SSConstants.SS_DATE_FORMAT_OUTPUT) .print(DateTimeFormat.forPattern(SSConstants.SS_DATE_FORMAT).parseLocalDate(ssLesson.end_date)); return StringUtils.capitalize(startDateOut) + " - " + StringUtils.capitalize(endDateOut); }