Example usage for org.apache.commons.lang3 StringUtils trimToEmpty

List of usage examples for org.apache.commons.lang3 StringUtils trimToEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils trimToEmpty.

Prototype

public static String trimToEmpty(final String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null .

Usage

From source file:org.ahp.commons.form.AhpAbstractForm.java

/**
 * /*from  w w  w  .j ava  2 s  .  com*/
 * @param pSubmitActionsEnum
 * @return
 */
public boolean isSubmitAction(Enum<?> pSubmitActionsEnum) {
    String lSubmitAction = StringUtils.trimToEmpty(this.getSubmitAction());
    if (lSubmitAction.equalsIgnoreCase(pSubmitActionsEnum.toString())) {
        return true;
    }
    return false;
}

From source file:org.ahp.commons.form.AhpAbstractForm.java

/**
 * //from   w ww.  j  ava  2  s. c om
 * @param pNavigateActionssEnum
 * @return
 */
public boolean isNextPage(Enum<?> pNavigateActionsEnum) {
    String lNextPage = StringUtils.trimToEmpty(this.getNextPage());
    if (lNextPage.equalsIgnoreCase(pNavigateActionsEnum.toString())) {
        return true;
    }
    return false;
}

From source file:org.ahp.core.bootstrap.AhpBootstrapStrutsPlugin.java

/**
 * /* w  w w.  j a  va 2 s .  c  om*/
 */
public void init(ActionServlet pActionServlet, ModuleConfig pModuleConfig) throws ServletException {
    System.out.println("Initializing AhpBootstrapStrutsPlugin");
    try {
        String lRealPath = pActionServlet.getServletContext().getRealPath("/");
        System.out.println("ConfigurationFiles - " + this.getAhpConfigurationLocation());
        WebApplicationContext lWebApplicationContext = WebApplicationContextUtils
                .getWebApplicationContext(pActionServlet.getServletContext());
        String lBeanName = StringUtils.trimToEmpty(this.getAhpBootstrapManagerBeanId());
        if (lBeanName == null) {
            lBeanName = DEFAULT_AHP_BOOTSTRAP_MANAGER_BEAN_ID;
        }
        IAhpBootstrapManager lAhpBootstrapManager = (IAhpBootstrapManager) lWebApplicationContext
                .getBean(lBeanName);
        if (lAhpBootstrapManager == null)
            lAhpBootstrapManager = lWebApplicationContext.getBean(IAhpBootstrapManager.class);
        lAhpBootstrapManager.bootstrap(this.getAhpConfigurationLocation().split(","), lRealPath);
    } catch (AhpRuntimeException exAhpRuntime) {
        throw exAhpRuntime;
    } catch (Exception ex) {
        throw new AhpRuntimeException("AHP.001.0001", ex);
    }
}

From source file:org.ahp.login.action.DisplayLogin.java

@Override
public ActionForward display(ActionMapping pActionMapping, ActionForm pActionForm,
        HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) {
    LoginForm lLoginForm = (LoginForm) pActionForm;
    if (NavigateActions.DisplayHomePage.toString().equals(StringUtils.trimToEmpty(lLoginForm.getNextPage()))) {
        LOGGER.debug("Login was successfull");
        return pActionMapping.findForward(NavigateActions.DisplayHomePage.toString());
    }//from   www  .  ja v  a2s  .com
    return pActionMapping.findForward(NavigateActions.DisplayLogin.toString());
}

From source file:org.ahp.vinavidai.commons.pagination.AhpAbstractPaginationAction.java

@Override
public ActionForward execute(ActionMapping pActionMapping, ActionForm pActionForm,
        HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) {
    AhpAbstractPaginationForm lAhpAbstractPaginationForm = (AhpAbstractPaginationForm) pActionForm;
    String lAction = StringUtils.trimToEmpty(lAhpAbstractPaginationForm.getSubmitAction());
    User lLoggedInUser = AhpActionHelper.getLoggedInUser(pHttpServletRequest);
    if ("".equals(lAction) && ""
            .equals(StringUtils.trimToEmpty(lAhpAbstractPaginationForm.getPaginationData().getOperation()))) {
        populatePaginationSearchCriteria(lAhpAbstractPaginationForm, lLoggedInUser, true);
    }/*www  .j a  va  2  s.c  o  m*/
    // User clicked Go Button with Order By.
    else if (StringUtils.equals(SubmitActions.GO.toString(), lAction)) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("User Pressed Go Button");
        lAhpAbstractPaginationForm.getPaginationData().setStartIndex(1);
        lAhpAbstractPaginationForm.getPaginationData().setEndIndex(25);
        lAhpAbstractPaginationForm.getPaginationData().setSelectedPage(1);
        populatePaginationSearchCriteria(lAhpAbstractPaginationForm, lLoggedInUser, false);
    }
    // User selects a Page Range from the ComboBox. et Start and End Indexes
    // based on the HiddenComboValue (Page Number he is requesting).
    else if (StringUtils.equals(PaginationOperations.ComboSubmit.toString(),
            StringUtils.trimToEmpty(lAhpAbstractPaginationForm.getPaginationData().getOperation()))) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("User Selected a Page Range from the ComboBox");
        int lSelectedComboValue = lAhpAbstractPaginationForm.getPaginationData().getHiddenSelectedComboValue();
        lAhpAbstractPaginationForm.getPaginationData().setEndIndex(
                lSelectedComboValue * lAhpAbstractPaginationForm.getPaginationData().getMaxRecordsPerPage());
        lAhpAbstractPaginationForm.getPaginationData()
                .setStartIndex(lAhpAbstractPaginationForm.getPaginationData().getEndIndex()
                        - lAhpAbstractPaginationForm.getPaginationData().getMaxRecordsPerPage() + 1);
        lAhpAbstractPaginationForm.getPaginationData().setSelectedPage(lSelectedComboValue);
        populatePaginationSearchCriteria(lAhpAbstractPaginationForm, lLoggedInUser, false);
    }
    // User Clicks Previous HyperLink. In this action the user might have
    // the search filters still on. Look for them and populate
    else if (StringUtils.equals(PaginationOperations.ShowPrevious.toString(),
            StringUtils.trimToEmpty(lAhpAbstractPaginationForm.getPaginationData().getOperation()))) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("User Clicked Previous");
        populatePaginationSearchCriteria(lAhpAbstractPaginationForm, lLoggedInUser, false);
        loadPageIndexes(lAhpAbstractPaginationForm);
    }
    // User Clicks Next HyperLink. In this action the user might have the
    // search filters still on. Look for them and populate
    else if (StringUtils.equals(PaginationOperations.ShowNext.toString(),
            StringUtils.trimToEmpty(lAhpAbstractPaginationForm.getPaginationData().getOperation()))) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("User Clicked Next");
        populatePaginationSearchCriteria(lAhpAbstractPaginationForm, lLoggedInUser, false);
        loadPageIndexes(lAhpAbstractPaginationForm);
    }
    ActionForward lActionForward = paginate(pActionMapping, pActionForm, pHttpServletRequest,
            pHttpServletResponse);
    lAhpAbstractPaginationForm.setSubmitAction(null);
    // this.clearPagination( lAhpAbstractPaginationForm );
    return lActionForward;
}

