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.backelite.sonarqube.objectivec.issues.oclint.OCLintRulesDefinition.java
private void loadRules(NewRepository repository) throws IOException { Reader reader = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream(RULES_FILE), CharEncoding.UTF_8)); final List<String> listLines = IOUtils.readLines(reader); String previousLine = null;/*from w w w . j a v a 2 s .c o m*/ Map<String, String> rule = new HashMap<String, String>(); boolean inDescription = false; for (String line : listLines) { if (isLineIgnored(line)) { inDescription = false; } else if (line.matches("[\\-]{4,}.*")) { LOGGER.debug("Rule found : {}", previousLine); // Remove the rule name from the description of the previous // rule if (rule.get("description") != null) { String description = rule.get("description").toString(); final int index = description.lastIndexOf(previousLine); if (index > 0) { rule.put("description", description.substring(0, index)); } } rule.clear(); rule.put("name", StringUtils.capitalize(previousLine)); rule.put("key", previousLine); } else if (line.matches("Summary:.*")) { inDescription = true; rule.put("description", line.substring(line.indexOf(':') + 1)); } else if (line.matches("Category:.*")) { inDescription = true; // Create rule when last filed found RulesDefinition.NewRule newRule = repository.createRule(rule.get("key").toString()); newRule.setName(rule.get("name").toString()); newRule.setSeverity(rule.get("severity").toString()); newRule.setHtmlDescription(rule.get("description").toString()); } else if (line.matches("Severity:.*")) { inDescription = false; final String severity = line.substring("Severity: ".length()); rule.put("severity", OCLintRuleSeverity.valueOfInt(Integer.valueOf(severity)).name()); } else { if (inDescription) { line = ruleDescriptionLink(line); String description = (String) rule.get("description"); rule.put("description", description + "<br>" + line); } } previousLine = line; } }
From source file:com.bstek.dorado.idesupport.initializer.ViewConfigRuleTemplateInitializer.java
public void initRuleTemplate(RuleTemplate ruleTemplate, InitializerContext initializerContext) throws Exception { RuleTemplateManager ruleTemplateManager = initializerContext.getRuleTemplateManager(); int sortFactor = 1000; RuleTemplate layoutHolderTemplate = ruleTemplateManager.getRuleTemplate("LayoutHolder"); for (LayoutTypeRegisterInfo registerInfo : layoutTypeRegistry.getRegisterInfos()) { String type = registerInfo.getType(); RuleTemplate layoutRuleTemplate = new RuleTemplate(StringUtils.capitalize(type) + "Layout"); layoutRuleTemplate.setNodeName(type); if (registerInfo.getClassType() != null) { layoutRuleTemplate.setType(registerInfo.getClassType().getName()); }/* www. j a va2 s .c o m*/ if (registerInfo.getClientTypes() != 0) { layoutRuleTemplate.setClientTypes(registerInfo.getClientTypes()); } layoutRuleTemplate.setSortFactor(++sortFactor); ruleTemplateManager.addRuleTemplate(layoutRuleTemplate); layoutHolderTemplate.addChild(new AutoChildTemplate(type, layoutRuleTemplate, null)); RuleTemplate layoutConstraintRuleTemplate = new RuleTemplate( StringUtils.capitalize(type) + "LayoutConstraint"); layoutConstraintRuleTemplate.setGlobal(true); if (registerInfo.getConstraintClassType() != null) { layoutConstraintRuleTemplate.setType(registerInfo.getConstraintClassType().getName()); } ruleTemplateManager.addRuleTemplate(layoutConstraintRuleTemplate); } sortFactor = 2000; List<RuleTemplate> componentRuleTemplates = new ArrayList<RuleTemplate>(); for (ComponentTypeRegisterInfo registerInfo : componentTypeRegistry.getRegisterInfos()) { boolean isAssembledComponent = registerInfo instanceof AssembledComponentTypeRegisterInfo; String name = registerInfo.getName(); Class<? extends Component> classType = registerInfo.getClassType(); boolean isNew = false; RuleTemplate componentRuleTemplate = ruleTemplateManager.getRuleTemplate(name); if (componentRuleTemplate == null) { componentRuleTemplate = new AutoRuleTemplate(name, (isAssembledComponent) ? null : classType.getName()); componentRuleTemplate.setLabel(name); componentRuleTemplate.setGlobal(true); componentRuleTemplate.setAutoInitialize(false); componentRuleTemplates.add(componentRuleTemplate); isNew = true; } if (!Control.class.isAssignableFrom(classType) && componentRuleTemplate.getClientTypes() == 0) { componentRuleTemplate.setClientTypes(DEFAULT_INVISIBLE_COMPONENT_CLIENT_TYPE); } componentRuleTemplate.setSortFactor(++sortFactor); componentRuleTemplate.setCategory(registerInfo.getCategory()); if (isAssembledComponent) { componentRuleTemplate.setScope("public"); componentRuleTemplate.setNodeName(name); AssembledComponentTypeRegisterInfo assembledComponentTypeRegisterInfo = (AssembledComponentTypeRegisterInfo) registerInfo; ComponentDefinition superComponentDefinition = assembledComponentTypeRegisterInfo .getSuperComponentDefinition(); if (superComponentDefinition != null) { String superRuleName = superComponentDefinition.getComponentType(); componentRuleTemplate .setParents(new RuleTemplate[] { ruleTemplateManager.getRuleTemplate(superRuleName) }); Map<String, VirtualPropertyDescriptor> virtualProperties = assembledComponentTypeRegisterInfo .getVirtualProperties(); if (virtualProperties != null) { for (VirtualPropertyDescriptor propertyDescriptor : virtualProperties.values()) { VirtualPropertyAvialableAt avialableAt = propertyDescriptor.getAvialableAt(); if (!VirtualPropertyAvialableAt.client.equals(avialableAt)) { PropertyTemplate propertyTemplate = new AutoPropertyTemplate( propertyDescriptor.getName()); if (propertyDescriptor.getType() != null) { propertyTemplate.setType(propertyDescriptor.getType().getName()); } propertyTemplate.setDefaultValue(propertyDescriptor.getDefaultValue()); if (StringUtils.isNotEmpty(propertyDescriptor.getReferenceComponentType())) { propertyTemplate.setReference(new LazyReferenceTemplate(ruleTemplateManager, propertyDescriptor.getReferenceComponentType(), "id")); } propertyTemplate.setHighlight(1); componentRuleTemplate.addProperty(propertyTemplate); } } } Map<String, VirtualEventDescriptor> virtualEvents = assembledComponentTypeRegisterInfo .getVirtualEvents(); if (virtualEvents != null) { for (VirtualEventDescriptor eventDescriptor : virtualEvents.values()) { ClientEvent event = new ClientEvent(); event.setName(eventDescriptor.getName()); componentRuleTemplate.addClientEvent(event); } } } else if (classType != null) { componentRuleTemplate.setType(classType.getName()); } } else if (classType != null) { componentRuleTemplate.setType(classType.getName()); } if (isNew) { ruleTemplateManager.addRuleTemplate(componentRuleTemplate); } } for (RuleTemplate componentRuleTemplate : componentRuleTemplates) { ruleTemplateBuilder.initRuleTemplate(initializerContext, componentRuleTemplate); } }
From source file:com.aliyun.openservices.odps.console.commands.DescribeInstanceCommand.java
@Override public void run() throws OdpsException, ODPSConsoleException { Odps odps = getCurrentOdps();/*from w ww .j av a 2s . c om*/ if (!(odps.instances().exists(projectName, instanceId))) { throw new ODPSConsoleException("Instance not found : " + instanceId); } Instance i = odps.instances().get(projectName, instanceId); PrintWriter out = new PrintWriter(System.out); out.printf("%-40s%-40s\n", "ID", i.getId()); out.printf("%-40s%-40s\n", "Owner", i.getOwner()); out.printf("%-40s%-40s\n", "StartTime", DATE_FORMAT.format(i.getStartTime())); if (i.getEndTime() != null) { out.printf("%-40s%-40s\n", "EndTime", DATE_FORMAT.format(i.getEndTime())); } out.printf("%-40s%-40s\n", "Status", i.getStatus()); for (Map.Entry<String, Instance.TaskStatus> entry : i.getTaskStatus().entrySet()) { out.printf("%-40s%-40s\n", entry.getKey(), StringUtils.capitalize(entry.getValue().getStatus().toString().toLowerCase())); } for (Task task : i.getTasks()) { out.printf("%-40s%-40s\n", "Query", task.getCommandText()); } out.flush(); }
From source file:ips1ap101.lib.core.control.UsuarioAutenticado.java
/** * Creates a new instance of UsuarioAutenticado *///from w w w. j a v a 2 s . c o m UsuarioAutenticado(String codigo) { this(); if (codigo != null) { setCodigoUsuario(codigo); setNombreUsuario(StringUtils.capitalize(codigo)); } setCredencialesUsuario(); }
From source file:info.magnolia.cms.util.ExceptionUtil.java
/** * Translates an exception class name to an english-readable idiom. Example: an instance of AccessDeniedException will be returned as "Access denied". *//*from w w w . jav a 2 s . c o m*/ public static String classNameToWords(Exception e) { return StringUtils.capitalize(StringUtils.removeEnd(e.getClass().getSimpleName(), "Exception") .replaceAll("[A-Z]", " $0").toLowerCase().trim()); }
From source file:be.selckin.ws.util.java2php.NameManager.java
public String getPhpClassName(QName qname) { return StringUtils.capitalize(qname.getLocalPart()); }
From source file:gov.va.med.pharmacy.peps.presentation.common.displaytag.DefaultHssfExportView.java
/** * doExport creates excel file for download * @param out OutputStream//from w ww. ja v a 2 s . co m * @see org.displaytag.export.BinaryExportView#doExport(java.io.OutputStream) * @throws IOException IOException * @throws JspException JspException */ public void doExport(OutputStream out) throws IOException, JspException { try { HSSFWorkbook wb = new HSSFWorkbook(); sheet = wb.createSheet("Table_Export"); int rowNum = 0; int colNum = 0; //Create a header row HSSFRow xlsRow = sheet.createRow(rowNum++); HSSFCellStyle headerStyle = wb.createCellStyle(); headerStyle.setFillPattern(HSSFCellStyle.FINE_DOTS); headerStyle.setFillBackgroundColor(HSSFColor.BLUE_GREY.index); HSSFFont bold = wb.createFont(); bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); bold.setColor(HSSFColor.WHITE.index); headerStyle.setFont(bold); Iterator iterator = this.model.getHeaderCellList().iterator(); while (iterator.hasNext()) { HeaderCell headerCell = (HeaderCell) iterator.next(); String columnHeader = headerCell.getTitle(); if (columnHeader == null) { columnHeader = StringUtils.capitalize(headerCell.getBeanPropertyName()); } HSSFCell cell = xlsRow.createCell(colNum++); cell.setCellValue(columnHeader); cell.setCellStyle(headerStyle); } RowIterator rowIterator = this.model.getRowIterator(this.exportFull); while (rowIterator.hasNext()) { Row row = rowIterator.next(); xlsRow = sheet.createRow(rowNum++); colNum = 0; // iterate on columns ColumnIterator columnIterator = row.getColumnIterator(this.model.getHeaderCellList()); while (columnIterator.hasNext()) { Column column = columnIterator.nextColumn(); Object value = column.getValue(this.decorated); HSSFCell cell = xlsRow.createCell(colNum++); if (value instanceof Number) { Number num = (Number) value; cell.setCellValue(num.doubleValue()); } else if (value instanceof Date) { cell.setCellValue((Date) value); } else if (value instanceof Calendar) { cell.setCellValue((Calendar) value); } else { cell.setCellValue(escapeColumnValue(value)); } } } wb.write(out); // new HssfTableWriter(wb).writeTable(this.model, "-1"); // wb.write(out); } catch (Exception e) { throw new HssfGenerationException(e); } }
From source file:au.org.ala.delta.ui.image.overlay.OverlayTextBuilder.java
public String getText(ImageOverlay overlay, Illustratable imageOwner) { String text = ""; boolean includeExtraText = false; switch (overlay.type) { case OverlayType.OLTEXT: // Use a literal text string includeExtraText = true;//from ww w . ja v a 2 s . c om break; case OverlayType.OLKEYWORD: // Use specified keyword(s) text = overlay.keywords; includeExtraText = true; break; case OverlayType.OLITEM: // Use name of the item if (!overlay.omitDescription()) { text = _itemFormatter.formatItemDescription((Item) imageOwner, overlay.includeComments() ? CommentStrippingMode.RETAIN : CommentStrippingMode.STRIP_ALL); } includeExtraText = true; break; case OverlayType.OLFEATURE: // Use name of the character if (!overlay.omitDescription()) { String description = _characterFormatter.formatCharacterDescription( (au.org.ala.delta.model.Character) imageOwner, overlay.includeComments() ? CommentStrippingMode.RETAIN : CommentStrippingMode.STRIP_ALL); text = StringUtils.capitalize(description); } includeExtraText = true; break; case OverlayType.OLSTATE: // Use name of the state (selectable) if (!overlay.omitDescription()) { text = _stateFormatter.formatState((MultiStateCharacter) imageOwner, overlay.stateId, overlay.includeComments() ? CommentStrippingMode.RETAIN : CommentStrippingMode.STRIP_ALL); // TODO convert from id to number inside slotfile code } includeExtraText = true; break; case OverlayType.OLVALUE: // Use specified values or ranges (selectable) if (!overlay.omitDescription()) { String value = overlay.getValueString(); String units = getUnits(imageOwner, overlay); if (StringUtils.isNotEmpty(units)) { value += " " + units; } text = value; } includeExtraText = true; break; case OverlayType.OLUNITS: // Use units (for numeric characters) if (!overlay.omitDescription()) { text = getUnits(imageOwner, overlay); } includeExtraText = true; break; case OverlayType.OLOK: // Create OK pushbutton text = _resources.getString("imageOverlay.okButton.text"); break; case OverlayType.OLCANCEL: // Create Cancel pushbutton text = _resources.getString("imageOverlay.cancelButton.text"); break; case OverlayType.OLNOTES: // Create Notes pushbutton (for character notes) text = _resources.getString("imageOverlay.notesButton.text"); break; case OverlayType.OLIMAGENOTES: // Create Notes pushbutton (for notes about the image) text = _resources.getString("imageOverlay.imageNotesButton.text"); break; case OverlayType.OLHEADING: // Using heading string for the data-set text = _imageSettings.getDatasetName(); case OverlayType.OLENTER: // Create edit box for data entry case OverlayType.OLCOMMENT: // Not a "real" overlay type, but used to // save comments addressed to images rather than overlays case OverlayType.OLBUTTONBLOCK: // Used only when modifying aligned push-buttons case OverlayType.OLHOTSPOT: // Not a "real" overlay type; used for convenience in editing case OverlayType.OLNONE: // Undefined; the remaining values MUST correspond with array OLKeywords. case OverlayType.OLSUBJECT: // Has text for menu entry case OverlayType.OLSOUND: // Has name of .WAV sound file break; default: text = ""; } if (includeExtraText) { if (StringUtils.isNotEmpty(text)) { text += " "; } text += overlay.overlayText; } return text; }
From source file:com.groupon.jenkins.buildsetup.GithubReposController.java
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException, InvocationTargetException, IllegalAccessException { String[] tokens = req.getRestOfPath().split("/"); String leadToken = tokens.length > 0 ? tokens[1] : null; GithubRepoAction repoAction = getRepoAction(leadToken); if (repoAction != null) { String methodToken = tokens.length > 1 ? tokens[2] : "index"; String methodName = "do" + StringUtils.capitalize(methodToken); Method method = ReflectionUtils.getPublicMethodNamed(repoAction.getClass(), methodName); method.invoke(repoAction, req, rsp); } else {/* w ww .j a va2 s . co m*/ String orgToken = req.getRestOfPath().replace("/", ""); req.getSession().setAttribute("setupOrg" + this.getCurrentGithubLogin(), orgToken); rsp.forwardToPreviousPage(req); } }
From source file:com.yahoo.bard.webservice.web.TableFullViewProcessor.java
/** * Method to provide grain level details(with metrics and dimensions) of the given logical table. * * @param logicalTable Logical Table at the grain level * @param grain Table grain/*w w w.j a v a 2 s. c o m*/ * @param uriInfo Uri information to construct the uri's * * @return logical table details at grain level with all the associated meta data */ @Override public TableGrainView formatTableGrain(LogicalTable logicalTable, String grain, UriInfo uriInfo) { TableGrainView resultRow = new TableGrainView(); resultRow.put("name", grain); resultRow.put("longName", StringUtils.capitalize(grain)); resultRow.put("description", "The " + logicalTable.getName() + " " + grain + " grain"); resultRow.put("retention", logicalTable.getRetention().toString()); resultRow.put("dimensions", DimensionsServlet.getDimensionListSummaryView(logicalTable.getDimensions(), uriInfo)); resultRow.put("metrics", MetricsServlet.getLogicalMetricListSummaryView(logicalTable.getLogicalMetrics(), uriInfo)); return resultRow; }