List of usage examples for org.apache.commons.lang StringUtils capitalize
public static String capitalize(String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:edu.ku.brc.af.core.expresssearch.QueryForIdResultsHQL.java
/** * /*w w w . j av a 2 s . c om*/ */ protected void buildCaptions() { captions = new Vector<ERTICaptionInfo>(); int i = 0; for (DisplayFieldConfig dfc : searchTableConfig.getDisplayFields()) { ERTICaptionInfo caption = new ERTICaptionInfo(dfc.getFieldInfo().getColumn(), dfc.getFieldInfo().getTitle(), true, dfc.getFieldInfo().getFormatter(), i + 1); caption.setColClass(dfc.getFieldInfo().getDataClass()); if (dfc.getFieldInfo().isPartialDate()) { String precName = dfc.getFieldInfo().getDatePrecisionName(); Vector<ColInfo> colInfoList = new Vector<ColInfo>(); ColInfo columnInfo = caption.new ColInfo(StringUtils.capitalize(precName), precName); columnInfo.setPosition(0); colInfoList.add(columnInfo); columnInfo = caption.new ColInfo(dfc.getFieldInfo().getColumn(), dfc.getFieldInfo().getName()); columnInfo.setPosition(1); colInfoList.add(columnInfo); caption.setColInfoList(colInfoList); caption.setColName(null); // XXX We need to get this from the SchemaConfig caption.setUiFieldFormatter(UIFieldFormatterMgr.getInstance().getFormatter("PartialDate")); } captions.add(caption); i++; } }
From source file:ch.entwine.weblounge.common.impl.content.page.LinkImpl.java
/** * Initializes this include from an XML node that was generated using * {@link #toXml()}./*from www . j a v a 2 s . co m*/ * * @param config * the include node * @param xpathProcessor * xpath processor to use * @throws IllegalStateException * if the configuration cannot be parsed * @see #toXml() */ public static LinkImpl fromXml(Node config, XPath xpathProcessor) throws IllegalStateException { String href = XPathHelper.valueOf(config, "@href", xpathProcessor); if (href == null) throw new ConfigurationException("Source path of link definition is mandatory!"); String charset = XPathHelper.valueOf(config, "@charset", xpathProcessor); String media = XPathHelper.valueOf(config, "@media", xpathProcessor); String rel = XPathHelper.valueOf(config, "@rel", xpathProcessor); String rev = XPathHelper.valueOf(config, "@rev", xpathProcessor); String type = XPathHelper.valueOf(config, "@type", xpathProcessor); LinkImpl include = new LinkImpl(href, type, media, rel, rev, charset); String use = XPathHelper.valueOf(config, "@use", xpathProcessor); if (StringUtils.isNotBlank(use)) { include.setUse(Use.valueOf(StringUtils.capitalize(use))); } return include; }
From source file:de.innovationgate.wgpublisher.hdb.HDBModelListener.java
public static String createContentClassJsIdentifier(String contentClass) { // Remove chars not allowed in JS var names: StringBuffer extension = new StringBuffer(); for (int idx = 0; idx < contentClass.length(); idx++) { Character c = contentClass.charAt(idx); if (idx == 0) { if (Character.isLetter(c)) { extension.append(c);/*w w w . j ava 2 s . c om*/ } } else { if (Character.isLetter(c) || Character.isDigit(c)) { extension.append(c); } } } // Capitalize return StringUtils.capitalize(extension.toString().toLowerCase()); }
From source file:com.frameworkset.orm.engine.model.Column.java
/** * Returns the name for the getter method to retrieve the value of this * column// w w w . j a va2s .c o m * * @return A getter method name for this column. * @since 3.2 */ public String getGetterName() { if (("boolean".equalsIgnoreCase(getJavaNative()) && isCorrectGetters())) { return "is" + StringUtils.capitalize(getJavaName()); } else { return "get" + StringUtils.capitalize(getJavaName()); } }
From source file:com.censoredsoftware.infractions.bukkit.legacy.CommandHandler.java
@Override public boolean onCommand(CommandSender sender, Command c, String label, String[] args) { Player p = null;// w w w . j av a 2 s .com if (sender instanceof Player) p = (Player) sender; if (c.getName().equalsIgnoreCase("infractions")) { MiscUtil.sendMessage(p, "---------------"); MiscUtil.sendMessage(p, "INFRACTIONS HELP"); MiscUtil.sendMessage(p, "---------------"); if (MiscUtil.hasPermissionOrOP(p, "infractions.mod")) { MiscUtil.sendMessage(p, ChatColor.GRAY + " /cite <player> <infraction> [proof-url]"); MiscUtil.sendMessage(p, ChatColor.GRAY + " /uncite <player> <key>" + ChatColor.WHITE + " - Find the key with " + ChatColor.YELLOW + "/history" + ChatColor.WHITE + "."); } MiscUtil.sendMessage(p, ChatColor.GRAY + " /history [player]"); MiscUtil.sendMessage(p, ChatColor.GRAY + " /reasons " + ChatColor.WHITE + "- Shows all valid infraction reasons."); MiscUtil.sendMessage(p, ChatColor.GRAY + " /virtues " + ChatColor.WHITE + "- Shows all valid virtue types."); return true; } else if (c.getName().equalsIgnoreCase("reasons")) { MiscUtil.sendMessage(p, "------------------"); MiscUtil.sendMessage(p, "INFRACTION REASONS"); MiscUtil.sendMessage(p, "------------------"); for (int i = 1; i < 6; i++) { MiscUtil.sendMessage(p, (i < 3 ? ChatColor.GREEN : i < 5 ? ChatColor.YELLOW : ChatColor.RED) + "Level " + i + ":"); for (int j = 0; j < SettingUtil.getLevel(i).size(); j++) MiscUtil.sendMessage(p, " " + SettingUtil.getLevel(i).get(j)); } return true; } else if (c.getName().equalsIgnoreCase("cite")) { if (!MiscUtil.hasPermissionOrOP(p, "infractions.mod")) { MiscUtil.sendMessage(p, "You do not have enough permissions."); return true; } if (SettingUtil.getSettingBoolean("require_proof")) { if ((args.length != 3)) { MiscUtil.sendMessage(p, "You must provide a valid URL as proof."); return false; } if (!URLUtil.isValidURL(args[2])) { MiscUtil.sendMessage(p, "You must provide a valid URL as proof."); return false; } } if (args.length == 0 || args.length == 1) { MiscUtil.sendMessage(p, "Not enough arguments."); return false; } if (Infractions.getCompleteDossier(args[0]) == null) { MiscUtil.sendMessage(p, "This player hasn't joined yet."); return true; } // Levels Integer level = SettingUtil.getLevel(args[1]); if (level != null) { if (args.length == 3) { if (!URLUtil.isValidURL(args[2])) { MiscUtil.sendMessage(p, "You must provide a valid URL as proof."); return false; } MiscUtil.addInfraction(MiscUtil.getInfractionsPlayer(args[0]), sender, level, args[1], URLUtil.convertURL(args[2])); } else { MiscUtil.addInfraction(MiscUtil.getInfractionsPlayer(args[0]), sender, level, args[1], "No proof."); } MiscUtil.sendMessage(p, ChatColor.GOLD + "Success! " + ChatColor.WHITE + "The level " + level + " infraction has been received."); MiscUtil.kickNotify(MiscUtil.getInfractionsPlayer(args[0]), args[1]); return true; } } else if (c.getName().equalsIgnoreCase("uncite")) { if (!(args.length == 2)) { MiscUtil.sendMessage(p, "Not enough arguments."); return false; } if (!MiscUtil.hasPermissionOrOP(p, "infractions.mod")) { MiscUtil.sendMessage(p, "You do not have enough permissions."); return true; } if (MiscUtil.removeInfraction(MiscUtil.getInfractionsPlayer(args[0]), args[1])) { MiscUtil.sendMessage(p, "Infraction removed!"); try { MiscUtil.checkScore(MiscUtil.getInfractionsPlayer(args[0])); } catch (NullPointerException e) { // player is offline } return true; } MiscUtil.sendMessage(p, "No such infraction."); return true; } else if (c.getName().equalsIgnoreCase("history")) { if (!(args.length == 1) && !(p == null)) { if (MiscUtil.ignore(p)) { sender.sendMessage(ChatColor.YELLOW + "Infractions does not track your history."); return true; } p.performCommand("history " + p.getName()); return true; } if ((p == null) && !(args.length == 1)) { log.info("You must provide a username in the console."); return false; } if (!MiscUtil.hasPermissionOrOP(p, "infractions.mod") && !p.getName().toLowerCase().equals(args[0])) { p.sendMessage(ChatColor.RED + "You don't have permission to do that."); return true; } /** * DISPLAY ALL CURRENT INFRACTIONS */ String player = MiscUtil.getInfractionsPlayer(args[0]); if (player != null) { sender.sendMessage(" "); CompleteDossier dossier = Infractions.getCompleteDossier(player); Integer maxScore = MiscUtil.getMaxScore(Infractions.getCompleteDossier(player).getId()); String chatLevel = InfractionsPlugin.getLevelForChat(player); MiscUtil.sendMessage(p, ChatColor.WHITE + (chatLevel.equals("") ? "" : chatLevel + " ") + ChatColor.YELLOW + player + ChatColor.WHITE + " - " + MiscUtil.getScore(player) + (maxScore == null ? " points towards a ban." : " points out of " + maxScore + " until a ban.")); try { boolean staff = MiscUtil.hasPermissionOrOP(p, "infractions.mod"); Set<Infraction> infractions = dossier.getInfractions(); if (!infractions.isEmpty()) { for (Infraction infraction : infractions) { MiscUtil.sendMessage(p, ChatColor.DARK_RED + " " + ChatColor.DARK_PURPLE + StringUtils.capitalize(infraction.getReason()) + ChatColor.DARK_GRAY + " - " + ChatColor.BLUE + FORMAT.format(infraction.getDateCreated())); MiscUtil.sendMessage(p, ChatColor.DARK_GRAY + " Penalty: " + ChatColor.GRAY + infraction.getScore()); MiscUtil.sendMessage(p, ChatColor.DARK_GRAY + " Proof: " + ChatColor.GRAY + Iterables.getFirst(Collections2.transform(infraction.getEvidence(), new Function<Evidence, Object>() { @Override public String apply(Evidence evidence) { return evidence.getRawData(); } }), "No Proof.")); if (staff) { String id = MiscUtil.getInfractionId(infraction); MiscUtil.sendMessage(p, ChatColor.DARK_GRAY + " Key: " + ChatColor.GRAY + id); String issuerId = infraction.getIssuer().getId(); if (IssuerType.STAFF.equals(infraction.getIssuer().getType())) { UUID issuerUUID = UUID.fromString(issuerId); ConcurrentMap<UUID, LegacyDossier> map = DataManager.getManager() .getMapFor(LegacyDossier.class); if (map.containsKey(issuerUUID) && map.get(issuerUUID) instanceof CompleteDossier) { CompleteDossier issuerDossier = (LegacyCompleteDossier) map.get(issuerUUID); issuerId = issuerDossier.getLastKnownName(); } else { issuerId = "INVALID UUID: " + issuerId; } } MiscUtil.sendMessage(p, ChatColor.DARK_GRAY + " Issuer: " + ChatColor.GRAY + issuerId); } } } else MiscUtil.sendMessage(p, ChatColor.DARK_GREEN + " " + ChatColor.WHITE + "No infractions found for this player."); if (!staff) return true; Set<InetAddress> addresses = dossier.getAssociatedIPAddresses(); MiscUtil.sendMessage(p, ChatColor.BLUE + " " + ChatColor.DARK_AQUA + "Associated IP Addresses:"); if (addresses.isEmpty()) MiscUtil.sendMessage(p, ChatColor.GRAY + " No currently known addresses."); else for (InetAddress address : addresses) { MiscUtil.sendMessage(p, ChatColor.GRAY + " " + address.getHostAddress()); Collection<String> others = AsyncIPMatcherTask.getRelatives(dossier.getId()); if (others.size() > 1) { MiscUtil.sendMessage(p, ChatColor.DARK_GRAY + " - also associated with:"); for (String other : others) { if (other.equals(player)) continue; MiscUtil.sendMessage(p, ChatColor.GRAY + " " + ChatColor.YELLOW + other); } } } sender.sendMessage(" "); return true; } catch (NullPointerException e) { return true; } } else { MiscUtil.sendMessage(p, "A player with the name \"" + args[0] + "\" cannot be found."); return true; } } else if (c.getName().equalsIgnoreCase("clearhistory") && p != null && p.hasPermission("infractions.clearhistory") && args.length > 0) { try { Player remove = Bukkit.getServer().matchPlayer(args[0]).get(0); Infractions.removeDossier(remove.getUniqueId()); remove.kickPlayer(ChatColor.GREEN + "Your Infractions history has been reset--please join again."); return true; } catch (Exception error) { sender.sendMessage(ChatColor.RED + "Could not find that player..."); return false; } } MiscUtil.sendMessage(p, "Something went wrong, please try again."); return false; }
From source file:ch.algotrader.esper.aggregation.GenericTALibFunctionFactory.java
@Override public void validate(AggregationValidationContext validationContext) { this.core = new CoreAnnotated(); Class<?>[] paramTypes = validationContext.getParameterTypes(); // get the functionname String talibFunctionName = (String) getConstant(validationContext, 0, String.class); // get the method by iterating over all core-methods // we have to do it this way, since we don't have the exact parameters for (Method method : this.core.getClass().getDeclaredMethods()) { if (method.getName().equals(talibFunctionName)) { this.function = method; break; }//from ww w . j a va2s .c o m } // check that we have a function now if (this.function == null) { throw new IllegalArgumentException("function " + talibFunctionName + " was not found"); } // get the parameters int paramCounter = 1; Map<String, Class<?>> outputParamTypes = new HashMap<>(); for (Annotation[] annotations : this.function.getParameterAnnotations()) { for (Annotation annotation : annotations) { // got through all inputParameters and count them if (annotation instanceof InputParameterInfo) { InputParameterInfo inputParameterInfo = (InputParameterInfo) annotation; if (inputParameterInfo.type().equals(InputParameterType.TA_Input_Real)) { if (paramTypes[paramCounter].equals(double.class) || paramTypes[paramCounter].equals(Double.class)) { this.inputParamCount++; paramCounter++; } else { throw new IllegalArgumentException( "param number " + paramCounter + " must be of type double"); } } else if (inputParameterInfo.type().equals(InputParameterType.TA_Input_Integer)) { if (paramTypes[paramCounter].equals(int.class) || paramTypes[paramCounter].equals(Integer.class)) { this.inputParamCount++; paramCounter++; } else { throw new IllegalArgumentException( "param number " + paramCounter + " must be of type int"); } } else if (inputParameterInfo.type().equals(InputParameterType.TA_Input_Price)) { // the flags define the number of parameters in use by a bitwise or int priceParamSize = numberOfSetBits(inputParameterInfo.flags()); for (int i = 0; i < priceParamSize; i++) { if (paramTypes[paramCounter].equals(double.class) || paramTypes[paramCounter].equals(Double.class)) { this.inputParamCount++; paramCounter++; } else { throw new IllegalArgumentException( "param number " + paramCounter + " must be of type double"); } } } // got through all optInputParameters and store them for later } else if (annotation instanceof OptInputParameterInfo) { OptInputParameterInfo optInputParameterInfo = (OptInputParameterInfo) annotation; if (optInputParameterInfo.type().equals(OptInputParameterType.TA_OptInput_IntegerRange)) { this.optInputParams.add(getConstant(validationContext, paramCounter, Integer.class)); } else if (optInputParameterInfo.type().equals(OptInputParameterType.TA_OptInput_RealRange)) { this.optInputParams.add(getConstant(validationContext, paramCounter, Double.class)); } else if (optInputParameterInfo.type().equals(OptInputParameterType.TA_OptInput_IntegerList)) { String value = (String) getConstant(validationContext, paramCounter, String.class); MAType type = MAType.valueOf(value); this.optInputParams.add(type); } paramCounter++; // to through all outputParameters and store them } else if (annotation instanceof OutputParameterInfo) { OutputParameterInfo outputParameterInfo = (OutputParameterInfo) annotation; String paramName = outputParameterInfo.paramName(); if (outputParameterInfo.type().equals(OutputParameterType.TA_Output_Real)) { this.outputParams.put(paramName, new double[1]); outputParamTypes.put(paramName.toLowerCase().substring(3), double.class); } else if (outputParameterInfo.type().equals(OutputParameterType.TA_Output_Integer)) { this.outputParams.put(outputParameterInfo.paramName(), new int[1]); outputParamTypes.put(paramName.toLowerCase().substring(3), int.class); } } } } // get unstable period int unstablePeriod = 0; if (paramTypes.length == paramCounter + 1) { unstablePeriod = (int) getConstant(validationContext, paramCounter, Integer.class); paramCounter++; } if (paramTypes.length > paramCounter) { throw new IllegalArgumentException("too many params, expected " + paramCounter + " or " + (paramCounter + 1) + " found " + paramTypes.length); } try { // get the dynamically created output class if (this.outputParams.size() > 1) { String className = StringUtils.capitalize(talibFunctionName); this.outputClass = getReturnClass(className, outputParamTypes); } // get the lookback size Object[] args = new Object[this.optInputParams.size()]; Class<?>[] argTypes = new Class[this.optInputParams.size()]; // supply all optInputParams int argCount = 0; for (Object object : this.optInputParams) { args[argCount] = object; Class<?> clazz = object.getClass(); Class<?> primitiveClass = ClassUtils.wrapperToPrimitive(clazz); if (primitiveClass != null) { argTypes[argCount] = primitiveClass; } else { argTypes[argCount] = clazz; } argCount++; } // set unstable period if (unstablePeriod > 0) { for (FuncUnstId value : FuncUnstId.values()) { this.core.SetUnstablePeriod(value, 50); } } // get and invoke the lookback method Method lookback = this.core.getClass().getMethod(talibFunctionName + "Lookback", argTypes); this.lookbackPeriod = (Integer) lookback.invoke(this.core, args) + 1; // create the fixed size Buffers for (int i = 0; i < this.inputParamCount; i++) { this.inputParams.add(new CircularFifoBuffer<>(this.lookbackPeriod)); } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.fiveamsolutions.nci.commons.search.OneCriterionSpecifiedCallback.java
private void processCollectionProperties(String[] fields, Collection<?> col, Class<? extends Object> fieldClass) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { for (String propName : fields) { // get the collection of values into a nice collection Method m2 = fieldClass.getMethod("get" + StringUtils.capitalize(propName)); for (Object collectionObj : col.toArray()) { Object val = m2.invoke(collectionObj); if (val != null) { if (isStringAndBlank(val)) { continue; }/* w ww .j a v a 2s. c om*/ hasOneCriterion = true; return; } } } }
From source file:com.activecq.api.helpers.WCMHelper.java
/** * Returns the HTML for creating DropTarget Edit Icon(s) for a specific * (named) DropTargets defined by a Component. * * Allows the developer to specific the EditType Icon to be used for the * Drop Target via editType parameter. If editType equals left null, the edit * type will be derived based on the DropTarget's Groups and Accepts * properties./*from w w w .ja v a 2 s . c o m*/ * * @param request * @param getName * @param editType * @param isConfigured will display edit block if evaluates to false * @return */ public static String getDDEditBlock(SlingHttpServletRequest request, String name, WCMEditType.Type editType, boolean... isConfigured) { if (!isAuthoringMode(request) || conditionAndCheck(isConfigured)) { return null; } final Resource resource = request.getResource(); final com.day.cq.wcm.api.components.Component component = WCMUtils.getComponent(resource); final String title = StringUtils.capitalize(component.getTitle()); String html = ""; ComponentEditConfig editConfig = component.getEditConfig(); Map<String, DropTarget> dropTargets = (editConfig != null) ? editConfig.getDropTargets() : null; if (dropTargets != null && !dropTargets.isEmpty()) { DropTarget dropTarget = null; // Find the named Drop Target for (String key : dropTargets.keySet()) { dropTarget = dropTargets.get(key); if (StringUtils.equals(name, dropTarget.getName())) { break; } else { dropTarget = null; } } if (dropTarget != null) { // If editType has not been specified then intelligently determine the best match editType = (editType == null) ? getWCMEditType(dropTarget) : editType; // Create the HTML img tag used for the edit icon html += "<img src=\"/libs/cq/ui/resources/0.gif\"" + " " + "class=\"" + dropTarget.getId() + " " + editType.getCssClass() + "\"" + " " + "alt=\"Drop Target: " + dropTarget.getName() + "\"" + " " + "title=\"Drop Target: " + dropTarget.getName() + "\"" + "/>"; } } return html; }
From source file:com.frameworkset.orm.engine.model.Column.java
/** * Returns the name for the setter method to set the value of this * column//ww w .j a v a 2 s . co m * * @return A setter method name for this column. * @since 3.2 */ public String getSetterName() { return "set" + StringUtils.capitalize(getJavaName()); }
From source file:com.yougou.api.service.impl.ApiServiceImpl.java
private void checkApiMethod(Api api) throws Exception { Class<?> clazz = Class.forName(api.getApiImplementor().getImplementorClass()); // ??//from www . j a v a2s. c om String[] strings = StringUtils.split(api.getApiMethod(), '.'); String methodName = strings[strings.length - 1]; for (int i = strings.length - 2; i > 0; i--) { methodName += StringUtils.capitalize(strings[i]); } // ? try { strings = StringUtils.split(api.getApiMethodParamTypes(), ','); Class<?>[] classes = new Class<?>[strings.length]; for (int i = 0; i < classes.length; i++) { classes[i] = Class.forName(strings[i]); } // ??? try { clazz.getMethod(methodName, classes); } catch (Exception e) { try { clazz.getMethod(methodName); } catch (Exception e2) { throw new UnsupportedOperationException("API[" + api.getApiMethod() + "]?"); } } } catch (ClassNotFoundException e) { throw new UnsupportedOperationException( "API?[" + api.getApiMethodParamTypes() + "]?"); } }