| author | kwilk | 2011-06-09 15:34:46 (EDT) |
|---|---|---|
| committer | Ryan D. Brooks | 2011-06-09 15:34:46 (EDT) |
| commit | fd9a7a19a0eef1d3a191847a7df6ba022a9458c9 (patch) (side-by-side diff) | |
| tree | e76edafd6aba7bdf76e6e9aa08a4c56005ec0f60 | |
| parent | 2cc094893cfa5cd2072a906b6b05e29ece4a7f1a (diff) | |
| download | org.eclipse.osee-fd9a7a19a0eef1d3a191847a7df6ba022a9458c9.zip org.eclipse.osee-fd9a7a19a0eef1d3a191847a7df6ba022a9458c9.tar.gz org.eclipse.osee-fd9a7a19a0eef1d3a191847a7df6ba022a9458c9.tar.bz2 | |
refactor: Addition of minimize() and small quality change to Strings utility class
| -rw-r--r-- | plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java | 18 |
1 files changed, 15 insertions, 3 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 b58979d..8ff7e30 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 @@ -62,14 +62,14 @@ public class Strings { /** * Will truncate string if necessary and add "..." to end if addDots and truncated */ - public static String truncate(String value, int length, boolean addDots) { + public static String truncate(String value, int length, boolean ellipsis) { if (value == null) { return emptyString(); } String toReturn = value; if (Strings.isValid(value) && value.length() > length) { - int len = addDots && length - 3 > 0 ? length - 3 : length; - toReturn = value.substring(0, Math.min(length, len)) + (addDots ? "..." : emptyString()); + int len = ellipsis && length - 3 > 0 ? length - 3 : length; + toReturn = value.substring(0, Math.min(length, len)) + (ellipsis ? "..." : emptyString()); } return toReturn; } @@ -98,6 +98,18 @@ public class Strings { } /** + * <p> + * Remove all <code>\n</code> and <code>\t</code>. + * </p> + * + * @param value + * @return + */ + public static String minimize(String value) { + return isValid(value) ? value.replaceAll("\n|\t", "") : value; + } + + /** * 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 } |

