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

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

Introduction

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

Prototype

public static String capitalizeFully(String str) 

Source Link

Document

Converts all the whitespace separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.

Usage

From source file:org.oep.cmon.portlet.hosotructiep.HoSoJSON.java

/**
 * This is function congDan//from w  w w . ja  v  a 2  s.  co  m
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param congDan
 * @return JSONObject
 */
public static JSONObject congDan(CongDan congDan) {
    JSONObject out = JSONFactoryUtil.createJSONObject();
    if (congDan != null) {
        out.put(HoSoFields.nguoiNopHoSoCongDanId, congDan.getCongDanId())
                .put(HoSoFields.hoTenNguoiNopHoSo, WordUtils.capitalizeFully(congDan.getHoTenDayDu()))
                .put(HoSoFields.ngaySinh, DateTimeUtil.getDayMonthYear(congDan.getNgaySinh()))
                .put(HoSoFields.gioiTinh, congDan.getGioiTinhId()).put(HoSoFields.soCMND, congDan.getSoCMND())
                .put(HoSoFields.dienThoaiCoDinh, congDan.getDienThoaiCoDinh())
                .put(HoSoFields.dienThoaiDiDong, congDan.getDienThoaiDiDong())
                .put(HoSoFields.email, congDan.getEmail())
                .put(HoSoFields.tinhThuongTruId, congDan.getTinhDiaChiId(true))
                .put(HoSoFields.huyenThuongTruId, congDan.getHuyenDiaChiId(true))
                .put(HoSoFields.xaThuongTruId, congDan.getXaDiaChiId(true))
                .put(HoSoFields.diaChiThuongTru, congDan.getDiaChiChiTiet())
                .put(HoSoFields.diaChiThuongTruDayDu, congDan.getDiaChiDayDu());
    }
    return out;
}

From source file:org.openhab.binding.astro.internal.bus.PlanetPublisher.java

/**
 * Publishes the item with the value, if the item is a OnOffType and the
 * value is a calendar, a job is scheduled.
 *//*from w  ww .  ja v a  2  s .co  m*/
private void publishValue(Item item, Object value, AstroBindingConfig bindingConfig) {
    if (value == null) {
        context.getEventPublisher().postUpdate(item.getName(), UnDefType.UNDEF);
    } else if (value instanceof Calendar) {
        Calendar calendar = (Calendar) value;
        if (bindingConfig.getOffset() != 0) {
            calendar = (Calendar) calendar.clone();
            calendar.add(Calendar.MINUTE, bindingConfig.getOffset());
        }

        if (item.getAcceptedDataTypes().contains(DateTimeType.class)) {
            context.getEventPublisher().postUpdate(item.getName(), new DateTimeType(calendar));
        } else if (item.getAcceptedCommandTypes().contains(OnOffType.class)) {
            context.getJobScheduler().scheduleItem(calendar, item.getName());
        } else {
            logger.warn("Unsupported type for item {}, only DateTimeType and OnOffType supported!",
                    item.getName());
        }
    } else if (value instanceof Number) {
        if (item.getAcceptedDataTypes().contains(DecimalType.class)) {
            BigDecimal decimalValue = new BigDecimal(value.toString()).setScale(2, RoundingMode.HALF_UP);
            context.getEventPublisher().postUpdate(item.getName(), new DecimalType(decimalValue));
        } else if (value instanceof Long && item.getAcceptedDataTypes().contains(StringType.class)
                && "duration".equals(bindingConfig.getProperty())) {
            // special case, transforming duration to minute:second string
            context.getEventPublisher().postUpdate(item.getName(),
                    new StringType(durationToString((Long) value)));
        } else {
            logger.warn("Unsupported type for item {}, only DecimalType supported!", item.getName());
        }
    } else if (value instanceof String || value instanceof Enum) {
        if (item.getAcceptedDataTypes().contains(StringType.class)) {
            if (value instanceof Enum) {
                String enumValue = WordUtils.capitalizeFully(StringUtils.replace(value.toString(), "_", " "));
                context.getEventPublisher().postUpdate(item.getName(), new StringType(enumValue));
            } else {
                context.getEventPublisher().postUpdate(item.getName(), new StringType(value.toString()));
            }
        } else {
            logger.warn("Unsupported type for item {}, only String supported!", item.getName());
        }

    } else {
        logger.warn("Unsupported value type {}", value.getClass().getSimpleName());
    }
}