From source file:org.ahp.vinavidai.console.action.DisplayQuizConsole.java

@Override
public ActionForward display(ActionMapping pActionMapping, ActionForm pActionForm,
        HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) {
    User lLoggedInUser = AhpActionHelper.getLoggedInUser(pHttpServletRequest);
    QuizConsoleForm lQuizConsoleForm = (QuizConsoleForm) pActionForm;
    String lNextPage = StringUtils.trimToEmpty(lQuizConsoleForm.getNextPage());
    ActionForward lActionForward = pActionMapping.findForward(NavigateActions.DisplayQuizConsole.toString());
    String lSubmitAction = StringUtils.trimToEmpty(lQuizConsoleForm.getSubmitAction());
    return lActionForward;
}

From source file:org.ahp.vinavidai.quiz.action.DisplayCreateQuestion.java

@Override
public ActionForward display(ActionMapping pActionMapping, ActionForm pActionForm,
        HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) {
    User lLoggedInUser = AhpActionHelper.getLoggedInUser(pHttpServletRequest);
    CreateQuestionForm lCreateQuestionForm = (CreateQuestionForm) pActionForm;
    String lNextPage = StringUtils.trimToEmpty(lCreateQuestionForm.getNextPage());
    ActionForward lActionForward = pActionMapping.findForward(NavigateActions.DisplayCreateQuestion.toString());
    if (NavigateActions.DisplayCreateQuestion.toString().equals(lNextPage)
            || NavigateActions.DisplayCreateQuestionStart.toString().equals(lNextPage)
            || NavigateActions.DisplayCreateQuestionNext.toString().equals(lNextPage)) {
        if (NavigateActions.DisplayCreateQuestionStart.toString().equals(lNextPage)) {
            this.setDefaultValues(lCreateQuestionForm);
            pHttpServletRequest.getSession().removeAttribute(QUIZ_UNDER_CREATION);
        }//from   w ww  .j  av  a 2  s .  c o m
        if (NavigateActions.DisplayCreateQuestionNext.toString().equals(lNextPage)) {
            this.setDefaultValues(lCreateQuestionForm);
        }
        if (lCreateQuestionForm.isSubmitAction(SubmitActions.ADD_OPTION)) {
            Option lOption = new Option();
            lOption.setOptionDescription("");
            lCreateQuestionForm.getOptions().add(lOption);
        }
        if (lCreateQuestionForm.isSubmitAction(SubmitActions.DELETE_OPTION)) {
            int lDeleteIndex = Integer.parseInt(lCreateQuestionForm.getHiddenDeleteOptionIndex());
            if (lCreateQuestionForm.getOptions().size() > lDeleteIndex)
                lCreateQuestionForm.getOptions().remove(lDeleteIndex);
            while (lCreateQuestionForm.getOptions().size() < 3) {
                Option lOption = new Option();
                lOption.setOptionDescription("");
                lCreateQuestionForm.getOptions().add(lOption);
            }
        }
        if (lCreateQuestionForm.isSubmitAction(SubmitActions.RESET)) {
            this.setDefaultValues(lCreateQuestionForm);
        }
    }
    if (NavigateActions.DisplayCreateQuizConfirmation.toString().equals(lNextPage)) {
        lActionForward = pActionMapping
                .findForward(NavigateActions.DisplayCreateQuestionConfirmation.toString());
    }
    if (NavigateActions.DisplayCreateQuizCancelled.toString().equals(lNextPage)) {
        lActionForward = pActionMapping.findForward(NavigateActions.DisplayQuizConsole.toString());
    }
    return lActionForward;
}

