Example usage for org.apache.commons.lang WordUtils capitalize

List of usage examples for org.apache.commons.lang WordUtils capitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang WordUtils capitalize.

Prototype

public static String capitalize(String str) 

Source Link

Document

Capitalizes all the whitespace separated words in a String.

Usage

From source file:org.codice.opendx.transform.rss.RSSInputTransformer.java

private List<ResolvedLocation> getResolvedLocationsForString(String string) {
    List<ResolvedLocation> resolvedLocations = null;
    try {//from  w w w  .j  ava2  s .  c o m
        resolvedLocations = geoParser.parse(WordUtils.capitalize(string));
    } catch (Exception e) {
        log.error(e);
    }
    return resolvedLocations;
}

From source file:org.eclipse.jubula.client.api.converter.utils.Utils.java

/**
 * Determines a valid Java class name for a given node
 * @param node the node//from w  w  w. j a  v a2  s  .  c om
 * @return the class name
 * @throws InvalidNodeNameException if a node name cannot be translated to a Java class name
 */
public static String determineClassName(IPersistentObject node) throws InvalidNodeNameException {
    String name = node.getName();
    name = removeInvalidCharacters(name);
    name = replaceUmlauts(name);
    name = WordUtils.capitalize(name);
    name = StringUtils.deleteWhitespace(name);
    name = name.replaceAll("^[0-9_]*", StringConstants.EMPTY); //$NON-NLS-1$
    if (!CLASS_NAME_PATTERN.matcher(name).matches()) {
        throw new InvalidNodeNameException();
    }
    return name;
}

From source file:org.eclipse.wb.internal.core.model.variable.NamesManager.java

/**
 * @return the basic name of variable (without prefix/suffix or uniqueness test) for given
 *         component and text, or <code>null</code> if no valid name can be generated.
 *///  ww w  .  j  a  va 2 s . com
private static String getNameForText(JavaInfo javaInfo, String text) {
    ComponentDescription description = javaInfo.getDescription();
    IPreferenceStore preferences = description.getToolkit().getPreferences();
    // prepare component class name for variable
    String classNameForVariable;
    {
        String qualifiedClassName = ReflectionUtils.getCanonicalName(description.getComponentClass());
        String shortClassName = CodeUtils.getShortClass(qualifiedClassName);
        classNameForVariable = StringUtilities.stripLeadingUppercaseChars(shortClassName, 1);
    }
    // prepare "text" part of template
    String textPart;
    {
        textPart = text.toLowerCase();
        textPart = WordUtils.capitalize(textPart);
        // remove HTML tags
        textPart = StringUtilities.stripHtml(textPart);
        // get first "wordsLimit" words to prevent too long identifiers
        {
            int wordsLimit = preferences.getInt(IPreferenceConstants.P_VARIABLE_TEXT_WORDS_LIMIT);
            if (wordsLimit > 0) {
                String[] strings = StringUtils.split(textPart);
                if (strings.length > wordsLimit) {
                    textPart = "";
                    for (int i = 0; i < wordsLimit; i++) {
                        textPart += strings[i];
                    }
                }
            }
        }
        // remove invalid characters
        textPart = StringUtilities.removeNonLatinCharacters(textPart);
        // is there any remaining symbol? :)
        if (textPart.length() == 0) {
            return null;
        }
    }
    // use template
    String name;
    {
        Map<String, String> valueMap = Maps.newTreeMap();
        {
            valueMap.put("class_name", classNameForVariable);
            valueMap.put("text", textPart);
            valueMap.put("default_name", getName(javaInfo));
            valueMap.put("class_acronym", getAcronym(javaInfo));
        }
        // use template
        String template = preferences.getString(IPreferenceConstants.P_VARIABLE_TEXT_TEMPLATE);
        name = StrSubstitutor.replace(template, valueMap);
    }
    // final modifications
    name = StringUtils.uncapitalize(name);
    return name;
}

From source file:org.eclipse.wb.internal.swing.FormLayout.gef.header.actions.SetTemplateAction.java

public SetTemplateAction(DimensionHeaderEditPart<T> header, FormDimensionTemplate template) {
    super(header, WordUtils.capitalize(template.getTitle()), template.getIcon(), AS_RADIO_BUTTON);
    m_template = template;/*from  w  ww. j a  v  a 2  s  .  co m*/
    setChecked(header.getDimension().isTemplate(template));
}

From source file:org.egov.adtax.service.notice.AdvertisementNoticeService.java

