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:com.adobe.acs.commons.wcm.impl.ComponentHelperImpl.java
@SuppressWarnings("squid:S3776") public String getEditBlock(SlingHttpServletRequest request, ComponentEditType.Type editType, boolean... isConfigured) { final Resource resource = request.getResource(); final com.day.cq.wcm.api.components.Component component = WCMUtils.getComponent(resource); if (!isAuthoringMode(request) || conditionAndCheck(isConfigured)) { return null; } else if (ComponentEditType.NONE.equals(editType)) { return "<!-- Edit Mode Placeholder is specified as: " + editType.getName() + " -->"; }/*from ww w . j a v a2 s .co m*/ StringBuilder html = new StringBuilder("<div class=\"wcm-edit-mode " + CSS_EDIT_MODE + "\">"); if (component == null) { html.append(getCssStyle()); html.append("Could not resolve CQ Component type."); } else if (ComponentEditType.NOICON.equals(editType) || ComponentEditType.NONE.equals(editType)) { final String title = StringUtils.capitalize(component.getTitle()); html.append(getCssStyle()); html.append("<dl>"); html.append("<dt>" + title + " Component</dt>"); if (component.isEditable()) { html.append("<dd>Double click or Right click to Edit</dd>"); } if (component.isDesignable()) { html.append("<dd>Switch to Design mode and click the Edit button</dd>"); } if (!component.isEditable() && !component.isDesignable()) { html.append("<dd>The component cannot be directly authored</dd>"); } html.append("</dl>"); } else if (ComponentEditType.DROPTARGETS.equals(editType)) { // Use DropTargets ComponentEditConfig editConfig = component.getEditConfig(); Map<String, DropTarget> dropTargets = (editConfig != null) ? editConfig.getDropTargets() : null; if (dropTargets != null && !dropTargets.isEmpty()) { // Auto generate images with drop-targets for (final Map.Entry<String, DropTarget> entry : dropTargets.entrySet()) { final DropTarget dropTarget = entry.getValue(); html.append("<img src=\"/libs/cq/ui/resources/0.gif\" "); html.append("class=\"").append(dropTarget.getId()); html.append(" ").append(getWCMEditType(dropTarget).getCssClass()).append("\" "); html.append("alt=\"Drop Target: ").append(dropTarget.getName()).append("\" "); html.append("title=\"Drop Target: ").append(dropTarget.getName()).append("\"/>"); } } } else { final String title = StringUtils.capitalize(component.getTitle()); // Use specified EditType html.append("<img src=\"/libs/cq/ui/resources/0.gif\" "); html.append("class=\"").append(editType.getCssClass()).append("\" alt=\""); html.append(title).append("\" "); html.append("title=\"").append(title).append("\"/>"); } html.append("</div>"); return html.toString(); }
From source file:net.sf.firemox.xml.XmlConfiguration.java
/** * Return the method name corresponding to the specified TAG. * /*w w w. ja va 2s .co m*/ * @param tagName * @return the method name corresponding to the specified TAG. */ static XmlToMDB getXmlClass(String tagName, Map<String, XmlToMDB> instances, Class<?> nameSpaceCall) { if (!nameSpaceCall.getSimpleName().startsWith("Xml")) throw new InternalError("Caller should be an Xml class : " + nameSpaceCall); XmlToMDB nodeClass = instances.get(tagName); if (nodeClass != null) { return nodeClass; } String simpleClassName = StringUtils.capitalize(tagName.replaceAll("-", "")); String packageName = nameSpaceCall.getPackage().getName(); String namespace = nameSpaceCall.getSimpleName().substring(3).toLowerCase(); String className = packageName + "." + namespace + "." + simpleClassName; XmlToMDB result; try { result = (XmlToMDB) Class.forName(className).newInstance(); } catch (Throwable e) { Class<?> mdbClass = null; simpleClassName = WordUtils.capitalize(tagName.replaceAll("-", " ")).replaceAll(" ", ""); try { result = (XmlToMDB) Class.forName(packageName + "." + namespace + "." + simpleClassName) .newInstance(); } catch (Throwable e1) { try { className = StringUtils.chomp(packageName, ".xml") + "." + namespace + "." + simpleClassName; mdbClass = Class.forName(className); if (!mdbClass.isAnnotationPresent(XmlTestElement.class)) { result = (XmlToMDB) mdbClass.newInstance(); } else { result = getAnnotedBuilder(mdbClass, tagName, packageName, namespace); } } catch (Throwable ei2) { error("Unsupported " + namespace + " '" + tagName + "'"); result = DummyBuilder.instance(); } } } instances.put(tagName, result); return result; }
From source file:adalid.core.programmers.AbstractJavaProgrammer.java
@Override public String getJavaUpperVariableName(String name) { return StringUtils.capitalize(StrUtils.getCamelCase(name, true)); }
From source file:ch.systemsx.cisd.openbis.generic.shared.util.WebClientFilesUpdater.java
/** * Updates the <code>OpenBIS.gwt.xml</code> up to the technologies found. */// ww w . jav a2s.co m public final void updateOpenBISGwtXmlFile() { final File openBISGwtXmlFile = new File(workingDirectory, OPENBIS_PACKAGE_NAME + "/" + OPENBIS_GWT_XML_FILE_NAME); final String response = FileUtilities.checkFileFullyAccessible(openBISGwtXmlFile, "xml"); if (response != null) { throw new RuntimeException(response); } final StringBuilder builder = new StringBuilder(XML_MARKER_START); final String sep = "\n"; builder.append(sep); final String indent = StringUtils.repeat(" ", 4); boolean first = true; for (final String technology : technologies) { if (first == false) { builder.append(sep); } first = false; builder.append(indent); builder.append(String.format("<!-- %s plugin -->", StringUtils.capitalize(technology))); builder.append(sep); // <script>-tag builder.append(createTag(SCRIPT_TAG_TEMPLATE, indent, technology)); // <public>-tag builder.append(createTag(PUBLIC_TAG_TEMPLATE, indent, technology)); // <source>-tag builder.append(createTag(SOURCE_TAG_TEMPLATE, indent, technology)); } builder.append(indent); String content = FileUtilities.loadToString(openBISGwtXmlFile); content = content.substring(0, content.indexOf(XML_MARKER_START)) + builder.toString() + content.substring(content.indexOf(XML_MARKER_END), content.length()); FileUtilities.writeToFile(openBISGwtXmlFile, content); }
From source file:ml.shifu.shifu.util.ClassUtils.java
public static Method getDeclaredSetterWithNull(String name, Class<?> clazz) { return getFirstMethodWithName("set" + StringUtils.capitalize(name), clazz); }
From source file:it.eng.spagobi.meta.initializer.name.BusinessModelNamesInitializer.java
public void setColumnName(SimpleBusinessColumn businessColumn) { String baseName = StringUtils.capitalize(businessColumn.getPhysicalColumn().getName().replace("_", " ")); businessColumn.setName(baseName);// w w w .j ava 2 s . c o m }
From source file:ch.entwine.weblounge.taglib.content.PagePreviewTag.java
/** * Sets the preview type. The value needs to be one of * <ul>/*from www . ja va 2 s.co m*/ * <li><code>None</code> - All elements of the page's stage composer are * included</li> * <li><code>Elements</code> - Only elements of the given types are included</li> * <li><code>Endmarker</code> - All elements up until the appearance of the * stop marker are included</li> * <li><code>PagePreview - The page preview elements are included</code></li> * </ul> */ public void setType(String value) { if (StringUtils.isNotBlank(value)) stopMarker = Marker.valueOf(StringUtils.capitalize(value.toLowerCase())); }
From source file:ch.entwine.weblounge.kernel.site.SiteServlet.java
/** * Depending on whether a call to a jsp is made or not, delegates to the * jasper servlet with a controlled context class loader or tries to load the * requested file from the bundle as a static resource. * /*w ww . j ava 2 s . co m*/ * @see HttpServlet#service(HttpServletRequest, HttpServletResponse) */ @Override public void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { String filename = FilenameUtils.getName(request.getPathInfo()); // Don't allow listing the root directory? if (StringUtils.isBlank(filename)) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return; } // Check the requested format. In case of a JSP, this can either be // processed (default) or raw, in which case the file contents are // returned rather than Jasper's output of it. Format format = Format.Processed; String f = request.getParameter(PARAM_FORMAT); if (StringUtils.isNotBlank(f)) { try { format = Format.valueOf(StringUtils.capitalize(f.toLowerCase())); } catch (IllegalArgumentException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return; } } if (Format.Processed.equals(format) && filename.endsWith(".jsp")) { serviceJavaServerPage(request, response); } else { serviceResource(request, response); } }
From source file:com.aol.advertising.qiao.util.ContextUtils.java
public static void injectMethods(Object object, Map<String, PropertyValue> props) throws BeansException, ClassNotFoundException { resolvePropertyReferences(props);/*from www . ja v a2 s. c om*/ if (props != null) { for (String key : props.keySet()) { String mth_name = "set" + StringUtils.capitalize(key); PropertyValue pv = props.get(key); if (pv.getType() == Type.IS_VALUE) { String pv_value = pv.getValue(); if (!pv.isResolved()) { if (pv.getDefaultValue() == null) // not resolved + no default throw new ConfigurationException("value " + pv.getValue() + " not resolved"); pv_value = pv.getDefaultValue(); } Method mth = findMethod(object.getClass(), mth_name, pv.getDataType().getJavaClass()); if (mth != null) { ReflectionUtils.invokeMethod(mth, object, ContextUtils.stringToValueByType(pv_value, pv.getDataType())); } else { String err = String.format(ERR_METHOD_NOTFOUND, mth_name, pv.getDataType(), object.getClass().getSimpleName()); logger.error(err); throw new MethodNotFoundException(err); } } else { Method mth = findMethod(object.getClass(), mth_name, pv.getRefObject().getClass()); if (mth != null) { ReflectionUtils.invokeMethod(mth, object, pv.getRefObject()); } else { String err = String.format(ERR_METHOD_NOTFOUND, mth_name, pv.getRefObject().getClass().getSimpleName(), object.getClass().getSimpleName()); logger.error(err); throw new MethodNotFoundException(err); } } } } }
From source file:com.demigodsrpg.game.listener.AreaListener.java
private void handleClaimAreas(ClaimRoom area, Player player) { // Important info PlayerModel model = DGData.PLAYER_R.fromPlayer(player); Deity deity = area.getDeity();/*from www . jav a 2s . c o m*/ String endMessage = ChatColor.YELLOW + "You have chosen "; // Set the correct type (and potentially faction if the deity is a hero) switch (deity.getDeityType()) { case HERO: model.setHero(deity); endMessage += deity.getFactions().get(0).getColor() + deity.getName() + ChatColor.YELLOW + " as your parent Hero."; break; case GOD: model.setGod(deity); String color = ChatColor.WHITE.toString(); if (model.getHero().isPresent()) { color = model.getHero().get().getFactions().get(0).getColor(); } endMessage += color + deity.getName() + ChatColor.YELLOW + " as your parent God."; break; } // Send the appropriate messages player.sendMessage(endMessage); // Add starting aspects for (Aspect.Group group : deity.getAspectGroups()) { List<Aspect> inGroup = Groups.aspectsInGroup(group); for (Aspect aspect : inGroup) { // Hero aspect if (DeityType.HERO.equals(deity.getDeityType()) && Aspect.Tier.HERO.equals(aspect.getTier())) { model.giveHeroAspect(deity, aspect); player.sendMessage(ChatColor.YELLOW + StringUtils.capitalize(deity.getPronouns()[0]) + " has placed you in the " + deity.getFactions().get(0).getColor() + deity.getFactions().get(0).getName() + ChatColor.YELLOW + " faction."); break; } // God tier I aspect else if (DeityType.GOD.equals(deity.getDeityType()) && Aspect.Tier.I.equals(aspect.getTier())) { model.giveAspect(aspect); } } } // If there is a next location, teleport the player to it if (area.getNextLocation() != null) { player.teleport(area.getNextLocation()); } // Save the model DGData.PLAYER_R.register(model); }