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.egov.wtms.application.service.ReportGenerationService.java

public Map<String, Object> setReglnConnCommonReportParameters(Map<String, Object> reportParams,
        WaterConnectionDetails waterConnectionDetails) {

    AssessmentDetails assessmentDetails = propertyExtnUtils.getAssessmentDetailsForFlag(
            waterConnectionDetails.getConnection().getPropertyIdentifier(),
            PropertyExternalService.FLAG_FULL_DETAILS, BasicPropertyStatus.ACTIVE);
    String[] doorno = assessmentDetails.getPropertyAddress().split(",");
    reportParams.put(DOORNO, doorno[0]);

    Iterator<OwnerName> iterator = null;
    if (!assessmentDetails.getOwnerNames().isEmpty())
        iterator = assessmentDetails.getOwnerNames().iterator();
    if (iterator != null && iterator.hasNext()) {
        reportParams.put("mobileNumber", assessmentDetails.getOwnerNames().iterator().next().getMobileNumber());
        reportParams.put(APPLICANT_NAME, WordUtils.capitalize(iterator.next().getOwnerName()));
    }//ww  w  . j  a v a  2s.  com
    Designation designation = designationService.getDesignationByName(DESG_COMM_NAME);
    if (designation != null) {
        List<Assignment> assignmentsList = assignmentService.getAllActiveAssignments(designation.getId());
        reportParams.put(COMMISSIONER_NAME,
                assignmentsList.isEmpty() ? EMPTY : assignmentsList.get(0).getEmployee().getName());
    }
    reportParams.put(CONSUMERNUMBER, waterConnectionDetails.getConnection().getConsumerCode());
    reportParams.put("applicationNumber", waterConnectionDetails.getApplicationNumber());
    reportParams.put(APPLICATION_TYPE, waterConnectionDetails.getApplicationType().getName());
    reportParams.put(DISTRICT, cityService.getDistrictName());
    String municipalityName = cityService.getMunicipalityName();
    reportParams.put(MUNICIPALITY_NAME, municipalityName);
    reportParams.put(CITY_NAME, municipalityName);
    reportParams.put("assessmentNumber", waterConnectionDetails.getConnection().getPropertyIdentifier());
    reportParams.put("date", toDefaultDateFormat(new Date()));
    reportParams.put(LOCALITY, assessmentDetails.getBoundaryDetails().getLocalityName());
    reportParams.put(ADDRESS, assessmentDetails.getPropertyAddress());
    reportParams.put("electionWard", assessmentDetails.getBoundaryDetails().getAdminWardName());
    reportParams.put("revenueWard", assessmentDetails.getBoundaryDetails().getWardName());
    reportParams.put(DONATION_CHARGES, BigDecimal.valueOf(waterConnectionDetails.getDonationCharges()));

    Map<String, String> resultMap = connectionDemandService.getMonthlyWaterChargesDue(waterConnectionDetails);
    BigDecimal waterCharges = BigDecimal.valueOf(Double.parseDouble(resultMap.get(WATER_CHARGES))) == null
            ? ZERO
            : BigDecimal.valueOf(Double.parseDouble(resultMap.get(WATER_CHARGES)));
    reportParams.put("waterCharges", waterCharges);
    reportParams.put(FROM_INSTALLMENT, resultMap.get(FROM_INSTALLMENT));
    reportParams.put(TO_INSTALLMENT, resultMap.get(TO_INSTALLMENT));
    reportParams.put("penaltyCharges",
            BigDecimal.valueOf(waterConnectionDetails.getDonationCharges()).divide(new BigDecimal(2)));

    BigDecimal totalCharges = BigDecimal.valueOf(waterConnectionDetails.getDonationCharges())
            .add(BigDecimal.valueOf(waterConnectionDetails.getDonationCharges()).divide(new BigDecimal(2)))
            .add(waterCharges);
    reportParams.put("totalCharges", totalCharges);
    reportParams.put("amountInWords", getTotalAmntInWords(totalCharges.doubleValue()));
    return reportParams;

}