public ReportOutput generatePermitOrder(final AdvertisementPermitDetail advertisementPermitDetail,
        final Map<String, Object> ulbDetailsReportParams) {
    ReportRequest reportInput = null;//  w ww.ja v a2s .com
    if (null != advertisementPermitDetail) {
        final Map<String, Object> reportParams = buildParametersForReport(advertisementPermitDetail);
        reportParams.putAll(ulbDetailsReportParams);
        reportParams.put("advertisementtitle", WordUtils.capitalize(ADVERTISEMENTPERMITODERTITLE));

        reportInput = new ReportRequest(PERMITORDER, advertisementPermitDetail, reportParams);
        reportInput.setReportFormat(ReportFormat.PDF);
    }
    return reportService.createReport(reportInput);
}

From source file:org.egov.adtax.service.notice.AdvertisementNoticeService.java

private Map<String, Object> buildParametersForReport(
        final AdvertisementPermitDetail advertisementPermitDetail) {
    StringBuilder measurement = new StringBuilder();
    final Map<String, Object> reportParams = new HashMap<>();
    String notMentioned = "Not Mentioned ";

    reportParams.put("advertisementtitle", WordUtils.capitalize(ADVERTISEMENTDEMANDNOTICETITLE));

    reportParams.put("advertisementnumber",
            advertisementPermitDetail.getAdvertisement().getAdvertisementNumber());
    reportParams.put("permitNumber", advertisementPermitDetail.getPermissionNumber());
    reportParams.put("applicationNumber", advertisementPermitDetail.getApplicationNumber());

    if (advertisementPermitDetail.getAgency() != null
            && isNotBlank(advertisementPermitDetail.getOwnerDetail())) {
        reportParams.put(AGENCYNAME, advertisementPermitDetail.getAgency().getName() + "/"
                + advertisementPermitDetail.getOwnerDetail());
        reportParams.put(AGENCYADDRESS,//from  www  .  j  a v  a2  s . c  o m
                defaultIfBlank(advertisementPermitDetail.getAgency().getAddress(), notMentioned));
    } else if (advertisementPermitDetail.getAgency() != null
            && isBlank(advertisementPermitDetail.getOwnerDetail())) {
        reportParams.put(AGENCYNAME, advertisementPermitDetail.getAgency().getName());
        reportParams.put(AGENCYADDRESS,
                defaultIfBlank(advertisementPermitDetail.getAgency().getAddress(), notMentioned));
    } else {
        reportParams.put(AGENCYNAME, advertisementPermitDetail.getOwnerDetail());
        reportParams.put(AGENCYADDRESS, notMentioned);
    }

    reportParams.put("address", advertisementPermitDetail.getAdvertisement().getAddress());
    reportParams.put("applicationDate",
            getDefaultFormattedDate(advertisementPermitDetail.getApplicationDate()));
    reportParams.put("category", advertisementPermitDetail.getAdvertisement().getCategory().getName());
    reportParams.put("subjectMatter", advertisementPermitDetail.getAdvertisementParticular());
    reportParams.put("subCategory", advertisementPermitDetail.getAdvertisement().getSubCategory().getCode());
    buildMeasurementDetailsForJasper(advertisementPermitDetail, measurement, reportParams, notMentioned);

    reportParams.put("permitStartDate",
            getDefaultFormattedDate(advertisementPermitDetail.getPermissionstartdate()));
    reportParams.put("permitEndDate",
            getDefaultFormattedDate(advertisementPermitDetail.getPermissionenddate()));
    reportParams.put("currdate", getDefaultFormattedDate(new Date()));
    reportParams.put("lastPaymentPaidYear",
            advertisementDemandService.getLastPaymentPaidFinYear(advertisementPermitDetail.getAdvertisement()));
    return reportParams;
}

From source file:org.egov.adtax.web.controller.reports.ReportController.java

private ResponseEntity<byte[]> generatePermitOrder(HttpServletRequest request,
        final AdvertisementPermitDetail advertisementPermitDetail, final HttpSession session,
        final String workFlowAction) {
    ReportRequest reportInput = null;/* www. j av  a2 s.  co m*/
    ReportOutput reportOutput = null;
    if (null != advertisementPermitDetail) {
        final Map<String, Object> reportParams = buildParametersForReport(request, advertisementPermitDetail);
        reportParams.put("advertisementtitle",
                WordUtils.capitalize(AdvertisementTaxConstants.ADVERTISEMENTPERMITODERTITLE));

        reportInput = new ReportRequest(AdvertisementTaxConstants.PERMITORDER, advertisementPermitDetail,
                reportParams);
    }
    final HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.parseMediaType("application/pdf"));
    headers.add("content-disposition", "inline;filename=Permit Order.pdf");
    reportOutput = reportService.createReport(reportInput);
    return new ResponseEntity<byte[]>(reportOutput.getReportOutputData(), headers, HttpStatus.CREATED);
}