From source file:org.openhab.binding.homematic.internal.type.HomematicTypeGeneratorImpl.java

@Override
public void generate(HmDevice device) {
    if (thingTypeProvider != null) {
        ThingTypeUID thingTypeUID = UidUtils.generateThingTypeUID(device);
        ThingType tt = thingTypeProvider.getThingType(thingTypeUID, Locale.getDefault());
        if (tt == null || device.isGatewayExtras()) {
            logger.debug("Generating ThingType for device '{}' with {} datapoints", device.getType(),
                    device.getDatapointCount());

            List<ChannelGroupType> groupTypes = new ArrayList<ChannelGroupType>();
            for (HmChannel channel : device.getChannels()) {
                List<ChannelDefinition> channelDefinitions = new ArrayList<ChannelDefinition>();
                // generate channel
                for (HmDatapoint dp : channel.getDatapoints().values()) {
                    if (!isIgnoredDatapoint(dp) && dp.getParamsetType() == HmParamsetType.VALUES) {
                        ChannelTypeUID channelTypeUID = UidUtils.generateChannelTypeUID(dp);
                        ChannelType channelType = channelTypeProvider.getChannelType(channelTypeUID,
                                Locale.getDefault());
                        if (channelType == null) {
                            channelType = createChannelType(dp, channelTypeUID);
                            channelTypeProvider.addChannelType(channelType);
                        }/*from   w w  w .j  a  v  a 2  s  .  c om*/

                        ChannelDefinition channelDef = new ChannelDefinition(dp.getName(),
                                channelType.getUID());
                        channelDefinitions.add(channelDef);
                    }
                }

                // generate group
                ChannelGroupTypeUID groupTypeUID = UidUtils.generateChannelGroupTypeUID(channel);
                ChannelGroupType groupType = channelTypeProvider.getChannelGroupType(groupTypeUID,
                        Locale.getDefault());
                if (groupType == null || device.isGatewayExtras()) {
                    String groupLabel = String.format("%s",
                            WordUtils.capitalizeFully(StringUtils.replace(channel.getType(), "_", " ")));
                    groupType = new ChannelGroupType(groupTypeUID, false, groupLabel, null, null,
                            channelDefinitions);
                    channelTypeProvider.addChannelGroupType(groupType);
                    groupTypes.add(groupType);
                }

            }
            tt = createThingType(device, groupTypes);
            thingTypeProvider.addThingType(tt);
        }
        addFirmware(device);
    }
}

From source file:org.openhab.binding.homematic.type.HomematicTypeGeneratorImpl.java

/**
 * {@inheritDoc}/*w w w.  j  a  v a 2 s . co m*/
 */
@Override
public void generate(HmDevice device) {
    if (thingTypeProvider != null) {
        ThingTypeUID thingTypeUID = UidUtils.generateThingTypeUID(device);
        ThingType tt = thingTypeProvider.getThingType(thingTypeUID, Locale.getDefault());
        if (tt == null || device.isGatewayExtras()) {
            logger.debug("Generating ThingType for device '{}' with {} datapoints", device.getType(),
                    device.getDatapointCount());

            List<ChannelGroupType> groupTypes = new ArrayList<ChannelGroupType>();
            for (HmChannel channel : device.getChannels()) {
                List<ChannelDefinition> channelDefinitions = new ArrayList<ChannelDefinition>();
                // generate channel
                for (HmDatapoint dp : channel.getDatapoints().values()) {
                    if (!isIgnoredDatapoint(dp) && dp.getParamsetType() == HmParamsetType.VALUES) {
                        ChannelTypeUID channelTypeUID = UidUtils.generateChannelTypeUID(dp);
                        ChannelType channelType = channelTypeProvider.getChannelType(channelTypeUID,
                                Locale.getDefault());
                        if (channelType == null) {
                            channelType = createChannelType(dp, channelTypeUID);
                            channelTypeProvider.addChannelType(channelType);
                        }

                        ChannelDefinition channelDef = new ChannelDefinition(dp.getName(),
                                channelType.getUID());
                        channelDefinitions.add(channelDef);
                    }
                }

                // generate group
                ChannelGroupTypeUID groupTypeUID = UidUtils.generateChannelGroupTypeUID(channel);
                ChannelGroupType groupType = channelTypeProvider.getChannelGroupType(groupTypeUID,
                        Locale.getDefault());
                if (groupType == null || device.isGatewayExtras()) {
                    String groupLabel = String.format("%s",
                            WordUtils.capitalizeFully(StringUtils.replace(channel.getType(), "_", " ")));
                    groupType = new ChannelGroupType(groupTypeUID, false, groupLabel, null, channelDefinitions);
                    channelTypeProvider.addChannelGroupType(groupType);
                    groupTypes.add(groupType);
                }

            }
            tt = createThingType(device, groupTypes);
            thingTypeProvider.addThingType(tt);
        }
        addFirmware(device);
    }
}

