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.jahia.ajax.gwt.utils.GWTInitializer.java

public static String generateInitializerStructure(HttpServletRequest request, HttpSession session,
        Locale locale, Locale uilocale) {
    StringBuilder buf = new StringBuilder();
    JahiaUser user = (JahiaUser) session.getAttribute(Constants.SESSION_USER);
    if (uilocale == null) {
        Locale sessionLocale = (Locale) session.getAttribute(Constants.SESSION_UI_LOCALE);
        JCRUserNode userNode = null;/*from   ww  w  . j av  a 2 s  .c om*/
        if (user != null) {
            userNode = JahiaUserManagerService.getInstance().lookupUserByPath(user.getLocalPath());
        }
        uilocale = sessionLocale != null ? UserPreferencesHelper.getPreferredLocale(userNode, sessionLocale)
                : UserPreferencesHelper.getPreferredLocale(userNode,
                        LanguageCodeConverters.resolveLocaleForGuest(request));
    }
    if (locale == null) {
        String language = request.getParameter("lang");
        if (!StringUtils.isEmpty(language)) {
            locale = LanguageCodeConverters.getLocaleFromCode(language);
        }
        if (locale == null) {
            locale = (Locale) session.getAttribute(Constants.SESSION_LOCALE);
        }
        if (locale == null) {
            locale = Locale.ENGLISH;
        }
    }

    buf.append("<meta name=\"gwt:property\" content=\"locale=")
            .append(StringEscapeUtils.escapeXml(uilocale.toString())).append("\"/>");
    addCss(buf, request, false);

    // creat parameters map
    Map<String, String> params = new HashMap<String, String>();

    RenderContext renderContext = (RenderContext) request.getAttribute("renderContext");

    String serviceEntrypoint = buildServiceBaseEntrypointUrl(request);
    params.put(JahiaGWTParameters.SERVICE_ENTRY_POINT, serviceEntrypoint);
    String contextPath = request.getContextPath();
    params.put(JahiaGWTParameters.CONTEXT_PATH, contextPath);
    params.put(JahiaGWTParameters.SERVLET_PATH,
            (request.getAttribute("servletPath") == null) ? request.getServletPath()
                    : (String) request.getAttribute("servletPath"));
    params.put(JahiaGWTParameters.PATH_INFO, request.getPathInfo());
    params.put(JahiaGWTParameters.QUERY_STRING, request.getQueryString());
    boolean devMode = SettingsBean.getInstance().isDevelopmentMode();
    params.put(JahiaGWTParameters.DEVELOPMENT_MODE, devMode ? "true" : "false");
    boolean areaAutoActivated = SettingsBean.getInstance().isAreaAutoActivated();
    params.put(JahiaGWTParameters.AREA_AUTO_ACTIVATED, areaAutoActivated ? "true" : "false");

    if (devMode) {
        params.put(JahiaGWTParameters.MODULES_SOURCES_DISK_PATH,
                StringEscapeUtils.escapeJavaScript(SettingsBean.getInstance().getModulesSourcesDiskPath()));
    }
    if (user != null) {
        String name = user.getUsername();
        int index = name.indexOf(":");
        if (index > 0) {
            String displayname = name.substring(0, index);
            params.put(JahiaGWTParameters.CURRENT_USER_NAME, displayname);
        } else {
            params.put(JahiaGWTParameters.CURRENT_USER_NAME, name);
        }
        params.put(JahiaGWTParameters.CURRENT_USER_PATH, user.getLocalPath());
    } else {
        params.put(JahiaGWTParameters.CURRENT_USER_NAME, "guest");
        params.put(JahiaGWTParameters.CURRENT_USER_PATH, "/users/guest");
    }

    params.put(JahiaGWTParameters.LANGUAGE, locale.toString());
    params.put(JahiaGWTParameters.LANGUAGE_DISPLAY_NAME,
            WordUtils.capitalizeFully(locale.getDisplayName(locale)));
    params.put(JahiaGWTParameters.UI_LANGUAGE, uilocale.toString());
    params.put(JahiaGWTParameters.UI_LANGUAGE_DISPLAY_NAME,
            WordUtils.capitalizeFully(uilocale.getDisplayName(uilocale)));
    try {
        if (renderContext != null) {
            params.put(JahiaGWTParameters.WORKSPACE, renderContext.getMainResource().getWorkspace());

            if (renderContext.getSite() != null) {
                params.put(JahiaGWTParameters.SITE_UUID, renderContext.getSite().getIdentifier());
                params.put(JahiaGWTParameters.SITE_KEY, renderContext.getSite().getSiteKey());
            }
        } else {
            if (request.getParameter("site") != null) {
                params.put(JahiaGWTParameters.SITE_UUID,
                        StringEscapeUtils.escapeXml(request.getParameter("site")));
            }
            if (request.getParameter("workspace") != null) {
                params.put(JahiaGWTParameters.WORKSPACE, request.getParameter("workspace"));
            } else {
                params.put(JahiaGWTParameters.WORKSPACE, "default");
            }
        }
    } catch (RepositoryException e) {
        logger.error("Error when getting site id", e);
    }

    // put live workspace url
    if (request.getAttribute("url") != null) {
        URLGenerator url = (URLGenerator) request.getAttribute("url");
        params.put(JahiaGWTParameters.BASE_URL, url.getContext() + url.getBase());
        params.put(JahiaGWTParameters.STUDIO_URL, url.getContext() + url.getStudio());
        params.put(JahiaGWTParameters.STUDIO_VISUAL_URL, url.getContext() + url.getStudioVisual());
        addLanguageSwitcherLinks(renderContext, params, url);
    } else {
        params.put(JahiaGWTParameters.BASE_URL, contextPath + Render.getRenderServletPath() + "/"
                + params.get("workspace") + "/" + locale.toString());
    }

    if (SettingsBean.getInstance().isUseWebsockets()) {
        params.put(JahiaGWTParameters.USE_WEBSOCKETS, "true");
    }

    String customCkeditorConfig = getCustomCKEditorConfig(request, renderContext);
    if (customCkeditorConfig != null) {
        params.put("ckeCfg", customCkeditorConfig);
    }

    // add jahia parameter dictionary
    buf.append("<script type=\"text/javascript\">\n");
    buf.append(getJahiaGWTConfig(params));
    buf.append("\n</script>\n");

    addJavaScript(buf, request, renderContext);

    return buf.toString();
}

