From 699e71e76b15081baf746c6ce9c9144f7e5f1ff9 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Mon, 30 Sep 2013 10:11:28 -0400 Subject: [PATCH] Trim trailing whitespace and organize imports --- src/main/java/com/gitblit/utils/StringUtils.java | 108 +++++++++++++++++++++++++++--------------------------- 1 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/gitblit/utils/StringUtils.java b/src/main/java/com/gitblit/utils/StringUtils.java index cff3577..5e62778 100644 --- a/src/main/java/com/gitblit/utils/StringUtils.java +++ b/src/main/java/com/gitblit/utils/StringUtils.java @@ -40,9 +40,9 @@ /** * Utility class of string functions. - * + * * @author James Moger - * + * */ public class StringUtils { @@ -52,7 +52,7 @@ /** * Returns true if the string is null or empty. - * + * * @param value * @return true if string is null or empty */ @@ -62,7 +62,7 @@ /** * Replaces carriage returns and line feeds with html line breaks. - * + * * @param string * @return plain text with html line breaks */ @@ -73,7 +73,7 @@ /** * Prepare text for html presentation. Replace sensitive characters with * html entities. - * + * * @param inStr * @param changeSpace * @return plain text escaped for html @@ -104,7 +104,7 @@ /** * Decode html entities back into plain text characters. - * + * * @param inStr * @return returns plain text from html */ @@ -115,7 +115,7 @@ /** * Encodes a url parameter by escaping troublesome characters. - * + * * @param inStr * @return properly escaped url */ @@ -137,7 +137,7 @@ /** * Flatten the list of strings into a single string with a space separator. - * + * * @param values * @return flattened list */ @@ -148,7 +148,7 @@ /** * Flatten the list of strings into a single string with the specified * separator. - * + * * @param values * @param separator * @return flattened list @@ -169,7 +169,7 @@ * Returns a string trimmed to a maximum length with trailing ellipses. If * the string length is shorter than the max, the original string is * returned. - * + * * @param value * @param max * @return trimmed string @@ -184,7 +184,7 @@ /** * Left pad a string with the specified character, if the string length is * less than the specified length. - * + * * @param input * @param length * @param pad @@ -205,7 +205,7 @@ /** * Right pad a string with the specified character, if the string length is * less then the specified length. - * + * * @param input * @param length * @param pad @@ -225,7 +225,7 @@ /** * Calculates the SHA1 of the string. - * + * * @param text * @return sha1 of the string */ @@ -240,7 +240,7 @@ /** * Calculates the SHA1 of the byte array. - * + * * @param bytes * @return sha1 of the byte array */ @@ -257,7 +257,7 @@ /** * Calculates the MD5 of the string. - * + * * @param string * @return md5 of the string */ @@ -268,10 +268,10 @@ throw new RuntimeException(u); } } - + /** * Calculates the MD5 of the string. - * + * * @param string * @return md5 of the string */ @@ -289,17 +289,17 @@ /** * Returns the hex representation of the byte array. - * + * * @param bytes * @return byte array as hex string */ private static String toHex(byte[] bytes) { StringBuilder sb = new StringBuilder(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { - if (((int) bytes[i] & 0xff) < 0x10) { + if ((bytes[i] & 0xff) < 0x10) { sb.append('0'); } - sb.append(Long.toString((int) bytes[i] & 0xff, 16)); + sb.append(Long.toString(bytes[i] & 0xff, 16)); } return sb.toString(); } @@ -307,7 +307,7 @@ /** * Returns the root path of the specified path. Returns a blank string if * there is no root path. - * + * * @param path * @return root path or blank */ @@ -321,7 +321,7 @@ /** * Returns the path remainder after subtracting the basePath from the * fullPath. - * + * * @param basePath * @param fullPath * @return the relative path @@ -341,7 +341,7 @@ /** * Splits the space-separated string into a list of strings. - * + * * @param value * @return list of strings */ @@ -351,7 +351,7 @@ /** * Splits the string into a list of string by the specified separator. - * + * * @param value * @param separator * @return list of strings @@ -359,7 +359,7 @@ public static List<String> getStringsFromValue(String value, String separator) { List<String> strings = new ArrayList<String>(); try { - String[] chunks = value.split(separator + "(?=([^\"]*\"[^\"]*\")*[^\"]*$)"); + String[] chunks = value.split(separator + "(?=([^\"]*\"[^\"]*\")*[^\"]*$)"); for (String chunk : chunks) { chunk = chunk.trim(); if (chunk.length() > 0) { @@ -379,7 +379,7 @@ /** * Validates that a name is composed of letters, digits, or limited other * characters. - * + * * @param name * @return the first invalid character found or null if string is acceptable */ @@ -402,7 +402,7 @@ /** * Simple fuzzy string comparison. This is a case-insensitive check. A * single wildcard * value is supported. - * + * * @param value * @param pattern * @return true if the value matches the pattern @@ -431,7 +431,7 @@ /** * Compare two repository names for proper group sorting. - * + * * @param r1 * @param r2 * @return @@ -459,7 +459,7 @@ /** * Sort grouped repository names. - * + * * @param list */ public static void sortRepositorynames(List<String> list) { @@ -476,7 +476,7 @@ for (char c : getMD5(value.toLowerCase()).toCharArray()) { cs += c; } - int n = (cs % 360); + int n = (cs % 360); float hue = ((float) n) / 360; return hsvToRgb(hue, 0.90f, 0.65f); } @@ -514,10 +514,10 @@ String bs = Integer.toHexString((int) (b * 256)); return "#" + rs + gs + bs; } - + /** * Strips a trailing ".git" from the value. - * + * * @param value * @return a stripped value or the original value if .git is not found */ @@ -527,10 +527,10 @@ } return value; } - + /** * Count the number of lines in a string. - * + * * @param value * @return the line count */ @@ -540,10 +540,10 @@ } return value.split("\n").length; } - + /** * Returns the file extension of a path. - * + * * @param path * @return a blank string or a file extension */ @@ -554,13 +554,13 @@ } return ""; } - + /** * Replace all occurences of a substring within a string with * another string. - * + * * From Spring StringUtils. - * + * * @param inString String to examine * @param oldPattern String to replace * @param newPattern String to insert @@ -582,12 +582,12 @@ // remember to append any characters to the right of a match return sb.toString(); } - + /** * Decodes a string by trying several charsets until one does not throw a * coding exception. Last resort is to interpret as UTF-8 with illegal * character substitution. - * + * * @param content * @param charsets optional * @return a string @@ -620,12 +620,12 @@ } return value; } - + /** * Attempt to extract a repository name from a given url using regular * expressions. If no match is made, then return whatever trails after * the final / character. - * + * * @param regexUrls * @return a repository path */ @@ -644,7 +644,7 @@ } return url; } - + /** * Converts a string with \nnn sequences into a UTF-8 encoded string. * @param input @@ -662,7 +662,7 @@ // strip leading \ character String oct = m.group().substring(1); bytes.write(Integer.parseInt(oct, 8)); - i = m.end(); + i = m.end(); } if (bytes.size() == 0) { // no octal matches @@ -679,11 +679,11 @@ } return input; } - + /** * Returns the first path element of a path string. If no path separator is - * found in the path, an empty string is returned. - * + * found in the path, an empty string is returned. + * * @param path * @return the first element in the path */ @@ -693,10 +693,10 @@ } return ""; } - + /** * Returns the last path element of a path string - * + * * @param path * @return the last element in the path */ @@ -706,10 +706,10 @@ } return path; } - + /** * Variation of String.matches() which disregards case issues. - * + * * @param regex * @param input * @return true if the pattern matches @@ -719,11 +719,11 @@ Matcher m = p.matcher(input); return m.matches(); } - + /** * Removes new line and carriage return chars from a string. * If input value is null an empty string is returned. - * + * * @param input * @return a sanitized or empty string */ -- Gitblit v1.9.1