From source file:org.openhab.binding.weather.internal.bus.WeatherPublisher.java

/**
 * Publishes the item with the value.//from   www. j  a  v a  2 s  . c  o m
 */
private void publishValue(String itemName, Object value, WeatherBindingConfig bindingConfig) {
    if (value == null) {
        context.getEventPublisher().postUpdate(itemName, UnDefType.UNDEF);
    } else if (value instanceof Calendar) {
        Calendar calendar = (Calendar) value;
        context.getEventPublisher().postUpdate(itemName, new DateTimeType(calendar));
    } else if (value instanceof Number) {
        context.getEventPublisher().postUpdate(itemName,
                new DecimalType(round(value.toString(), bindingConfig)));
    } else if (value instanceof String || value instanceof Enum) {
        if (value instanceof Enum) {
            String enumValue = WordUtils.capitalizeFully(StringUtils.replace(value.toString(), "_", " "));
            context.getEventPublisher().postUpdate(itemName, new StringType(enumValue));
        } else {
            context.getEventPublisher().postUpdate(itemName, new StringType(value.toString()));
        }
    } else {
        logger.warn("Unsupported value type {}", value.getClass().getSimpleName());
    }
}

From source file:org.openmrs.module.diagnosiscapturerwanda.util.DiagnosisUtil.java

public static List<AutoCompleteObj> convertToAutoCompleteObj(List<ConceptSearchResult> diagnosisConcepts) {

    List<AutoCompleteObj> ret = new ArrayList<AutoCompleteObj>();
    Locale currentLocale = Context.getLocale();
    if (diagnosisConcepts != null) {
        for (ConceptSearchResult c : diagnosisConcepts) {
            for (ConceptName cn : c.getConcept().getNames()) {
                AutoCompleteObj o = new AutoCompleteObj();
                o.setValue(c.getConcept().getConceptId());

                if (cn.getName().equals(c.getConcept().getDisplayString())) {
                    o.setLabel(WordUtils.capitalizeFully(cn.getName()));
                } else {
                    String label = WordUtils.capitalizeFully(WordUtils.capitalizeFully(cn.getName()))
                            + "<span class='otherHit'>  &rArr; "
                            + WordUtils.capitalizeFully(c.getConcept().getDisplayString()) + "</span>";
                    o.setLabel(label);//from  www.j a v a  2  s  .c  o  m
                }

                ret.add(o);
            }
        }
    }

    Collections.sort(ret, new Comparator<AutoCompleteObj>() {

        @Override
        public int compare(AutoCompleteObj o1, AutoCompleteObj o2) {
            return o1.getLabel().compareTo(o2.getLabel());
        }

    });
    return ret;
}

From source file:org.openmrs.module.diagnosiscapturerwanda.util.DiagnosisUtil.java

/**
  * Auto generated method comment//  w  w  w .  jav a  2s  .com
  * 
  * @param findingsConcepts
  * @return
  */