From source file:org.ahp.vinavidai.quiz.action.DisplayCreateQuiz.java

@Override
public ActionForward display(ActionMapping pActionMapping, ActionForm pActionForm,
        HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) {
    LOGGER.trace("DisplayCreateQuiz :: starts");
    User lLoggedInUser = AhpActionHelper.getLoggedInUser(pHttpServletRequest);
    CreateQuizForm lCreateQuizForm = (CreateQuizForm) pActionForm;
    String lNextPage = StringUtils.trimToEmpty(lCreateQuizForm.getNextPage());
    ActionForward lActionForward = pActionMapping.findForward(NavigateActions.DisplayCreateQuiz.toString());
    if (lCreateQuizForm.isSubmitAction(SubmitActions.ADD_CATEGORY)) {
        Category lCategory = new Category();
        lCategory.setCategory("");
        lCreateQuizForm.getCategory().add(lCategory);
        return lActionForward;
    }/*from   w w w.  ja v a  2  s  .c o  m*/
    if (lCreateQuizForm.isSubmitAction(SubmitActions.DELETE_CATEGORY)) {
        int lDeleteCategoryIndex = lCreateQuizForm.getHiddenDeleteCategoryIndex();
        lCreateQuizForm.getCategory().remove(lDeleteCategoryIndex);
        return lActionForward;
    }
    if (lCreateQuizForm.isSubmitAction(SubmitActions.ADD_SKILL_LEVEL)) {
        SkillLevel lSkillLevel = new SkillLevel();
        lSkillLevel.setSkillLevel("");
        lCreateQuizForm.getSkillLevel().add(lSkillLevel);
        return lActionForward;
    }
    if (lCreateQuizForm.isSubmitAction(SubmitActions.DELETE_SKILL_LEVEL)) {
        int lDeleteSkillLevelIndex = lCreateQuizForm.getHiddenDeleteSkillLevelIndex();
        lCreateQuizForm.getSkillLevel().remove(lDeleteSkillLevelIndex);
        return lActionForward;
    }
    if (NavigateActions.DisplayCreateQuiz.toString().equals(lNextPage)) {
        //lCreateQuizForm.setCategoriesAutoComplete( AhpStringUtil.listToQuotedString( this.mQuizService
        //        .getAllCategoryNames( lLoggedInUser ) ) );
        //lCreateQuizForm.setSkillLevelsAutoComplete( AhpStringUtil.listToQuotedString( this.mQuizService
        //        .getAllSkillLevelNames( lLoggedInUser ) ) );
        List<Category> lCategoryList = new ArrayList<Category>();
        lCategoryList.add(new Category());
        lCreateQuizForm.setCategory(lCategoryList);
        List<SkillLevel> lSkillLevelList = new ArrayList<SkillLevel>();
        lSkillLevelList.add(new SkillLevel());
        lCreateQuizForm.setSkillLevel(lSkillLevelList);
        lActionForward = pActionMapping.findForward(NavigateActions.DisplayCreateQuiz.toString());
    }
    if (NavigateActions.DisplayCreateQuestion.toString().equals(lNextPage)) {
        lActionForward = pActionMapping.findForward(NavigateActions.DisplayCreateQuestion.toString());
    }
    if (NavigateActions.DisplayCreateQuizConfirmation.toString().equals(lNextPage)) {
        lActionForward = pActionMapping.findForward(NavigateActions.DisplayCreateQuizConfirmation.toString());
    }
    LOGGER.trace("DisplayCreateQuiz :: ends");
    return lActionForward;
}

