From 7692fa077a84972231948354d3f0de99f27a9ad7 Mon Sep 17 00:00:00 2001 From: student Date: Fri, 7 Apr 2017 11:34:00 -0400 Subject: Fix property bugs --- .../main/java/bjc/utils/funcutils/StringUtils.java | 72 +++++++++++----------- 1 file changed, 35 insertions(+), 37 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcutils') diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java index 540fb39..d5eaadf 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java @@ -16,53 +16,51 @@ public class StringUtils { * expression * * @param input - * The string to check - * @param regex - * The regex to see if the string only contains matches - * of - * @return Whether or not the string consists only of multiple matches - * of the provided regex + * The string to check + * @param rRegex + * The regex to see if the string only contains matches of + * @return Whether or not the string consists only of multiple matches of + * the provided regex */ - public static boolean containsOnly(String input, String regex) { - if(input == null) + public static boolean containsOnly(String input, String rRegex) { + if (input == null) throw new NullPointerException("Input must not be null"); - else if(regex == null) throw new NullPointerException("Regex must not be null"); + else if (rRegex == null) + throw new NullPointerException("Regex must not be null"); /* * This regular expression is fairly simple. * * First, we match the beginning of the string. Then, we start a - * non-capturing group whose contents are the passed in regex. - * That group is then matched one or more times and the pattern - * matches to the end of the string + * non-capturing group whose contents are the passed in regex. That + * group is then matched one or more times and the pattern matches to + * the end of the string */ - return input.matches("\\A(?:" + regex + ")+\\Z"); + return input.matches("\\A(?:" + rRegex + ")+\\Z"); } /** * Indent the string being built in a StringBuilder n levels * * @param builder - * The builder to indent in + * The builder to indent in * @param levels - * The number of levels to indent + * The number of levels to indent */ public static void indentNLevels(StringBuilder builder, int levels) { - for(int i = 0; i < levels; i++) { + for (int i = 0; i < levels; i++) { builder.append("\t"); } } /** - * Print out a deque with a special case for easily showing a deque is - * empty + * Print out a deque with a special case for easily showing a deque is empty * * @param - * The type in the deque + * The type in the deque * @param queue - * The deque to print - * @return A string version of the deque, with allowance for an empty - * deque + * The deque to print + * @return A string version of the deque, with allowance for an empty deque */ public static String printDeque(Deque queue) { return queue.isEmpty() ? "(none)" : queue.toString(); @@ -72,17 +70,17 @@ public class StringUtils { * Converts a sequence to an English list. * * @param objects - * The sequence to convert to an English list. + * The sequence to convert to an English list. * @param join - * The string to use for separating the last element from - * the rest. + * The string to use for separating the last element from the + * rest. * @param comma - * The string to use as a comma + * The string to use as a comma * * @return The sequence as an English list. */ public static String toEnglishList(Object[] objects, String join, String comma) { - if(objects == null) { + if (objects == null) { throw new NullPointerException("Sequence must not be null"); } @@ -91,7 +89,7 @@ public class StringUtils { String joiner = join; String coma = comma; - switch(objects.length) { + switch (objects.length) { case 0: /* * Empty list. @@ -115,7 +113,7 @@ public class StringUtils { /* * Three or more items. */ - for(int i = 0; i < objects.length - 1; i++) { + for (int i = 0; i < objects.length - 1; i++) { sb.append(objects[i].toString()); sb.append(coma + " "); } @@ -137,10 +135,10 @@ public class StringUtils { * Converts a sequence to an English list. * * @param objects - * The sequence to convert to an English list. + * The sequence to convert to an English list. * @param join - * The string to use for separating the last element from - * the rest. + * The string to use for separating the last element from the + * rest. * * @return The sequence as an English list. */ @@ -152,14 +150,14 @@ public class StringUtils { * Converts a sequence to an English list. * * @param objects - * The sequence to convert to an English list. + * The sequence to convert to an English list. * @param and - * Whether to use 'and' or 'or'. + * Whether to use 'and' or 'or'. * * @return The sequence as an English list. */ public static String toEnglishList(Object[] objects, boolean and) { - if(and) { + if (and) { return toEnglishList(objects, "and"); } else { return toEnglishList(objects, "or"); @@ -170,7 +168,7 @@ public class StringUtils { * Count the number of graphemes in a string. * * @param value - * The string to check. + * The string to check. * * @return The number of graphemes in the string. */ @@ -179,7 +177,7 @@ public class StringUtils { it.setText(value); int count = 0; - while(it.next() != BreakIterator.DONE) { + while (it.next() != BreakIterator.DONE) { count++; } -- cgit v1.2.3