/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/* WBN Valentine's Day, 2000 -- place for handy String utils.
*/
public class StringUtils {
private StringUtils() {
}
////////////////////////////////////////////////////////////////////////////
/**
* return the length of the String - or 0 if it's null
*/
if (s == null) {
return 0;
}
return s.length();
}
////////////////////////////////////////////////////////////////////////////
}
////////////////////////////////////////////////////////////////////////////
String s = "SQLException:\n";
do {
s += "\n";
return s;
}
////////////////////////////////////////////////////////////////////////////
// find longest String in a vector of Strings...
int max = 0;
return 0;
}
}
}
return max;
}
////////////////////////////////////////////////////////////////////////////
// is this the String representation of a valid hex number?
// "5", "d", "D", "F454ecbb" all return true...
// p.s. there MUST be a better and faster way of doing this...
for (int i = 0; i < slen; i++) {
return false;
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////
public static boolean isHex(char c) {
// is this the char a valid hex digit?
for (int i = 0; i < hexlen; i++) {
return true;
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////
// e.g. input: "a/b/c/d/foobar.txt" output: "d"
return s;
}
// must be a plain file name -- return empty string...
return "";
}
if (index < 0) {
return ""; // can't happen!!!
}
if (index >= 0) {
}
return s;
}
////////////////////////////////////////////////////////////////////////////
}
return className;
}
////////////////////////////////////////////////////////////////////////////
return s;
}
s += ' ';
}
return s;
}
////////////////////////////////////////////////////////////////////////////
return s;
}
ss += ' ';
}
return ss + s;
}
////////////////////////////////////////////////////////////////////////////
if (s == null) {
return new String[0];
}
int start = 0;
int end = 0;
}
}
return ss;
}
////////////////////////////////////////////////////////////////////////////
}
}
////////////////////////////////////////////////////////////////////////////
return s;
}
}
////////////////////////////////////////////////////////////////////////////
return s;
}
if (index < 0) {
return s;
}
return ret;
}
////////////////////////////////////////////////////////////////////////////
return "No entries";
}
// first -- to line things up nicely -- find the longest key...
int keyWidth = 0;
}
}
++keyWidth;
// now make the strings...
}
}
// Test Code...
testToLine();
} else {
usage();
}
}
////////////////////////////////////////////////////////////////////////////
private static void usage() {
}
////////////////////////////////////////////////////////////////////////////
}
}
////////////////////////////////////////////////////////////////////////////
private static void testToLine() {
null,
"",
"abc\ndef\n",
"abc\ndef",
"abc",
"abc\n",
"abc\n\n",
"q",
"\n\nk\n\nz\n\n",
"sd.adj;ld"
};
}
}
}
public static void testUpperCase() {
}
}
/**
A utility to get the Operating System specific path from given array
of Strings.
@param strings an array of Strings participating in the path.
@param addTrailing a boolean that determines whether the returned
String should have a trailing File Separator character. None of
the strings may be null or empty String. An exception is thrown.
@return a String that concatenates these Strings and gets a path. Returns
a null if the array is null or contains no elements.
@throws IllegalArgumentException if any of the arguments is null or is
an empty string.
*/
path = new StringBuffer();
throw new IllegalArgumentException();
}
}
}
if (addTrailing) {
}
}
}
/**
* Parses a string containing substrings separated from
* each other by the standard separator characters and returns
* a list of strings.
*
* Splits the string <code>line</code> into individual string elements
* separated by the field separators, and returns these individual
* strings as a list of strings. The individual string elements are
* trimmed of leading and trailing whitespace. Only non-empty strings
* are returned in the list.
*
* @param line The string to split
* @return Returns the list containing the individual strings that
* the input string was split into.
*/
}
/**
* Parses a string containing substrings separated from
* each other by the specified set of separator characters and returns
* a list of strings.
*
* Splits the string <code>line</code> into individual string elements
* separated by the field separators specified in <code>sep</code>,
* and returns these individual strings as a list of strings. The
* individual string elements are trimmed of leading and trailing
* whitespace. Only non-empty strings are returned in the list.
*
* @param line The string to split
* @param sep The list of separators to use for determining where the
* string should be split. If null, then the standard
* separators (see StringTokenizer javadocs) are used.
* @return Returns the list containing the individual strings that
* the input string was split into.
*/
return null;
}
} else {
}
while (st.hasMoreTokens()) {
}
}
return tokens;
}
/**
* Get a system propety given a property name, possibly trying all combination
* of upercase, name mangling to get a value.
*
* @param propName the approximate system property name
* @return the property value if found, null otherwise
*/
// xxx.yyy
return value;
}
// XXX.YYY
return value;
}
// xxx_yyy
return value;
}
// XXX_YYY
}
return value;
}
/**
* Remove a character from a String
*
* @param strOrig original string
* @param c character to remove from the string
* @return String with specified characters removed
*/
}
}
return strNew;
}
t.printStackTrace(pw);
}
}
if(isToken(s))
// NO possible wrong assumptions here -- see isToken()
else
return s; // GIGO
}
/**
* Concatenate a list of strings, putting a separator in between each one.
* If the list is one string, then the separator is not used.
* The separator will never be added to the start or end of the returned
* string.
* When empty or null strings are encountered in the list of strings
* they are ignore.
*
* @param separator Separator to use between concatenated strings
* @param list List of strings to concatenate together
* @return String created by concatenating provided strings
*/
boolean first = true;
// Skip empty or null strings
if (!StringUtils.ok(s)) {
continue;
}
if (!first) {
} else {
first = false;
}
}
}
/**
* Removes the quoting around a String.
* @param s The String that may have enclosing quotes
* @return The String resulting from removing the enclosing quotes
*/
if (s == null)
return null;
if (isDoubleQuoted(s) || isSingleQuoted(s)) {
}
return s;
}
/**
* Nightmares can result from using a path with a space in it!
* This method will enclose in quotes if needed.
* @param path
* @return
*/
|| !needsQuoting(path)
|| isDoubleQuoted(path)
|| isSingleQuoted(path))
return path;
// needs quoting!
}
}
}
}
}