diff options
Diffstat (limited to 'plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java')
-rw-r--r-- | plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java | 132 |
1 files changed, 66 insertions, 66 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 13e9e9e766c..0716a0d9dac 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 @@ -1,70 +1,70 @@ -/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osee.framework.jdk.core.util;
-
-/**
- * @author Jeff C. Phillips
- * @author Don Dunne
- * @author Karol M. Wilk
- */
-public class Strings {
- private final static String EMPTY_STRING = "";
-
- public static boolean isValid(String value) {
- return value != null && value.length() > 0;
- }
-
- public static String emptyString() {
- return EMPTY_STRING;
- }
-
- /**
+/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ + +package org.eclipse.osee.framework.jdk.core.util; + +/** + * @author Jeff C. Phillips + * @author Don Dunne + * @author Karol M. Wilk + */ +public class Strings { + private final static String EMPTY_STRING = ""; + + public static boolean isValid(String 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. - * @return a string with doubled ampersands.
- */
+ * @return a string with doubled ampersands. + */ public static String escapeAmpersands(String stringWithAmp) { - if (isValid(stringWithAmp)) {
- return stringWithAmp.replace("&", "&&");
- } else {
- return null;
- }
- }
-
- public static String intern(String str) {
- if (str == null) {
- return null;
- }
- return str.intern();
- }
-
- /**
- * Will truncate string if necessary and add "..." to end if addDots and truncated
- */
- public static String truncate(String value, int length, boolean addDots) {
- if (value == null) {
- return "";
- }
- 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 ? "..." : "");
- }
- return toReturn;
- }
-
- public static String truncate(String value, int length) {
- return truncate(value, length, false);
- }
-
-}
+ if (isValid(stringWithAmp)) { + return stringWithAmp.replace("&", "&&"); + } else { + return null; + } + } + + public static String intern(String str) { + if (str == null) { + return null; + } + return str.intern(); + } + + /** + * Will truncate string if necessary and add "..." to end if addDots and truncated + */ + public static String truncate(String value, int length, boolean addDots) { + if (value == null) { + return ""; + } + 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 ? "..." : ""); + } + return toReturn; + } + + public static String truncate(String value, int length) { + return truncate(value, length, false); + } + +} |