public void setProgressMessage(String progressMessage) { this.progressMessage = StringUtils.defaultIfEmpty(StringUtils.right(progressMessage, MAX_STRING_SIZE), ""); }
public void setTestComment(String testComment) { this.testComment = StringUtils.trimToEmpty(StringUtils.right(testComment, MAX_STRING_SIZE)); }
@Override protected void doLog(LogLevel level, String message, String category) { //Cargo actually starts logging messages 2+ times at the end of a test run. Lets not do this because it makes //it hard to read the logs. if (StringUtils.equals(message, lastMessage) && StringUtils.equals(category, lastCategory) && ObjectUtils.equals(level, lastLevel)) { return; } lastLevel = level; lastMessage = message; lastCategory = category; this.writer.printf("[%tT][%s][%s] %s%n", System.currentTimeMillis(), level, StringUtils.right(category, 20), message); } }
public static ItemName stringToQName(String text) { if (StringUtils.isEmpty(text)) { return null; } int index = text.lastIndexOf(QNAME_DELIMITER); String namespace = StringUtils.left(text, index); String localPart = StringUtils.right(text, text.length() - index - 1); if (StringUtils.isEmpty(localPart)) { return null; } return new ItemName(namespace, localPart); }
/** * 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; }
public void right(PrettyPrint pp) { long millis = System.currentTimeMillis() - pp.getStart(); String elapsed = getElapsed(millis); String padding = StringUtils.repeat(".", defaultPrintableConsoleWidth); String right = padding + " " + elapsed; int rightLength = defaultPrintableConsoleWidth - pp.getMsg().length(); if (rightLength < elapsed.length()) { System.out.println(elapsed); } else { System.out.println(StringUtils.right(right, rightLength)); } }
/** * [固定电话] 后四位,其他隐藏<例子:****1234> * * @param num * @return */ public static String fixedPhone(String num) { if (StringUtils.isBlank(num)) { return ""; } return StringUtils.leftPad(StringUtils.right(num, 4), StringUtils.length(num), "*"); }
/** * [身份证号] 显示最后四位,其他隐藏。共计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), "*"); }
/** * <p> * Method for abbreviating the given String to a particular length, by * removing characters from the middle of the String. * </p> * <p> * This method does not, yet guarantee a return String of length len. * </p> * * @param input * @param len * @return String */ public static final String centerAbbreviate(final String input, final int len) { if (input.length() <= len) { return input; } if (len < 5) { return input; } if (input.length() < len) { return input; } else { return StringUtils.abbreviate(input, len / 2) + StringUtils.right(input, len / 2); } }
/** * [银行卡号] 前六位,后四位,其他用星号隐藏每位1个星号<例子:6222600**********1234> * * @param cardNum * @return */ public static String bankCard(String cardNum) { if (StringUtils.isBlank(cardNum)) { return ""; } return StringUtils.left(cardNum, 6).concat(StringUtils.removeStart(StringUtils.leftPad(StringUtils.right(cardNum, 4), StringUtils.length(cardNum), "*"), "******")); }
/** * 链接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; }
/** * create the jcr node path for work Item by its id. * @param eid */ public String createPathFromId(FlowExpressionId eid) { String wlInstId = eid.getWorkflowInstanceId(); // TODO someone who knows the code better should have a look String groupString = StringUtils.right(StringUtils.substringBefore(wlInstId, "."), 3); int groupNumber = Integer.parseInt(groupString) % 100; StringBuffer buffer = new StringBuffer(eid.getWorkflowDefinitionName()); buffer.append(WorkflowConstants.SLASH); buffer.append(eid.getWorkflowDefinitionRevision()); buffer.append(WorkflowConstants.SLASH); buffer.append(groupNumber); buffer.append(WorkflowConstants.SLASH); buffer.append(eid.getWorkflowInstanceId()); buffer.append(WorkflowConstants.SLASH); buffer.append(eid.getExpressionName()); buffer.append(WorkflowConstants.SLASH); buffer.append(eid.getExpressionId()); return convertPath(buffer.toString()); }
/** * [手机号码] 前三位,后四位,其他隐藏<例子:138****1234> * * @param num * @return */ public static String mobilePhone(String num) { if (StringUtils.isBlank(num)) { return ""; } if (7 < num.length()) { return StringUtils.left(num, 3).concat(StringUtils.removeStart(StringUtils.leftPad(StringUtils.right(num, 4), StringUtils.length(num), "*"), "***")); } else { return StringUtils.leftPad(StringUtils.right(num, 2), StringUtils.length(num), "*"); } }
/** * Register the user in the MDC under USER_KEY. * * @param userName the name of current user * @return true if the username was registered in MDC, false only if the user is anonymous and session id is empty. * If true, you have to unregister the user at some point otherwise the memory will leak. */ private boolean registerCurrentUserName(String userName, String sessionId) { if (!StringUtils.isEmpty(userName)) { loggerMdc.registerUser(userName); return true; } else if (isSessionIdValid(sessionId)) { loggerMdc.registerUser(ANONYMOUS_PREFIX + StringUtils.right(sessionId, SESSION_ID_LENGTH)); return true; } else { return false; } }
/** * [自定义脱敏规则] 定义自定义脱敏规则,指定前面位数与后面位数,其他均星号隐藏 * * @param code 代脱敏字符 * @param beginLength 前面位数 * @param endLength 后面位数 * @return */ public static String other(String code, int beginLength, int endLength) { return StringUtils.left(code, beginLength).concat(StringUtils.removeStart(StringUtils.leftPad(StringUtils.right(code, endLength), StringUtils.length(code), "*"), "***")); }
@Override public String shortName() { return kind().prefix() + StringUtils.right(getValue(), 3); }
int delimeter = kind.indexOf(DELIMITER); version = StringUtils.left(kind, delimeter); kind = StringUtils.right(kind, kind.length() - delimeter - DELIMITER.length());
int delimeter = kind.indexOf(DELIMITER); version = StringUtils.left(kind, delimeter); kind = StringUtils.right(kind, kind.length() - delimeter - DELIMITER.length());
AmazonECS getAmazonECSClient() { 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()); } 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(); }