Java Code Examples for org.apache.commons.lang.StringUtils#right()

The following examples show how to use org.apache.commons.lang.StringUtils#right() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssetGlobal.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/** 
 * Sets the universityFiscalPeriodName attribute.
 * 
 * @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;
}
 
Example 2
Source File: InformationResponseMessage.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void parsePayLoad() {
    Matcher matcher = RESPONSE_PATTERN.matcher(payLoad);
    if (matcher.matches()) {
        MAC = matcher.group(1);
        year = Integer.parseInt(matcher.group(2), 16) + 2000;
        month = Integer.parseInt(matcher.group(3), 16);
        minutes = Integer.parseInt(matcher.group(4), 16);
        logAddress = (Integer.parseInt(matcher.group(5), 16) - 278528) / 32;
        powerState = (matcher.group(6).equals("01"));
        hertz = Integer.parseInt(matcher.group(7), 16);
        hardwareVersion = StringUtils.left(matcher.group(8), 4) + "-" + StringUtils.mid(matcher.group(8), 4, 4)
                + "-" + StringUtils.right(matcher.group(8), 4);
        firmwareVersion = Integer.parseInt(matcher.group(9), 16);
        deviceType = intToDeviceType(Integer.parseInt(matcher.group(10), 16));
    } else {
        logger.debug("Plugwise protocol RoleCallResponseMessage error: {} does not match", payLoad);
    }
}
 
Example 3
Source File: InitialiseResponseMessage.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void parsePayLoad() {
    Matcher matcher = RESPONSE_PATTERN.matcher(payLoad);
    if (matcher.matches()) {
        MAC = matcher.group(1);
        unknown1 = matcher.group(2);
        online = (Integer.parseInt(matcher.group(3), 16) == 1);
        networkID = matcher.group(4);
        shortNetworkID = matcher.group(5);
        unknown2 = matcher.group(6);

        // now some serious protocol reverse-engineering assumption. Circle+ MAC = networkID with first two bytes
        // replaced by 00
        circlePlusMAC = "00" + StringUtils.right(networkID, StringUtils.length(networkID) - 2);
    } else {
        logger.debug("Plugwise protocol InitialiseResponse error: {} does not match", payLoad);
    }

}
 
Example 4
Source File: FileUtils.java    From Aooms with Apache License 2.0 5 votes vote down vote up
/** 
 * 链接PATH后处理 
 *  
 * @param path 
 * @return 
 */  
public static String trimRightPath(String path) {  
    if (isFile(path))  
        return path;  
    path = replacePath(path);  
    String bottom = StringUtils.right(path, 1);  
    if (StringUtils.equalsIgnoreCase(SLASH_TWO, bottom))  
        return StringUtils.substring(path, 0, path.length() - 2);  
    return path + SLASH_TWO;  
}
 
Example 5
Source File: SensitiveInfoUtils.java    From SuperBoot with MIT License 5 votes vote down vote up
/**
 * [身份证号] 显示最后四位,其他隐藏。共计18位或者15位。<例子:*************5762>
 *
 * @param id 身份证号
 * @return
 */
public static String idCardNum(String id) {
    if (StringUtils.isBlank(id)) {
        return "";
    }
    String num = StringUtils.right(id, 4);
    return StringUtils.leftPad(num, StringUtils.length(id), "*");
}
 
Example 6
Source File: ECSService.java    From amazon-ecs-plugin with MIT License 5 votes vote down vote up
public ECSService(String credentialsId, String regionName) {
    this.clientSupplier = () -> {
        ProxyConfiguration proxy = Jenkins.get().proxy;
        ClientConfiguration clientConfiguration = new ClientConfiguration();

        if (proxy != null) {
            clientConfiguration.setProxyHost(proxy.name);
            clientConfiguration.setProxyPort(proxy.port);
            clientConfiguration.setProxyUsername(proxy.getUserName());
            clientConfiguration.setProxyPassword(proxy.getPassword());
        }

        // Default is 3. 10 helps us actually utilize the SDK's backoff strategy
        // The strategy will wait up to 20 seconds per request (after multiple failures)
        clientConfiguration.setMaxErrorRetry(10);

        AmazonECSClientBuilder builder = AmazonECSClientBuilder
                .standard()
                .withClientConfiguration(clientConfiguration)
                .withRegion(regionName);

        AmazonWebServicesCredentials credentials = getCredentials(credentialsId);
        if (credentials != null) {
            if (LOGGER.isLoggable(Level.FINE)) {
                String awsAccessKeyId = credentials.getCredentials().getAWSAccessKeyId();
                String obfuscatedAccessKeyId = StringUtils.left(awsAccessKeyId, 4) + StringUtils.repeat("*", awsAccessKeyId.length() - (2 * 4)) + StringUtils.right(awsAccessKeyId, 4);
                LOGGER.log(Level.FINE, "Connect to Amazon ECS with IAM Access Key {1}", new Object[]{obfuscatedAccessKeyId});
            }
            builder
                    .withCredentials(credentials);
        }
        LOGGER.log(Level.FINE, "Selected Region: {0}", regionName);

        return builder.build();
    };
}
 
Example 7
Source File: LedgerPostingDocumentBase.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Set accountingPeriod based on incoming paramater.
 * @param accountingPeriodString in the form of [period][year]
 */
public void setAccountingPeriodCompositeString(String accountingPeriodString) {
    if (StringUtils.isNotBlank(accountingPeriodString)) {
        String period = StringUtils.left(accountingPeriodString, 2);
        Integer year = new Integer(StringUtils.right(accountingPeriodString, 4));
        AccountingPeriod accountingPeriod = getAccountingPeriodService().getByPeriod(period, year);
        setAccountingPeriod(accountingPeriod);
    }
}
 
Example 8
Source File: ProcurementCardCreateDocumentServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Set up PCDO document description as "cardholder name-card number (which is 4 digits)-chartOfAccountsCode-default account"
 *
 * @param pcardDocument
 */
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);
    }
}
 
Example 9
Source File: VoucherForm.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * util method to get postingYear out of selectedAccountingPeriod
 * 
 * @return Integer
 */

protected Integer getSelectedPostingYear() {
    Integer postingYear = null;
    if (StringUtils.isNotBlank(getSelectedAccountingPeriod())) {
        postingYear = new Integer(StringUtils.right(getSelectedAccountingPeriod(), 4));
    }
    return postingYear;
}
 
Example 10
Source File: AssetGlobal.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Sets the accountingPeriod if in period 13
 * @param accountingPeriodString
 * 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);
    }
}
 
Example 11
Source File: AssetRetirementGlobal.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Sets the accountingPeriod if in period 13
 * @param accountingPeriodString
 * 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);
    }
}