From source file:org.jahia.taglibs.functions.Functions.java

public static java.lang.String displayLocaleNameWith(Locale localeToDisplay, Locale localeUsedForRendering) {
    return WordUtils.capitalizeFully(localeToDisplay.getDisplayName(localeUsedForRendering));
}

From source file:org.jahia.utils.LanguageCodeConverters.java

public static List<Locale> getAvailableBundleLocalesSorted() {
    Map<String, Locale> sortedLocales = new TreeMap<String, Locale>();
    for (Locale locale : getAvailableBundleLocales(ResourceBundles.JAHIA_INTERNAL_RESOURCES, null)) {
        sortedLocales.put(WordUtils.capitalizeFully(locale.getDisplayName(locale)), locale);
    }/*  w ww  . java  2s. c  om*/
    return new LinkedList<Locale>(sortedLocales.values());
}

From source file:org.kuali.kra.s2s.generator.impl.GlobalLibraryV2_0Generator.java

/**
 * Create a StateCodeDataType.Enum as defined in UniversalCodes 2.0 from the
 * given name of the state./*from   w  ww .  j a va2s  .  co  m*/
 * 
 * @param StateCode
 *            The state name
 * @return The StateCodeDataType type corresponding to the given State code.
 */
public StateCodeDataType.Enum getStateCodeDataType(String stateName) {
    StateCodeDataType.Enum stateCodeDataType = null;
    State state = s2sUtilService.getStateFromName(stateName);
    if (state != null) {
        StringBuilder stateDetail = new StringBuilder();
        stateDetail.append(state.getPostalStateCode());
        stateDetail.append(": ");
        stateDetail.append(WordUtils.capitalizeFully(state.getPostalStateName()));
        stateCodeDataType = StateCodeDataType.Enum.forString(stateDetail.toString());
    }
    return stateCodeDataType;
}