From source file:org.ahp.vinavidai.quiz.action.DisplayCreateQuizConfirmation.java

@Override
public ActionForward display(ActionMapping pActionMapping, ActionForm pActionForm,
        HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) {
    User lLoggedInUser = AhpActionHelper.getLoggedInUser(pHttpServletRequest);
    CreateQuestionForm lCreateQuizForm = (CreateQuestionForm) pActionForm;
    String lNextPage = StringUtils.trimToEmpty(lCreateQuizForm.getNextPage());
    ActionForward lActionForward = pActionMapping
            .findForward(NavigateActions.DisplayCreateQuizConfirmation.toString());
    if (NavigateActions.DisplayCreateQuizConfirmation.toString().equals(lNextPage)) {
        lActionForward = pActionMapping.findForward(NavigateActions.DisplayCreateQuizConfirmation.toString());
    }//from   www.  ja v a2s.  c o  m
    return lActionForward;
}

From source file:org.ahp.vinavidai.quiz.action.DisplayDeleteQuiz.java

@Override
public ActionForward display(ActionMapping pActionMapping, ActionForm pActionForm,
        HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) {
    User lLoggedInUser = AhpActionHelper.getLoggedInUser(pHttpServletRequest);
    ManageQuizForm lManageQuizForm = (ManageQuizForm) pActionForm;
    lManageQuizForm.setDeleteQuiz(true);
    String lNextPage = StringUtils.trimToEmpty(lManageQuizForm.getNextPage());
    ActionForward lActionForward = pActionMapping.findForward(NavigateActions.DisplayDeleteQuiz.toString());
    if (NavigateActions.DisplayManageQuiz.toString().equals(lNextPage)) {
        lActionForward = pActionMapping.findForward(NavigateActions.DisplayManageQuiz.toString());
    }/*from ww w .  j a v a  2s .  c  o  m*/
    if (NavigateActions.DisplayDeleteQuiz.toString().equals(lNextPage)) {
        for (Quiz lViewQuiz : lManageQuizForm.getQuizResults()) {
            if (lViewQuiz.getQuizId().longValue() == (lManageQuizForm.getSelectedQuizId().longValue())) {
                lManageQuizForm.setSelectedQuiz(lViewQuiz);
                break;
            }
        }
        lActionForward = pActionMapping.findForward(NavigateActions.DisplayDeleteQuiz.toString());
    }
    return lActionForward;
}