From source file:org.egov.wtms.web.controller.application.EstimationNoticeController.java

private ResponseEntity<InputStreamResource> generateEstimationReport(
        WaterConnectionDetails waterConnectionDetails, HttpSession session) {
    ReportOutput reportOutput = new ReportOutput();
    if (waterConnectionDetails != null)
        if (waterConnectionDetails.getEstimationNoticeFileStoreId() != null) {
            File file = fileStoreService.fetch(waterConnectionDetails.getEstimationNoticeFileStoreId(),
                    FILESTORE_MODULECODE);
            reportOutput = new ReportOutput();
            try {
                reportOutput.setReportName(waterConnectionDetails.getEstimationNumber());
                reportOutput.setReportOutputData(FileUtils.readFileToByteArray(file));
                reportOutput.setReportFormat(ReportFormat.PDF);
            } catch (IOException e) {
                throw new ApplicationRuntimeException("Exception in generating work order notice" + e);
            }/*w  w  w .  j a v  a2  s .co  m*/
        } else {

            Map<String, Object> reportParams = new HashMap<>();
            AssessmentDetails assessmentDetails = propertyExtnUtils.getAssessmentDetailsForFlag(
                    waterConnectionDetails.getConnection().getPropertyIdentifier(),
                    PropertyExternalService.FLAG_FULL_DETAILS, BasicPropertyStatus.ACTIVE);
            String[] doorNo = assessmentDetails.getPropertyAddress().split(",");
            StringBuilder ownerName = new StringBuilder();

            for (OwnerName names : assessmentDetails.getOwnerNames()) {
                if (assessmentDetails.getOwnerNames().size() > 1)
                    ownerName.append(", ");
                ownerName.append(names.getOwnerName());
            }

            reportParams.put("applicationType",
                    WordUtils.capitalize(waterConnectionDetails.getApplicationType().getName()));
            reportParams.put("cityName", session.getAttribute("citymunicipalityname"));
            reportParams.put("district", session.getAttribute("districtName"));
            reportParams.put("estimationNumber", waterConnectionDetails.getEstimationNumber());
            reportParams.put("donationCharges", waterConnectionDetails.getDonationCharges());
            FieldInspectionDetails inspectionDetails = waterConnectionDetails.getFieldInspectionDetails();
            reportParams.put("estimationDate", toDefaultDateFormat(inspectionDetails.getCreatedDate()));
            double totalCharges = waterConnectionDetails.getDonationCharges()
                    + inspectionDetails.getSupervisionCharges() + inspectionDetails.getRoadCuttingCharges()
                    + inspectionDetails.getSecurityDeposit();
            reportParams.put("totalCharges", totalCharges);
            reportParams.put("applicationDate",
                    toDefaultDateFormat(waterConnectionDetails.getApplicationDate()));
            reportParams.put("applicantName", ownerName.toString());
            reportParams.put("address", assessmentDetails.getPropertyAddress());
            reportParams.put("houseNo", doorNo[0]);
            reportParams.put("propertyID", waterConnectionDetails.getConnection().getPropertyIdentifier());
            reportParams.put("amountInWords", reportGenerationService.getTotalAmntInWords(totalCharges));
            reportParams.put("securityDeposit", inspectionDetails.getSecurityDeposit());
            reportParams.put("roadCuttingCharges", inspectionDetails.getRoadCuttingCharges());
            reportParams.put("superVisionCharges", inspectionDetails.getSupervisionCharges());
            if (waterConnectionDetails.getConnectionType().equals(NON_METERED)) {
                reportParams.put("estimationDetails", waterConnectionDetails.getEstimationDetails());
                reportParams.put("designation", waterConnectionDetails.getState().getOwnerPosition()
                        .getDeptDesig().getDesignation().getName());
                reportOutput = reportService
                        .createReport(new ReportRequest("wtr_estimation_notice_for_non_metered",
                                waterConnectionDetails.getEstimationDetails(), reportParams));
            } else {
                reportOutput = reportService.createReport(new ReportRequest(ESTIMATION_NOTICE,
                        waterConnectionDetails.getEstimationDetails(), reportParams));
            }

            reportOutput.setReportFormat(ReportFormat.PDF);
            reportOutput.setReportName(waterConnectionDetails.getEstimationNumber());
        }
    return reportAsResponseEntity(reportOutput);
}