From source file:org.mule.devkit.generation.mule.studio.editor.MuleStudioUtils.java

public String formatCaption(String caption) {
    return WordUtils.capitalizeFully(caption);
}

From source file:org.neo4j.examples.imdb.parser.ImdbParser.java

public String parsePersonFile(BufferedReader fileReader, RelTypes batchName) throws IOException {

    if (fileReader == null) {
        throw new IllegalArgumentException("Null " + batchName + " file");
    }/* w w w.j a va2s. co  m*/
    String line = fileReader.readLine();
    String currentActor = null;
    String previousTitleForActor = null;
    final List<PersonData> buffer = new LinkedList<PersonData>();
    final List<RoleData> movies = new ArrayList<RoleData>();
    int movieCount = 0;
    ProgressCounter actorCount = new ProgressCounter(batchName.toString());
    while (line != null) {
        // get rid of blank lines
        if ("".equals(line)) {
            line = fileReader.readLine();
            continue;
        }
        int actorSep = line.indexOf('\t');
        if (actorSep >= 0) {
            String actor = line.substring(0, actorSep).trim();
            actor = WordUtils.capitalizeFully(actor); //There is an error in the source file where Cann, Nathan Maxwell is not capitalised
            if (actor != null && !"".equals(actor) && !actor.equals(currentActor)) {
                if (movies.size() > 0) {
                    buffer.add(new PersonData(currentActor, movies.toArray(new RoleData[movies.size()])));
                    actorCount.increment();
                    movies.clear();
                    previousTitleForActor = null;
                }
                currentActor = actor;
            }
            String title = line.substring(actorSep).trim();
            MovieFormat format = MovieFormat.FILM;

            //normalize title : remove episode name
            if (title.contains("{") && title.contains("}")) {
                int startEpisodeSep = title.indexOf("{");
                int endEpisodeSep = title.indexOf("}");
                title = title.substring(0, startEpisodeSep).trim()
                        + title.substring(endEpisodeSep + 1, title.length());
            }
            if (title.startsWith("\"")) {
                format = MovieFormat.SERIE;
                title = title.replace("\"", "");
            }

            if (title.length() == 0 || title.contains("{") || title.startsWith("\"")
                    || title.contains("????")) {
                line = fileReader.readLine();
                continue;
            }
            int characterStart = title.indexOf('[');
            int characterEnd = title.indexOf(']');
            String character = null;
            if (characterStart > 0 && characterEnd > characterStart) {
                character = title.substring(characterStart + 1, characterEnd);
            }
            int creditStart = title.indexOf('<');
            // int creditEnd = title.indexOf( '>' );
            // String credit = null;
            // if ( creditStart > 0 && creditEnd > creditStart )
            // {
            // credit = title.substring( creditStart + 1, creditEnd );
            // }
            if (characterStart > 0) {
                title = title.substring(0, characterStart).trim();
            } else if (creditStart > 0) {
                title = title.substring(0, creditStart).trim();
            }
            int spaces = title.indexOf("  ");
            if (spaces > 0) {
                if (title.charAt(spaces - 1) == ')' && title.charAt(spaces + 2) == '(') {
                    title = title.substring(0, spaces).trim();
                }
            }
            if (format == MovieFormat.SERIE) {
                title = title + " (SERIE)";
            }
            if (title.equals(previousTitleForActor)) {
                line = fileReader.readLine();
                continue;
            }
            previousTitleForActor = title;

            movies.add(new RoleData(title, batchName, character));
            movieCount++;
            if (movieCount % BUFFER_SIZE == 0) {
                reader.newPersons(buffer);
                buffer.clear();
            }
        }
        line = fileReader.readLine();
    }
    reader.newPersons(buffer);
    return (actorCount.getCount() + " " + batchName + " added including " + movieCount
            + " characters parsed and injected.");
}

From source file:org.obiba.onyx.quartz.editor.questionnaire.tree.QuestionnaireTreePanel.java

/**
 * Available when context menu will be OK
 *///w w w  . j  av  a  2 s  .c o  m