public static List<AutoCompleteObj> convertConceptToAutoCompleteObj(List<Concept> findingsConcepts) {

    List<AutoCompleteObj> ret = new ArrayList<AutoCompleteObj>();
    Locale currentLocale = Context.getLocale();
    if (findingsConcepts != null) {
        for (Concept c : findingsConcepts) {
            for (ConceptName cn : c.getNames()) {
                AutoCompleteObj o = new AutoCompleteObj();
                o.setValue(c.getConceptId());

                if (cn.getName().equals(c.getDisplayString())) {
                    o.setLabel(WordUtils.capitalizeFully(cn.getName()));
                } else {
                    String label = WordUtils.capitalizeFully(cn.getName()) + "<span class='otherHit'>  &rArr; "
                            + WordUtils.capitalizeFully(c.getDisplayString()) + "</span>";
                    o.setLabel(label);
                }

                ret.add(o);
            }
        }
    }
    Collections.sort(ret, new Comparator<AutoCompleteObj>() {

        @Override
        public int compare(AutoCompleteObj o1, AutoCompleteObj o2) {
            return o1.getLabel().compareTo(o2.getLabel());
        }

    });
    return ret;
}

From source file:org.openmrs.module.diagnosiscapturerwanda.util.DiagnosisUtil.java

/**
  * Auto generated method comment/*from ww  w .  j  av  a  2s .c  o  m*/
  * 
  * @param v
  * @return
  */
public static List<VisitPOJO> getVisitPOJO(List<Visit> v) {

    List<VisitPOJO> visits = new ArrayList<VisitPOJO>();
    for (Visit visit : v) {
        VisitPOJO pojo = new VisitPOJO();
        pojo.setDate(visit.getStartDatetime());
        pojo.setLocation(visit.getLocation().getName());
        pojo.setPatient(visit.getPatient());
        pojo.setId(visit.getId());

        Set<Encounter> encounters = visit.getEncounters();
        Encounter diagnosis = null;
        for (Encounter e : encounters) {
            if (e.getEncounterType().equals(MetadataDictionary.ENCOUNTER_TYPE_DIAGNOSIS)) {
                diagnosis = e;
                break;
            }
        }

        if (diagnosis != null) {
            Map<EncounterRole, Set<Provider>> providers = diagnosis.getProvidersByRoles();
            for (EncounterRole er : providers.keySet()) {
                for (Provider p : providers.get(er)) {
                    pojo.setProvider(p.getName());
                }
            }

            for (Obs o : diagnosis.getAllObs()) {
                if (o.getConcept()
                        .equals(MetadataDictionary.CONCEPT_SET_PRIMARY_CARE_PRIMARY_DIAGNOSIS_CONSTRUCT)) {
                    for (Obs go : o.getGroupMembers()) {
                        if (go.getConcept().equals(MetadataDictionary.CONCEPT_PRIMARY_CARE_DIAGNOSIS)
                                && go.getValueCoded() != null) {
                            pojo.setDiagnosis(WordUtils.capitalizeFully(go.getValueCoded().getDisplayString()));
                            break;
                        }
                        if (go.getConcept().equals(MetadataDictionary.CONCEPT_DIAGNOSIS_NON_CODED)
                                && go.getValueText() != null && !go.getValueText().equals("")) {
                            pojo.setDiagnosis(go.getValueText());
                            break;
                        }
                    }
                }
            }
        }
        visits.add(pojo);
    }

    return visits;
}

From source file:org.openregistry.core.aspect.CapitalizationAspect.java

protected String doNormalCaseCapitalization(final String value) {
    return WordUtils.capitalizeFully(value);
}

From source file:org.openregistry.core.aspect.FirstNameAspect.java

@Around("set(@org.openregistry.core.domain.normalization.FirstName * *)")
public Object transformFieldValue(final ProceedingJoinPoint joinPoint) throws Throwable {
    final String value = (String) joinPoint.getArgs()[0];

    if (isDisabled() || value == null || value.isEmpty()) {
        return joinPoint.proceed();
    }/*  w ww  .  ja  v a  2 s.com*/

    final String overrideValue = getCustomMapping().get(value);

    if (overrideValue != null) {
        return joinPoint.proceed(new Object[] { overrideValue });
    }

    return joinPoint.proceed(new Object[] { WordUtils.capitalizeFully(value) });
}