From source file:org.egov.wtms.web.controller.application.MeterDemandNoticeController.java

/**
 * @param waterConnectionDetails/*w w  w . j a v  a2  s  .c  om*/
 * @param session
 * @param formatter
 * @param assessmentDetails
 * @param ownerName
 * @param billObj
 * @param meterReadingpriviousObj
 * @param monthName
 * @param yearName
 */
private Map<String, Object> prepareReportParams(final WaterConnectionDetails waterConnectionDetails,
        final HttpSession session, final AssessmentDetails assessmentDetails, final String ownerName,
        final EgBill billObj, final MeterReadingConnectionDetails meterReadingPreviousObj) {
    final Format formatterMonth = new SimpleDateFormat("MMMM");
    final Format formatterYear = new SimpleDateFormat("YYYY");
    DateTime dateTime = new DateTime();
    final String monthName;
    final String yearName;
    if (!waterConnectionDetails.getMeterConnection().isEmpty()) {
        final Date currentReadingDate = waterConnectionDetails.getMeterConnection().get(0)
                .getCurrentReadingDate();
        dateTime = new DateTime(currentReadingDate);
        if (dateTime != null) {
            final int currentMidday = dateTime.dayOfMonth().getMaximumValue() / 2;
            final DateTime currentMidDate = new DateTime(currentReadingDate).withDayOfMonth(currentMidday);
            if (currentReadingDate.before(currentMidDate.toDate()))
                dateTime = dateTime.minusMonths(1);
        }
    }
    monthName = formatterMonth.format(dateTime.toDate());
    yearName = formatterYear.format(dateTime.toDate());
    final Map<String, Object> reportParams = new HashMap<>();
    if (WaterTaxConstants.NEWCONNECTION.equalsIgnoreCase(waterConnectionDetails.getApplicationType().getCode())
            || WaterTaxConstants.ADDNLCONNECTION
                    .equalsIgnoreCase(waterConnectionDetails.getApplicationType().getCode()))
        reportParams.put("applicationType",
                WordUtils.capitalize(waterConnectionDetails.getApplicationType().getName()));

    reportParams.put("municipality", session.getAttribute("citymunicipalityname"));
    reportParams.put("district", session.getAttribute("districtName"));
    reportParams.put("waterCharges", waterConnectionDetails.getConnectionType().name());
    reportParams.put("propertyassesmentNumber", waterConnectionDetails.getConnection().getPropertyIdentifier());
    reportParams.put("consumerNumber", waterConnectionDetails.getConnection().getConsumerCode());
    reportParams.put("pipeSize", waterConnectionDetails.getPipeSize().getSizeInInch());
    reportParams.put("mterSerialNumber", waterConnectionDetails.getConnection().getMeterSerialNumber());
    reportParams.put("applicantName", ownerName);
    reportParams.put("demandNoticeNumber",
            billObj != null && billObj.getBillNo() != null ? billObj.getBillNo() : "");
    reportParams.put("billMonth", monthName + "-" + yearName);
    reportParams.put("demandNoticeDate", billObj == null || billObj.getCreateDate() == null ? null
            : toDefaultDateFormat(billObj.getCreateDate()));
    reportParams.put("previousReading", meterReadingPreviousObj.getCurrentReading());
    if (meterReadingPreviousObj.getCurrentReadingDate() == null)
        reportParams.put("previousReadingDate", "");
    else
        reportParams.put("previousReadingDate",
                toDefaultDateFormat(meterReadingPreviousObj.getCurrentReadingDate()));

    reportParams.put("currentReading", waterConnectionDetails.getMeterConnection().get(0).getCurrentReading());
    reportParams.put("currrentReadingDate",
            toDefaultDateFormat(waterConnectionDetails.getMeterConnection().get(0).getCurrentReadingDate()));
    if (meterReadingPreviousObj.getCurrentReading() != null
            && !waterConnectionDetails.getMeterConnection().isEmpty()
            && waterConnectionDetails.getMeterConnection().get(0).getCurrentReading() != null)
        reportParams.put("noofunitsconsume",
                waterConnectionDetails.getMeterConnection().get(0).getCurrentReading()
                        - meterReadingPreviousObj.getCurrentReading());
    reportParams.put("totalBilltoCollect",
            waterConnectionDetailsService.getTotalAmount(waterConnectionDetails));
    reportParams.put("currentMonthCharges",
            getCurrentMonthDemandAmount(waterConnectionDetails, dateTime.toDate()));
    reportParams.put("totalDueAmount", getTotalDue(waterConnectionDetails, dateTime.toDate()));

    reportParams.put("address", assessmentDetails.getPropertyAddress());
    return reportParams;
}