From source file:org.egov.adtax.web.controller.reports.ReportController.java

private Map<String, Object> buildParametersForReport(HttpServletRequest request,
        final AdvertisementPermitDetail advertisementPermitDetail) {
    StringBuffer measurement = new StringBuffer();
    final Map<String, Object> reportParams = new HashMap<String, Object>();
    String NOTMENTIONED = "Not Mentioned ";

    final String url = WebUtils.extractRequestDomainURL(request, false);
    final String cityLogo = url.concat(AdvertisementTaxConstants.IMAGE_CONTEXT_PATH)
            .concat((String) request.getSession().getAttribute("citylogo"));
    final String cityName = request.getSession().getAttribute("citymunicipalityname").toString();
    reportParams.put("logoPath", cityLogo);
    reportParams.put("cityName", cityName);
    reportParams.put("advertisementtitle",
            WordUtils.capitalize(AdvertisementTaxConstants.ADVERTISEMENTDEMANDNOTICETITLE));

    final SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    //   reportParams.put("workFlowAction", workFlowAction);
    reportParams.put("advertisementnumber",
            advertisementPermitDetail.getAdvertisement().getAdvertisementNumber());
    reportParams.put("permitNumber", advertisementPermitDetail.getPermissionNumber());
    reportParams.put("applicationNumber", advertisementPermitDetail.getApplicationNumber());

    if (advertisementPermitDetail.getAgency() != null
            && org.apache.commons.lang.StringUtils.isNotBlank(advertisementPermitDetail.getOwnerDetail())) {
        reportParams.put("agencyname", advertisementPermitDetail.getAgency().getName() + "/"
                + advertisementPermitDetail.getOwnerDetail());
        reportParams.put("agencyaddress", advertisementPermitDetail.getAgency().getAddress());
    } else if (advertisementPermitDetail.getAgency() != null
            && org.apache.commons.lang.StringUtils.isBlank(advertisementPermitDetail.getOwnerDetail())) {
        reportParams.put("agencyname", advertisementPermitDetail.getAgency().getName());
        reportParams.put("agencyaddress", advertisementPermitDetail.getAgency().getAddress());
    } else {/*from  www  . j a  v a  2s.  co m*/
        reportParams.put("agencyname", advertisementPermitDetail.getOwnerDetail());
        reportParams.put("agencyaddress", NOTMENTIONED);
    }

    reportParams.put("address", advertisementPermitDetail.getAdvertisement().getAddress());
    reportParams.put("applicationDate", formatter.format(advertisementPermitDetail.getApplicationDate()));
    reportParams.put("category", advertisementPermitDetail.getAdvertisement().getCategory().getName());
    reportParams.put("subjectMatter", advertisementPermitDetail.getAdvertisementParticular());
    buildMeasurementDetailsForJasper(advertisementPermitDetail, measurement, reportParams, NOTMENTIONED);

    reportParams.put("permitStartDate", formatter.format(advertisementPermitDetail.getPermissionstartdate()));
    reportParams.put("permitEndDate", formatter.format(advertisementPermitDetail.getPermissionenddate()));
    reportParams.put("currdate", formatter.format(new Date()));
    return reportParams;
}

From source file:org.egov.council.service.CouncilReportService.java

private Map<String, Object> buildReportParameters(final CouncilMeeting councilMeeting) {

    final StringBuilder meetingDateTimeLocation = new StringBuilder();
    final Map<String, Object> reportParams = new HashMap<>();
    reportParams.put("logoPath", cityService.getCityLogoURL());
    reportParams.put("commiteeType", WordUtils.capitalize(councilMeeting.getCommitteeType().getName()));
    reportParams.put("meetingNumber", WordUtils.capitalize(councilMeeting.getMeetingNumber()));
    meetingDateTimeLocation.append(DateUtils.getDefaultFormattedDate(councilMeeting.getMeetingDate()));
    if (null != councilMeeting.getMeetingTime()) {
        meetingDateTimeLocation.append(' ');
        meetingDateTimeLocation.append(councilMeeting.getMeetingTime());
    }//from  w  w  w.  j a  v  a 2s .  com
    if (null != councilMeeting.getMeetingLocation()) {
        meetingDateTimeLocation.append(' ');
        meetingDateTimeLocation.append(councilMeeting.getMeetingLocation());
    }
    reportParams.put("meetingDate",
            councilMeeting.getMeetingDate().toString() != null ? councilMeeting.getMeetingDate().toString()
                    : " ");
    reportParams.put("meetingTime",
            councilMeeting.getMeetingTime() != null ? councilMeeting.getMeetingTime() : " ");
    reportParams.put("meetingPlace",
            councilMeeting.getMeetingLocation() != null ? councilMeeting.getMeetingLocation() : " ");
    reportParams.put("meetingDateTimePlace", meetingDateTimeLocation.toString());
    reportParams.put("cityName", ReportUtil.getCityName());
    return reportParams;
}