// protected class AddChildBehavior extends AbstractDefaultAjaxBehavior {
// @Override
// protected void respond(final AjaxRequestTarget target) {
// Request request = RequestCycle.get().getRequest();
// final String nodeId = request.getParameter("nodeId");
// String type = request.getParameter("type");
// log.info("Add " + type + " to " + nodeId);
//
// @SuppressWarnings("unchecked")
// final IModel<Questionnaire> questionnaireModel = (IModel<Questionnaire>)
// QuestionnaireTreePanel.this.getDefaultModel();
// final Questionnaire questionnaire = questionnaireModel.getObject();
// final TreeNode node = elements.get(nodeId);
// final QuestionnaireFinder questionnaireFinder = QuestionnaireFinder.getInstance(questionnaire);
// questionnaire.setQuestionnaireCache(null);
// if(node.isHasSection() && "section".equals(type)) {
// addSection(nodeId, node, questionnaireModel, questionnaireFinder, target);
// } else if(node.isSection() && "page".equals(type)) {
// addPage(nodeId, node, questionnaireModel, questionnaireFinder, target);
// } else if(node.isPage() && "question".equals(type)) {
// addQuestion(nodeId, node, questionnaireModel, questionnaireFinder, target);
// } else if("variable".equals(type)) {
// addVariable(nodeId, node, questionnaireModel, target);
// }
// }
// }

private JsonNode createNode(IQuestionnaireElement element) {
    NodeType nodeType = NodeType.get(element);
    String typeStr = WordUtils.capitalizeFully(nodeType.name());
    TreeNode treeNode = new TreeNode(element.getName(), nodeType);
    JsonNodeAttribute attr = new JsonNodeAttribute(addElement(treeNode), typeStr,
            typeStr + " " + element.getName());
    attr.setClazz("jstree-leaf");
    JsonNode newNode = new JsonNode();
    newNode.setData(new Data(treeNode.getName(),
            RequestCycle.get().urlFor(treeNode.getNodeType().getIcon()).toString()));
    newNode.setAttr(attr);
    return newNode;
}

From source file:org.obiba.onyx.quartz.editor.questionnaire.tree.QuestionnaireTreePanel.java

private JsonNode populateNode(IQuestionnaireElement element) {

    TreeNode treeNode = new TreeNode(element.getName(), NodeType.get(element));

    JsonNode jsonNode = new JsonNode();
    jsonNode.setData(new Data(treeNode.getName(),
            RequestCycle.get().urlFor(treeNode.getNodeType().getIcon()).toString()));
    String type = WordUtils.capitalizeFully(treeNode.getNodeType().name());
    JsonNodeAttribute nodeAttribute = new JsonNodeAttribute(addElement(treeNode), type,
            type + " " + treeNode.getName());
    jsonNode.setAttr(nodeAttribute);//from w  w  w. jav a  2  s .c  o  m

    TreeNodeCollector questionnaireVisitor = new TreeNodeCollector();
    element.accept(questionnaireVisitor);
    if (questionnaireVisitor.getChildren().isEmpty()) {
        nodeAttribute.setClazz("jstree-leaf");
    }
    for (Object child : questionnaireVisitor.getChildren()) {
        if (child instanceof IQuestionnaireElement) {
            jsonNode.getChildren().add(populateNode((IQuestionnaireElement) child));
        } else if (child instanceof Variable) {
            if (variablesNode == null) {
                createVariablesNode();
                jsonNode.getChildren().add(variablesNode);
            }
            Variable variable = (Variable) child;
            JsonNode variableNode = new JsonNode();
            variableNode.setData(new Data(variable.getName(),
                    RequestCycle.get().urlFor(NodeType.VARIABLE.getIcon()).toString()));
            JsonNodeAttribute variableNodeAttribute = new JsonNodeAttribute(
                    addElement(new TreeNode(variable.getName(), NodeType.VARIABLE)), "Variable",
                    "Variable " + variable.getName());
            variableNodeAttribute.setClazz("jstree-leaf");
            variableNode.setAttr(variableNodeAttribute);
            variablesNode.getChildren().add(variableNode);
        }
    }
    return jsonNode;
}