From source file:org.eodsteven.CrafterNexus.CrafterNexus.java

public void startGame() {
    for (Player p : Bukkit.getOnlinePlayers()) {
        for (Player pp : Bukkit.getOnlinePlayers()) {
            p.showPlayer(pp);//from  w w  w  .j  a v  a  2  s . c  om
            pp.showPlayer(p);
        }
    }

    Bukkit.getPluginManager().callEvent(new GameStartEvent(maps.getCurrentMap()));
    sb.scores.clear();

    for (OfflinePlayer score : sb.sb.getPlayers())
        sb.sb.resetScores(score);

    sb.obj.setDisplayName(ChatColor.DARK_AQUA + "Map: " + WordUtils.capitalize(voting.getWinner()));

    for (GameTeam t : GameTeam.teams()) {
        sb.scores.put(t.name(), sb.obj
                .getScore(Bukkit.getOfflinePlayer(WordUtils.capitalize(t.name().toLowerCase() + " Nexus"))));
        sb.scores.get(t.name()).setScore(t.getNexus().getHealth());

        Team sbt = sb.sb.registerNewTeam(t.name() + "SB");
        sbt.addPlayer(Bukkit.getOfflinePlayer(
                WordUtils.capitalize(WordUtils.capitalize(t.name().toLowerCase() + " Nexus"))));
        sbt.setPrefix(t.color().toString());
    }

    sb.obj.setDisplayName(ChatColor.DARK_AQUA + "Map: " + WordUtils.capitalize(voting.getWinner()));

    for (Player p : getServer().getOnlinePlayers())
        if (PlayerMeta.getMeta(p).getTeam() != GameTeam.NONE)
            Util.sendPlayerToGame(p, this);

    sb.update();

    getServer().getScheduler().runTaskTimer(this, new Runnable() {
        @Override
        public void run() {
            for (Player p : getServer().getOnlinePlayers()) {
                if (PlayerMeta.getMeta(p).getKit() == Kit.SCOUT) {
                    PlayerMeta.getMeta(p).getKit().addScoutParticles(p);
                }
            }
        }
    }, 0L, 1200L);

    getServer().getScheduler().runTaskTimer(this, new Runnable() {
        @Override
        public void run() {
            for (GameTeam t : GameTeam.values()) {
                if (t != GameTeam.NONE && t.getNexus().isAlive()) {
                    Location nexus = t.getNexus().getLocation().clone();
                    nexus.add(0.5, 0, 0.5);
                    Util.ParticleEffect.PORTAL.getName();
                    Util.ParticleEffect.ENCHANTMENT_TABLE.getName();
                }
            }
        }
    }, 100L, 5L);
}

