Example usage for org.apache.commons.lang StringUtils left

List of usage examples for org.apache.commons.lang StringUtils left

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils left.

Prototype

public static String left(String str, int len) 

Source Link

Document

Gets the leftmost len characters of a String.

Usage

From source file:org.jtalks.jcommune.service.transactional.TransactionalTopicFetchService.java

/**
 * {@inheritDoc}// w w  w  . j a v a  2  s .c o m
 */
@Override
public Page<Topic> searchByTitleAndContent(String phrase, String page) {
    JCUser currentUser = userService.getCurrentUser();

    List<Long> allowedBranchesIds = this.getDao().getAllowedBranchesIds(currentUser);

    if (!StringUtils.isEmpty(phrase) && !allowedBranchesIds.isEmpty()) {
        int pageSize = currentUser.getPageSize();
        PageRequest pageRequest = new PageRequest(page, pageSize);
        // hibernate search refuses to process long string throwing error
        String normalizedPhrase = StringUtils.left(phrase, 50);

        return searchDao.searchByTitleAndContent(normalizedPhrase, pageRequest, allowedBranchesIds);
    }
    return new PageImpl<>(Collections.<Topic>emptyList());
}

From source file:org.jumpmind.metl.core.runtime.component.ModelAttributeScriptHelper.java

public String left(int length) {
    return StringUtils.left(value != null ? value.toString() : "", length);
}

From source file:org.jumpmind.symmetric.db.firebird.FirebirdSymmetricDialect.java

@Override
public String getName() {
    return StringUtils.left(super.getName(), 50);
}

From source file:org.jumpmind.symmetric.model.NodeHost.java

public void setIpAddress(String ipAddress) {
    this.ipAddress = StringUtils.left(ipAddress, MAX_IP_ADDRESS_SIZE);
}

From source file:org.jumpmind.symmetric.model.RegistrationRequest.java

public void setIpAddress(String ipAddress) {
    this.ipAddress = StringUtils.left(ipAddress == null ? "unknown" : ipAddress, NodeHost.MAX_IP_ADDRESS_SIZE);
}

From source file:org.kuali.kfs.fp.batch.service.impl.ProcurementCardCreateDocumentServiceImpl.java

/**
 * Set up PCDO document description as "cardholder name-card number (which is 4 digits)-chartOfAccountsCode-default account"
 *
 * @param pcardDocument/*  ww  w  .j ava  2s.  com*/
 */
protected void setupDocumentDescription(ProcurementCardDocument pcardDocument) {
    ProcurementCardHolder cardHolder = pcardDocument.getProcurementCardHolder();

    if (ObjectUtils.isNotNull(cardHolder)) {
        String cardHolderName = StringUtils.left(cardHolder.getCardHolderName(), 23);
        String lastFourDigits = StringUtils.right(cardHolder.getTransactionCreditCardNumber(), 4);
        String chartOfAccountsCode = cardHolder.getChartOfAccountsCode();
        String accountNumber = cardHolder.getAccountNumber();

        String description = MessageFormat.format(DOCUMENT_DESCRIPTION_PATTERN, cardHolderName, lastFourDigits,
                chartOfAccountsCode, accountNumber);
        pcardDocument.getDocumentHeader().setDocumentDescription(description);
    }
}

From source file:org.kuali.kfs.fp.document.web.struts.VoucherForm.java

/**
 * util method to get posting period code out of selectedAccountingPeriod
 * // w  w  w  .j  av a2  s  .c  om
 * @return String
 */
protected String getSelectedPostingPeriodCode() {
    String periodCode = null;
    String selectedPeriod = getSelectedAccountingPeriod();
    if (StringUtils.isNotBlank(selectedPeriod)) {
        periodCode = StringUtils.left(selectedPeriod, 2);
    }
    return periodCode;
}

From source file:org.kuali.kfs.module.cam.businessobject.AssetGlobal.java

/**
 * Gets the universityFiscalPeriodName attribute.
 * //from w  w  w  .  j  av a 2  s  .  co  m
 * @return Returns the universityFiscalPeriodName
 */

public String getUniversityFiscalPeriodName() {
    if (StringUtils.isNotBlank(universityFiscalPeriodName)) {
        this.setFinancialDocumentPostingPeriodCode(StringUtils.left(universityFiscalPeriodName, 2));
        this.setFinancialDocumentPostingYear(new Integer(StringUtils.right(universityFiscalPeriodName, 4)));
    }

    if (StringUtils.isBlank(universityFiscalPeriodName)) {
        if (this.financialDocumentPostingPeriodCode != null && this.financialDocumentPostingYear != null) {
            universityFiscalPeriodName = this.financialDocumentPostingPeriodCode
                    + this.financialDocumentPostingYear;
        }
    }

    return universityFiscalPeriodName;
}

From source file:org.kuali.kfs.module.cam.businessobject.AssetGlobal.java

/** 
 * Sets the universityFiscalPeriodName attribute.
 * /*from  w w  w. j a  va2 s  .  c o  m*/
 * @param universityFiscalPeriodName The universityFiscalPeriodName to set.
 */
public void setUniversityFiscalPeriodName(String universityFiscalPeriodName) {
    if (StringUtils.isBlank(universityFiscalPeriodName)) {
        if (this.financialDocumentPostingPeriodCode != null && this.financialDocumentPostingYear != null) {
            universityFiscalPeriodName = this.financialDocumentPostingPeriodCode
                    + this.financialDocumentPostingYear;
        }
    }

    String THIRTEEN = "13";
    if (StringUtils.isNotBlank(universityFiscalPeriodName)
            && StringUtils.left(universityFiscalPeriodName, 2).equals(THIRTEEN)) {
        String period = StringUtils.left(universityFiscalPeriodName, 2);
        Integer year = new Integer(StringUtils.right(universityFiscalPeriodName, 4));
        AccountingPeriod accountingPeriod = getAccountingPeriodService().getByPeriod(period, year);
        setAccountingPeriod(accountingPeriod);
    }

    this.universityFiscalPeriodName = universityFiscalPeriodName;
}

From source file:org.kuali.kfs.module.cam.businessobject.AssetGlobal.java

/**
 * Sets the accountingPeriod if in period 13
 * @param accountingPeriodString/*from   www .j a va2  s.c o m*/
 * TODO remove hardcoding
 */
public void setAccountingPeriodCompositeString(String accountingPeriodString) {
    String THIRTEEN = "13";
    if (StringUtils.isNotBlank(accountingPeriodString)
            && StringUtils.left(accountingPeriodString, 2).equals(THIRTEEN)) {
        String period = StringUtils.left(accountingPeriodString, 2);
        Integer year = new Integer(StringUtils.right(accountingPeriodString, 4));
        AccountingPeriod accountingPeriod = getAccountingPeriodService().getByPeriod(period, year);
        setAccountingPeriod(accountingPeriod);
    }
}