From source file:org.oep.cmon.portlet.hosolienthong.HoSoLienThongPortlet.java

/**
 * This is function searchHoSoLienThongNoiGui
 * Version: 1.0/*from www .ja  v a 2 s .  co m*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param request
 * @param ajaxResponse
 * @throws Exception
 */
public void searchHoSoLienThongNoiGui(ResourceRequest request, AjaxResponse ajaxResponse) throws Exception {
    long thuTucGuiId = ParamUtil.getLong(request, HSLTFields.thuTucGuiId);
    long[] thuTucGuiIds;
    CongChuc canBoNoiGui = EgovUtil.getCongChucDaDangNhap(PortalUtil.getUserId(request));

    if (thuTucGuiId == 0L) {

        List<ThongTinThuTuc> thuTucs = HSLTBusinessUtil.getDSThuTucLienThongNoiGui2CanBo(canBoNoiGui);
        int size = thuTucs.size();
        thuTucGuiIds = new long[size];
        for (int i = 0; i < size; ++i) {
            thuTucGuiIds[i] = thuTucs.get(i).getThuTucId();
        }
    } else {
        thuTucGuiIds = new long[] { thuTucGuiId };
    }

    QueryResult<HoSoLienThong> queryResult = HoSoLienThongLocalServiceUtil.searchHoSoNoiGui(request,
            canBoNoiGui, thuTucGuiIds);
    JSONArray searchResultJSON = JSONFactoryUtil.createJSONArray();
    JSONObject jsitem;

    int count = queryResult.getFetchedCount();
    int trangThaiLienThong;
    List<HoSoLienThong> result = queryResult.getResult();
    HoSoLienThong hoSoLienThong = null;
    HoSoTTHCCong hoSo = null;

    for (int i = 0; i < count; i++) {
        hoSoLienThong = result.get(i);
        trangThaiLienThong = hoSoLienThong.getTrangThaiLienThong();

        jsitem = JSONFactoryUtil.createJSONObject().put(HSLTFields.hoSoLienThongId, hoSoLienThong.getId())
                .put(HSLTFields.hoSoId, hoSoLienThong.getHoSoId())
                .put(HSLTFields.tenThuTucGui, hoSoLienThong.getTenThuTucGui())
                .put(HSLTFields.maSoBienNhanLucGui, hoSoLienThong.getMaSoBienNhanLucGui())
                .put(HSLTFields.hoTenNguoiNopHoSo,
                        WordUtils.capitalizeFully(hoSoLienThong.getHoTenCongDanNop()))
                .put(HSLTFields.hoTenCanBoGui, WordUtils.capitalizeFully(hoSoLienThong.getHoTenCanBoGui()))
                .put(HSLTFields.lucGui, DateTimeUtil.getFullDateTimeShort(hoSoLienThong.getNgayGui(), false))
                .put(HSLTFields.tenCoQuanNhan, hoSoLienThong.getTenCoQuanNhan())
                .put(HSLTFields.trangThaiLienThong, trangThaiLienThong).put(HSLTFields.tenTrangThaiLienThong,
                        HSLTBusinessUtil.getTenTrangThaiLienThong(request, trangThaiLienThong));

        jsitem.put(HSLTFields.coTheXemChiTiet, (trangThaiLienThong == HSLTBusinessUtil.TTLT_DA_NHAN_KET_QUA
                || trangThaiLienThong == HSLTBusinessUtil.TTLT_DA_TU_CHOI));

        jsitem.put(HSLTFields.daTraKetQua, trangThaiLienThong == HSLTBusinessUtil.TTLT_DA_TRA_KET_QUA);

        hoSo = HoSoTTHCCongLocalServiceUtil.fetchHoSoTTHCCong(hoSoLienThong.getHoSoId());
        jsitem.put(HSLTFields.coTheGuiLienThongLai,
                trangThaiLienThong == HSLTBusinessUtil.TTLT_DA_TU_CHOI && (!hoSo.getDungXuLy()));

        if (trangThaiLienThong == HSLTBusinessUtil.TTLT_DA_TIEP_NHAN) {
            jsitem.put(HSLTFields.coTheYeuCauRut, RutHoSoBusinessUtil.laHoSoCanBoDuocPhepYeuCauRut(
                    HoSoTTHCCongLocalServiceUtil.fetchHoSoTTHCCong(hoSoLienThong.getHoSoId())));
            jsitem.put(HSLTFields.yeuCauRutURL, RutHoSoBusinessUtil.getURLCanBoYeuCauRut(request,
                    hoSoLienThong.getHoSoId(), HSLTBusinessUtil.getURLDanhSachHoSoNoiGui(request)));
        } else {
            jsitem.put(HSLTFields.coTheYeuCauRut, false);
        }

        searchResultJSON.put(jsitem);
    }

    ajaxResponse.sendSearchResult(queryResult, searchResultJSON);
}