From source file:org.eodsteven.CrafterNexus.CrafterNexus.java

public void onSecond() {
    long time = timer.getTime();

    if (time == -5L) {

        String winner = voting.getWinner();
        voting.end();// www  .  j  a v a 2  s.com
        getServer().broadcastMessage(ChatColor.GOLD + "Voting is now closed!");
        maps.selectMap(winner);
        getServer().broadcastMessage(ChatColor.GREEN + WordUtils.capitalize(winner) + " was chosen!");
        loadMap(winner);

        for (Player p : Bukkit.getOnlinePlayers()) {
            p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 10, 1);
            p.playSound(p.getLocation(), Sound.ENDERDRAGON_GROWL, 10, 1);
        }
    }

    if (time <= -5L) {
        for (Player p : Bukkit.getOnlinePlayers()) {
            //p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 10, 1);
            //p.playSound(p.getLocation(), Sound.ENDERDRAGON_GROWL, 10, 1);
            p.playSound(p.getLocation(), Sound.NOTE_PLING, 10, 2F);
            p.playSound(p.getLocation(), Sound.NOTE_BASS_GUITAR, 10, 2F);
            p.playSound(p.getLocation(), Sound.NOTE_PIANO, 10, 2F);
        }
    }

    if (time == 0L)
        startGame();
}

From source file:org.gftp.FlickrDownload.Stats.java

public static Element generateStatsXml(Map<String, MediaStats> allStats) {
    Element topLevelStats = new Element("media_stats");

    for (String mediaType : allStats.keySet()) {
        MediaStats stats = allStats.get(mediaType);

        Element diskSpaceElement = new Element("disk_space");
        for (String type : stats.diskSpaceByFileType.keySet()) {
            diskSpaceElement.addContent(new Element("image").setAttribute("type", type)
                    .setText(String.valueOf(stats.diskSpaceByFileType.get(type))));
        }//from w ww.  j  a v a  2 s .co  m

        Element licensesElement = new Element("licenses");
        for (String type : stats.licenses.keySet()) {
            licensesElement.addContent(new Element("license").setAttribute("type", type)
                    .setText(String.valueOf(stats.licenses.get(type))));
        }

        Element duplicatesElement = new Element("duplicates");
        for (String md5sum : stats.md5sums.keySet()) {
            List<String> photoIds = stats.md5sums.get(md5sum);
            if (photoIds.size() <= 1)
                continue;

            Element dupEle = new Element("duplicate");
            for (String photoId : photoIds) {
                dupEle.addContent(new Element("photo_id").setText(photoId));
            }
            duplicatesElement.addContent(dupEle);
        }

        topLevelStats.addContent(new Element("media").setAttribute("type", WordUtils.capitalize(mediaType))
                .addContent(new Element("photo_counts").setAttribute("total", String.valueOf(stats.totalPhotos))
                        .setAttribute("additional_duplicate", String.valueOf(stats.duplicatePhotos))
                        .addContent(new Element("public").setText(String.valueOf(stats.publicPhotos)))
                        .addContent(new Element("private").setText(String.valueOf(stats.privatePhotos)))
                        .addContent(new Element("friendsOnly").setText(String.valueOf(stats.friendsOnlyPhotos)))
                        .addContent(new Element("familyOnly").setText(String.valueOf(stats.familyOnlyPhotos)))
                        .addContent(new Element("friendsAndFamily")
                                .setText(String.valueOf(stats.friendsAndFamilyPhotos))))
                .addContent(new Element("tagged")
                        .addContent(new Element("yes").setText(String.valueOf(stats.tagged)))
                        .addContent(new Element("no").setText(String.valueOf(stats.notTagged))))
                .addContent(new Element("geoTagged")
                        .addContent(new Element("yes").setText(String.valueOf(stats.geotagged)))
                        .addContent(new Element("no").setText(String.valueOf(stats.notGeotagged))))
                .addContent(diskSpaceElement).addContent(licensesElement).addContent(duplicatesElement));
    }
    return topLevelStats;
}

