private String constructInsertQuery(String tableName, List<List<Column>> columnLists) { StringBuilder sb = new StringBuilder(); sb.append("Insert into ").append(tableName).append(" ("); Collection<String> columnNames = Collections2.transform(columnLists.get(0), new Function<Column, String>() { @Override public String apply(Column input) { return input.getColumnName(); } }); String columns = Joiner.on(",").join(columnNames); sb.append(columns).append(") values ( "); String placeHolders = StringUtils.chop(StringUtils.repeat("?,", columnNames.size())); sb.append(placeHolders).append(")"); return sb.toString(); }
private static int processLine(String line) { int ret = 0; String command = ""; for (String oneCmd : line.split(";")) { if (StringUtils.endsWith(oneCmd, "\\")) { command += StringUtils.chop(oneCmd) + ";"; continue; } else { command += oneCmd; } if (StringUtils.isBlank(command)) { continue; } ret = processCmd(command); command = ""; } return ret; }
/** * Process command line. * * @param line the command line * @return the int execution result code */ public int processLine(String line) { int lastRet = 0; int ret = 0; String command = ""; for (String oneCmd : line.split(";")) { if (StringUtils.endsWith(oneCmd, "\\")) { command += StringUtils.chop(oneCmd) + ";"; continue; } else { command += oneCmd; } if (StringUtils.isBlank(command)) { continue; } ret = processCmd(command); command = ""; lastRet = ret; if (ret != 0) { return ret; } } return lastRet; }
command += StringUtils.chop(oneCmd) + ";"; continue; } else {
/** * @param num number of times to repeat the pattern * @return bind variables repeated num times */ protected String getBindVariables(String pattern, int num) { return StringUtils.chop(StringUtils.repeat(pattern, num)); }
/** * @param num number of times to repeat the pattern * @return bind variables repeated num times */ default String getBindVariables(String pattern, int num) { return StringUtils.chop(StringUtils.repeat(pattern, num)); }
/** * @param num number of times to repeat the pattern * @return bind variables repeated num times */ protected String getBindVariables(String pattern, int num) { return StringUtils.chop(StringUtils.repeat(pattern, num)); }
/** * Replaces references to collection elements to their respective plural names WARNING: this method is totally lame and I for * one wished it didn't have to exist * * @param name the property name with perhaps collection elements in * @return the corrected name */ protected String replaceCollectionElementsWithPlurals(String name) { String temp = name.replaceAll("\\[\\d+\\]", "s"); // now - need to check if the property name ends with a double "s", which is incorrect if ( temp.endsWith( "ss" ) ) { temp = StringUtils.chop(temp); } return temp; }
/** * Creates a comma separated string of source root directories. * * @param dirs the names to concatenate. * @return the concatenated string. */ private static String createSourceRootString(final Collection<String> dirs) { final StringBuilder buffer = new StringBuilder(); for (String dir : dirs) { buffer.append(dir).append(','); } return StringUtils.chop(buffer.toString()); }
/** * Creates a {@link File#pathSeparatorChar} separated string of source root * directories. * * @param dirs the names to concatenate. * @return the concatenated string. */ private static String createClassRootString(final Collection<String> dirs) { final StringBuilder buffer = new StringBuilder(); for (String dir : dirs) { buffer.append(dir).append(File.pathSeparatorChar); } return StringUtils.chop(buffer.toString()); }
/** * Default constructor. * * @param path the path to match. */ public Matcher(final String path) { this.wildcardMatch = Arg.checkNotNull("path", path).endsWith("*"); this.path = wildcardMatch ? StringUtils.chop(path) : path; }
@Override public String getInternalAddonBaseUrl(String pluginKey) { String productBase = applicationProperties.getBaseUrl(UrlMode.CANONICAL); if (productBase.endsWith("/")) { productBase = StringUtils.chop(productBase); } return productBase + AddonTestFilter.FILTER_MAPPING + "/" + pluginKey; }
protected String extractRequestString(final String requestUri) { String cleanUri = StringUtils.trim(requestUri); if (cleanUri.endsWith(SLASH)) { cleanUri = StringUtils.chop(cleanUri); } cleanUri = StringUtils.removeStart(cleanUri, SLASH); String requestString = cleanUri; if (StringUtils.contains(requestString, SLASH)) { requestString = StringUtils.substringAfter(requestString, SLASH); if (StringUtils.contains(requestString, QUESTION_MARK)) { requestString = StringUtils.substringBefore(requestString, QUESTION_MARK); } } return requestString; }
/** * adds a mapping from the service specific portion of the service URL to the service name. */ public void register(ServiceDefinition serviceDefinition) { String serviceUrlBase = trimServiceUrlBase(serviceDefinition.getEndpointUrl().toExternalForm()); if (serviceUrlBase.endsWith("/")) { serviceUrlBase = StringUtils.chop(serviceUrlBase); } servicePathToQName.put(serviceUrlBase, serviceDefinition.getServiceName()); }
private static int processLine(String line) { int ret = 0; String command = ""; for (String oneCmd : line.split(";")) { if (StringUtils.endsWith(oneCmd, "\\")) { command += StringUtils.chop(oneCmd) + ";"; continue; } else { command += oneCmd; } if (StringUtils.isBlank(command)) { continue; } ret = processCmd(command); command = ""; } return ret; }
private static int processLine(String line) { int ret = 0; String command = ""; for (String oneCmd : line.split(";")) { if (StringUtils.endsWith(oneCmd, "\\")) { command += StringUtils.chop(oneCmd) + ";"; continue; } else { command += oneCmd; } if (StringUtils.isBlank(command)) { continue; } ret = processCmd(command); command = ""; } return ret; }
@Override public String getQueryString() { String queryString = super.getQueryString(); // If query string ends with an ampersand, take it off if (StringUtils.endsWith(queryString, "&")) { queryString = StringUtils.chop(queryString); } return queryString; } }
/** * Verifies that for every method's parameter a "@param" tag followed by the parameter's name * is present in the ASDoc. */ private static void checkForParametersASDoc(ASDocCheck check, MethodASDoc methodASDoc, AstNode functionDef) { StringBuilder builder = new StringBuilder(); for (AstNode parameter : Function.getParametersIdentifiers(functionDef)) { String paramValue = parameter.getTokenValue(); if (!methodASDoc.isParameterDocumented(paramValue)) { builder.append(paramValue).append(", "); } } if (builder.length() > 0) { String message = MessageFormat.format("Add the missing \"@param\" ASDoc for: {0}.", StringUtils.chop(builder.toString().trim())); check.addIssue(message, functionDef); } }
protected String extractPackageName(File file, File directory) { String packageName = StringUtils.removeStart(file.getPath(), directory.getPath()); packageName = StringUtils.replaceChars(packageName, '\\', '/'); packageName = StringUtils.substringBeforeLast(packageName, "/"); packageName = StringUtils.replaceChars(packageName, '/', '.'); if (packageName.endsWith(".")) { packageName = StringUtils.chop(packageName); } if (packageName.startsWith(".")) { packageName = StringUtils.substringAfter(packageName, "."); } return packageName; } }
/** * Verifies that for every method's parameter a "@param" tag followed by the parameter's name * is present in the ASDoc. */ private void checkForParametersASDoc(ASDocCheck check, MethodASDoc methodASDoc, AstNode functionDef) { StringBuilder builder = new StringBuilder(); for (AstNode parameter : Function.getParametersIdentifiers(functionDef)) { String paramValue = parameter.getTokenValue(); if (!methodASDoc.isParameterDocumented(paramValue)) { builder.append(paramValue).append(", "); } } if (builder.length() > 0) { check.getContext().createLineViolation(check, "Add the missing \"@param\" ASDoc for: {0}.", functionDef, StringUtils.chop(builder.toString().trim())); } }