@Override public String getDescription() { return "String: " + StringUtils.abbreviate(content, 100); } });
return abbreviate(str, 0, maxWidth);
public Builder setName(String name) { this.name = abbreviate(requireNonNull(name, NAME_CANNOT_BE_NULL), MAX_COMPONENT_NAME_LENGTH); return this; }
public Builder setShortName(String shortName) { this.shortName = abbreviate(requireNonNull(shortName, NAME_CANNOT_BE_NULL), MAX_COMPONENT_NAME_LENGTH); return this; }
public DefaultIssue setMessage(@Nullable String s) { this.message = StringUtils.abbreviate(StringUtils.trim(s), MESSAGE_MAX_SIZE); return this; }
public static String reformatParam(@Nullable Object param) { if (param == null) { return PARAM_NULL; } String abbreviated = abbreviate(param.toString(), PARAM_MAX_WIDTH); return NEWLINE_PATTERN.matcher(abbreviated).replaceAll("\\\\n"); }
@Override public DefaultIssueLocation message(String message) { requireNonNull(message, "Message can't be null"); if (message.contains("\u0000")) { throw new IllegalArgumentException(unsupportedCharacterError(message, component)); } this.message = abbreviate(trim(message), MESSAGE_MAX_SIZE); return this; }
public Builder setDescription(@Nullable String description) { this.description = abbreviate(trimToNull(description), MAX_COMPONENT_DESCRIPTION_LENGTH); return this; }
private static void dumpPropIfNotSensitive(BufferedWriter fileWriter, String prop, String value) throws IOException { fileWriter.append(String.format(KEY_VALUE_FORMAT, prop, isSensitiveProperty(prop) ? "******" : StringUtils.abbreviate(value, MAX_WIDTH))).append('\n'); }
/** * @param input * input to test. * @param predicate * predicate to apply. * @throws IllegalArgumentException * if predicate didn't rejected input. */ public static void assertFalse( final Object input, final Predicate predicate ) throws IllegalArgumentException { if ( !predicate.evaluate( input ) ) { return; } final StringBuilder builder = new StringBuilder(); builder.append( "Predicate didn't rejected input [predicate=" ); builder.append( predicate ); builder.append( ", input=" ); builder.append( StringUtils.abbreviate( String.valueOf( input ), INPUT_MAX_WIDTH ) ); builder.append( "]" ); throw new IllegalArgumentException( builder.toString() ); }
/** * @param input * input to test. * @param predicate * predicate to apply. * @throws IllegalArgumentException * if predicate rejected input. */ public static void assertTrue( final Object input, final Predicate predicate ) throws IllegalArgumentException { if ( predicate.evaluate( input ) ) { return; } final StringBuilder builder = new StringBuilder(); builder.append( "Predicate rejected input [predicate=" ); builder.append( predicate ); builder.append( ", input=" ); builder.append( StringUtils.abbreviate( String.valueOf( input ), INPUT_MAX_WIDTH ) ); builder.append( "]" ); throw new IllegalArgumentException( builder.toString() ); }
return "..." + abbreviate(str.substring(offset), maxWidth - 3);
private static void logPaths(String label, Path baseDir, List<Path> paths) { if (!paths.isEmpty()) { StringBuilder sb = new StringBuilder(label); for (Iterator<Path> it = paths.iterator(); it.hasNext();) { Path file = it.next(); Optional<String> relativePathToBaseDir = PathResolver.relativize(baseDir, file); if (!relativePathToBaseDir.isPresent()) { sb.append(file); } else if (StringUtils.isBlank(relativePathToBaseDir.get())) { sb.append("."); } else { sb.append(relativePathToBaseDir.get()); } if (it.hasNext()) { sb.append(", "); } } if (LOG.isDebugEnabled()) { LOG.debug(sb.toString()); } else { LOG.info(StringUtils.abbreviate(sb.toString(), 80)); } } }
/** * convert "From src insert blah blah" to "From src insert ... blah" */ public static String abbreviate(String str, int max) { str = str.trim(); int len = str.length(); int suffixlength = 20; if (len <= max) { return str; } suffixlength = Math.min(suffixlength, (max - 3) / 2); String rev = StringUtils.reverse(str); // get the last few words String suffix = WordUtils.abbreviate(rev, 0, suffixlength, StringUtils.EMPTY); suffix = StringUtils.reverse(suffix); // first few .. String prefix = StringUtils.abbreviate(str, max - suffix.length()); return prefix + suffix; }
/** * convert "From src insert blah blah" to "From src insert ... blah" */ public static String abbreviate(String str, int max) { str = str.trim(); int len = str.length(); int suffixlength = 20; if (len <= max) { return str; } suffixlength = Math.min(suffixlength, (max - 3) / 2); String rev = StringUtils.reverse(str); // get the last few words String suffix = WordUtils.abbreviate(rev, 0, suffixlength, ""); suffix = StringUtils.reverse(suffix); // first few .. String prefix = StringUtils.abbreviate(str, max - suffix.length()); return prefix + suffix; }
/** * Constructor * * Note: The parameters are used to uniquely identify a HiveLockObject. * The parameters will be stripped off any ':' characters in order not * to interfere with the way the data is serialized (':' delimited string). * The query string might be truncated depending on HIVE_LOCK_QUERY_STRING_MAX_LENGTH * @param queryId The query identifier will be added to the object without change * @param lockTime The lock time will be added to the object without change * @param lockMode The lock mode will be added to the object without change * @param queryStr The query string might be truncated based on * HIVE_LOCK_QUERY_STRING_MAX_LENGTH conf variable * @param conf The hive configuration based on which we decide if we should truncate the query * string or not */ public HiveLockObjectData(String queryId, String lockTime, String lockMode, String queryStr, HiveConf conf) { this.queryId = removeDelimiter(queryId); this.lockTime = StringInternUtils.internIfNotNull(removeDelimiter(lockTime)); this.lockMode = removeDelimiter(lockMode); this.queryStr = StringInternUtils.internIfNotNull( queryStr == null ? null : StringUtils.abbreviate(removeDelimiter(queryStr.trim()), conf.getIntVar(HiveConf.ConfVars.HIVE_LOCK_QUERY_STRING_MAX_LENGTH))); }
private static String obfuscateValue(PropertyDefinitions definitions, String key, String value) { PropertyDefinition def = definitions.get(key); if (def != null && def.type() == PropertyType.PASSWORD) { return PASSWORD_VALUE; } if (endsWithIgnoreCase(key, ".secured") || containsIgnoreCase(key, "password") || containsIgnoreCase(key, "passcode") || AUTH_JWT_SECRET.getKey().equals(key)) { return PASSWORD_VALUE; } return abbreviate(value, MAX_VALUE_LENGTH); } }
null, this.jobConf.getBoolean(HiveConf.ConfVars.HIVE_IN_TEST.varname, HiveConf.ConfVars.HIVE_IN_TEST.defaultBoolVal)); explainOutput = StringUtils.abbreviate(tran.getName() + " Explain Plan:\n\n" + outputStream .toString(), 100000); LOG.debug(explainOutput);
private static CreateRequest toCreateRequest(Request request) { return CreateRequest.builder() .setOrganization(request.param(PARAM_ORGANIZATION)) .setKey(request.mandatoryParam(PARAM_PROJECT)) .setName(abbreviate(request.mandatoryParam(PARAM_NAME), MAX_COMPONENT_NAME_LENGTH)) .setBranch(request.param(PARAM_BRANCH)) .setVisibility(request.param(PARAM_VISIBILITY)) .build(); }
@Override public void handle(Request wsRequest, Response wsResponse) throws Exception { String organizationKey = wsRequest.getParam(PARAM_ORGANIZATION_KEY) .emptyAsNull() .or(defaultOrganizationProvider.get()::getKey); String projectKey = wsRequest.mandatoryParam(PARAM_PROJECT_KEY); String deprecatedBranch = wsRequest.param(PARAM_PROJECT_BRANCH); String projectName = abbreviate(defaultIfBlank(wsRequest.param(PARAM_PROJECT_NAME), projectKey), MAX_COMPONENT_NAME_LENGTH); Map<String, String> characteristics = parseTaskCharacteristics(wsRequest); try (InputStream report = new BufferedInputStream(wsRequest.mandatoryParamAsPart(PARAM_REPORT_DATA).getInputStream())) { CeTask task = reportSubmitter.submit(organizationKey, projectKey, deprecatedBranch, projectName, characteristics, report); Ce.SubmitResponse submitResponse = Ce.SubmitResponse.newBuilder() .setTaskId(task.getUuid()) .setProjectId(task.getComponent().get().getUuid()) .build(); WsUtils.writeProtobuf(submitResponse, wsRequest, wsResponse); } }