From source file:org.gitools.ui.app.analysis.htest.editor.AbstractHtestAnalysisEditor.java

@Override
protected void prepareContext(VelocityContext context) {

    T analysis = getModel();//from  w  ww.  ja v  a  2  s  . c o m

    IResourceLocator fileRef = analysis.getData().getLocator();

    context.put("dataFile", fileRef != null ? fileRef.getName() : "Not defined");

    ToolConfig testConfig = analysis.getTestConfig();
    if (!testConfig.get(TestFactory.TEST_NAME_PROPERTY).equals("")) {
        context.put("test", WordUtils.capitalize(testConfig.get(TestFactory.TEST_NAME_PROPERTY)));
        HashMap<String, Object> testAttributes = new HashMap<>();
        for (String key : testConfig.getConfiguration().keySet()) {
            if (!key.equals(TestFactory.TEST_NAME_PROPERTY)) {
                testAttributes.put(WordUtils.capitalize(key), WordUtils.capitalize(testConfig.get(key)));
            }
        }
        if (testAttributes.size() > 0) {
            context.put("testAttributes", testAttributes);
        }

    }

    CutoffCmp cmp = analysis.getBinaryCutoffCmp();
    String filterDesc = cmp == null ? "Not filtered"
            : "Binary cutoff filter for values " + cmp.getLongName() + " " + analysis.getBinaryCutoffValue();
    context.put("filterDesc", filterDesc);

    fileRef = analysis.getModuleMap().getLocator();

    context.put("modulesFile", fileRef != null ? fileRef.getName() : "Unknown");

    context.put("moduleMinSize", analysis.getMinModuleSize());
    int maxSize = analysis.getMaxModuleSize();
    context.put("moduleMaxSize", maxSize != Integer.MAX_VALUE ? maxSize : "No limit");

    if (analysis.getMtc().equals("bh")) {
        context.put("mtc", "Benjamini Hochberg FDR");
    } else if (analysis.getMtc().equals("bonferroni")) {
        context.put("mtc", "Bonferroni");
    }

    if (analysis.getResults() != null) {
        fileRef = analysis.getResults().getLocator();
        context.put("resultsFile", fileRef != null ? fileRef.getName() : "Not defined");
    }

    fileRef = analysis.getLocator();
    if (fileRef != null) {
        context.put("analysisLocation", fileRef.getURL());

        if (fileRef.isWritable()) {
            setSaveAllowed(true);
        }
    }

    if (analysis.getStartTime() != null) {
        context.put("startTime", analysis.getStartTime());
    }

    if (analysis.getElapsedTime() > 0) {
        context.put("elapsedTime", analysis.getElapsedTime());
    }

    super.prepareContext(context);
}

From source file:org.jboss.tools.openshift.common.core.utils.StringUtils.java

/**
 * Rudimentary implementation of humanizing a String
 * to a human readable form (e.g. Build Configs from buildConfigs)
 * @param string//from   w  w  w.  ja va 2  s.  co  m
 * @return
 */
public static String humanize(String value) {
    String[] parts = org.apache.commons.lang.StringUtils.splitByCharacterTypeCamelCase(value);
    String split = org.apache.commons.lang.StringUtils.join(parts, " ");
    return WordUtils.capitalize(split);
}

From source file:org.jdal.beans.PropertyUtils.java

public static String toHumanReadable(String propertyName) {
    String humanReadable = getPropertyName(propertyName).replaceAll("([A-Z])", " $1").trim();
    return WordUtils.capitalize(humanReadable);
}

From source file:org.kuali.rice.krad.keyvalues.EnumValuesFinder.java

/**
 * Derives a label value from an enum
 */
protected String getEnumLabel(Enum enm) {
    return WordUtils.capitalize(enm.name().toLowerCase());
}