From source file:org.egov.stms.notice.service.SewerageNoticeService.java

public ReportOutput generateReportOutputDataForEstimation(
        final SewerageApplicationDetails sewerageApplicationDetails) {
    ReportRequest reportInput = null;//from   w ww. java2  s . c  o  m
    final Map<String, Object> reportParams = new HashMap<>();
    if (sewerageApplicationDetails != null) {
        final AssessmentDetails assessmentDetails = sewerageTaxUtils.getAssessmentDetailsForFlag(
                sewerageApplicationDetails.getConnectionDetail().getPropertyIdentifier(),
                PropertyExternalService.FLAG_FULL_DETAILS);
        String[] doorNo = null;
        if (null != assessmentDetails.getPropertyAddress())
            doorNo = assessmentDetails.getPropertyAddress().split(",");
        String ownerName = "";
        if (null != assessmentDetails.getOwnerNames())
            for (final OwnerName names : assessmentDetails.getOwnerNames()) {
                ownerName = names.getOwnerName();
                break;
            }

        if (sewerageApplicationDetails.getApplicationType() != null)
            reportParams.put(APPLICATION_TYPE,
                    WordUtils.capitalize(sewerageApplicationDetails.getApplicationType().getName()));
        reportParams.put("cityName", cityService.getMunicipalityName());
        reportParams.put(DISTRICT, cityService.getDistrictName());
        reportParams.put("estimationDate",
                getDefaultFormattedDate(sewerageApplicationDetails.getApplicationDate()));
        reportParams.put("cityLogo", cityService.getCityLogoURL());
        reportParams.put("estimationNumber", sewerageApplicationDetails.getEstimationNumber());
        reportParams.put(ASSESSMENT_NO,
                sewerageApplicationDetails.getConnectionDetail().getPropertyIdentifier());
        if (sewerageApplicationDetails.getCurrentDemand() != null)
            for (final EgDemandDetails egDmdDetails : sewerageApplicationDetails.getCurrentDemand()
                    .getEgDemandDetails())
                if (egDmdDetails.getEgDemandReason().getEgDemandReasonMaster().getCode()
                        .equalsIgnoreCase(SewerageTaxConstants.FEES_DONATIONCHARGE_CODE))
                    donationCharges = egDmdDetails.getAmount().subtract(egDmdDetails.getAmtCollected());
        // TODO: CHECK THIS LOGIC AGAIN. IF FEE TYPE IS ESTIMATION FEES,
        // THEN WE NEED TO GROUP ALL FEESES.
        for (final SewerageConnectionFee scf : sewerageApplicationDetails.getConnectionFees()) {
            if (scf.getFeesDetail().getCode()
                    .equalsIgnoreCase(SewerageTaxConstants.FEES_ESTIMATIONCHARGES_CODE))
                estimationCharges = BigDecimal.valueOf(scf.getAmount());
            if (scf.getFeesDetail().getCode().equalsIgnoreCase(SewerageTaxConstants.FEES_SEWERAGETAX_CODE))
                sewerageCharges = BigDecimal.valueOf(scf.getAmount());
        }
        final BigDecimal totalCharges = estimationCharges.add(donationCharges).add(sewerageCharges);
        reportParams.put(ESTIMATION_CHARGES, estimationCharges);
        reportParams.put(DONATION_CHARGES, donationCharges);
        reportParams.put("sewerageCharges", sewerageCharges);
        reportParams.put(TOTAL_CHARGES, totalCharges);
        reportParams.put("amountInWords",
                getTotalAmountInWords(totalCharges.setScale(2, BigDecimal.ROUND_HALF_EVEN)));
        reportParams.put(APPLICATION_DATE,
                getDefaultFormattedDate(sewerageApplicationDetails.getApplicationDate()));
        reportParams.put("applicantName", ownerName);
        reportParams.put(ADDRESS, assessmentDetails.getPropertyAddress());
        reportParams.put("inspectionDetails",
                sewerageApplicationDetails.getFieldInspections().get(0).getFieldInspectionDetails());
        reportParams.put("estimationDetails", sewerageApplicationDetails.getEstimationDetails());
        reportParams.put("houseNo", doorNo != null ? doorNo[0] : "");
        reportInput = new ReportRequest(ESTIMATION_NOTICE, sewerageApplicationDetails, reportParams);
    }
    return reportService.createReport(reportInput);
}