From source file:org.oep.cmon.portlet.hosolienthong.HoSoLienThongPortlet.java

/**
 * This is function searchHoSoLienThongNoiNhan
 * Version: 1.0//  w  ww .j a v a  2 s.  com
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param request
 * @param ajaxResponse
 * @throws Exception
 */
public void searchHoSoLienThongNoiNhan(ResourceRequest request, AjaxResponse ajaxResponse) throws Exception {

    long thuTucNhanId = ParamUtil.getLong(request, HSLTFields.thuTucNhanId);
    long[] thuTucNhanIds;
    CongChuc canBoNoiNhan = EgovUtil.getCongChucDaDangNhap(PortalUtil.getUserId(request));

    if (thuTucNhanId == 0L) {
        List<ThongTinThuTuc> thuTucs = HSLTBusinessUtil.getDSThuTucLienThongNoiNhan2CanBo(canBoNoiNhan);
        int size = thuTucs.size();
        thuTucNhanIds = new long[size];
        for (int i = 0; i < size; ++i) {
            thuTucNhanIds[i] = thuTucs.get(i).getThuTucId();
        }
    } else {
        thuTucNhanIds = new long[] { thuTucNhanId };
    }

    QueryResult<HoSoLienThong> queryResult = HoSoLienThongLocalServiceUtil.searchHoSoNoiNhan(request,
            canBoNoiNhan, thuTucNhanIds);
    JSONArray searchResultJSON = JSONFactoryUtil.createJSONArray();

    int count = queryResult.getFetchedCount();
    int trangThaiLienThong;
    List<HoSoLienThong> result = queryResult.getResult();
    HoSoLienThong hoSoLienThong;

    for (int i = 0; i < count; i++) {
        hoSoLienThong = result.get(i);
        trangThaiLienThong = hoSoLienThong.getTrangThaiLienThong();

        searchResultJSON.put(JSONFactoryUtil.createJSONObject()
                .put(HSLTFields.hoSoLienThongId, hoSoLienThong.getId())
                .put(HSLTFields.hoSoId, hoSoLienThong.getHoSoId())
                .put(HSLTFields.tenThuTucNhan, hoSoLienThong.getTenThuTucNhan())
                .put(HSLTFields.hoTenNguoiNopHoSo,
                        WordUtils.capitalizeFully(hoSoLienThong.getHoTenCongDanNop()))
                .put(HSLTFields.diaChiDayDuCongDanNop, hoSoLienThong.getDiaChiDayDuCongDanNop())
                .put(HSLTFields.tenCoQuanGui, hoSoLienThong.getTenCoQuanGui())
                .put(HSLTFields.hoTenCanBoGui, WordUtils.capitalizeFully(hoSoLienThong.getHoTenCanBoGui()))
                .put(HSLTFields.lucGui, DateTimeUtil.getFullDateTimeShort(hoSoLienThong.getNgayGui(), false))
                .put(HSLTFields.trangThaiLienThong, trangThaiLienThong).put(HSLTFields.tenTrangThaiLienThong,
                        HSLTBusinessUtil.getTenTrangThaiLienThong(request, trangThaiLienThong)));
    }

    ajaxResponse.sendSearchResult(queryResult, searchResultJSON);
}