summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2011-04-18 16:02:10 (EDT)
committer Ryan D. Brooks2011-04-18 16:02:10 (EDT)
commit2a92bc7de8e3143e7b5f55814b86b02b6e833c07 (patch)
treedf9d688968e8311c2b4698b7a93a000b848649d6
parent2d073757354746d5fb1b31d788e4d57c8e4bf9a6 (diff)
downloadorg.eclipse.osee-2a92bc7de8e3143e7b5f55814b86b02b6e833c07.zip
org.eclipse.osee-2a92bc7de8e3143e7b5f55814b86b02b6e833c07.tar.gz
org.eclipse.osee-2a92bc7de8e3143e7b5f55814b86b02b6e833c07.tar.bz2
refactor: Cleanup for Strings utility class
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java27
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java2
2 files changed, 14 insertions, 15 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java
index aa14340..a2b3a9f 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java
@@ -26,14 +26,14 @@ public class Strings {
}
/**
- * Don't remove this function without coordinating the change with the OTE source code.
+ * OTE pre-compile dependency. Left for binary compatibility for 0.9.8
*/
public static boolean isValid(String value) {
return value != null && value.length() > 0;
}
- public static boolean isValid(String... values) {
- for (String value : values) {
+ public static boolean isValid(CharSequence... values) {
+ for (CharSequence value : values) {
if (value == null || value.length() == 0) {
return false;
}
@@ -41,17 +41,13 @@ public class Strings {
return true;
}
- public static boolean isValid(CharSequence value) {
- return value != null && value.length() > 0;
- }
-
public static String emptyString() {
return EMPTY_STRING;
}
/**
- * This method adjusts '&'-containing strings to break the keyboard shortcut ("Accelerator") feature some widgets
- * offer, where &Test will make Alt+T a shortcut. This method breaks the accelerator by escaping ampersands.
+ * Adjusts '&'-containing strings to break the keyboard shortcut ("Accelerator") feature some widgets offer, where
+ * &Test will make Alt+T a shortcut. This method breaks the accelerator by escaping ampersands.
*
* @return a string with doubled ampersands.
*/
@@ -109,17 +105,20 @@ public class Strings {
}
/**
+ * Provides a nicer list of items with an 'and' at the end. This could be done using iterator().
+ *
+ * @param items Lists of form { apple, banana, orange } or { apple, banana }
* @return string of form "apple, banana and orange" or "apple and banana" depending on size of list
*/
- public static String buildItemizedStatment(List<?> items) {
+ public static String buildStatment(List<?> items) {
StringBuilder niceList = new StringBuilder();
if (items.size() >= 2) {
int andIndex = items.size() - 2;
- for (int branchIndex = 0; branchIndex < items.size(); branchIndex++) {
- niceList.append(items.get(branchIndex));
- if (branchIndex == andIndex) {
+ for (int itemIndex = 0; itemIndex < items.size(); itemIndex++) {
+ niceList.append(items.get(itemIndex));
+ if (itemIndex == andIndex) {
niceList.append(" and ");
- } else if (branchIndex < andIndex) {
+ } else if (itemIndex < andIndex) {
niceList.append(", ");
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java
index b62e727..f829f03 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java
@@ -77,7 +77,7 @@ public abstract class GeneralBranchHandler extends CommandHandler {
private String buildDialogMessage(List<Branch> selectedBranches, String actionDesc) {
StringBuilder branchesStatement = new StringBuilder();
branchesStatement.append(String.format("Are you sure you want to %s branch(es): ", actionDesc));
- branchesStatement.append(Strings.buildItemizedStatment(selectedBranches));
+ branchesStatement.append(Strings.buildStatment(selectedBranches));
branchesStatement.append(" \u003F");
return branchesStatement.toString();
}