/* XBN Java: Generically useful, non-GUI Java code. http://sourceforge.net/projects/xbnjava Copyright (C) 1997-2003, Jeff Epstein All rights reserved. Modifications: No Redistribution in binary form, with or without modifications, are permitted provided that the following conditions are met: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * If modifications are made to source code then this license should indicate that fact in the "Modifications" section above. * Neither the author, nor the contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [NOTE: This license contains NO advertising clause.] */ package xbn.string; import xbn.placeholder.i_i_i; import java.util.Date; import java.text.SimpleDateFormat; import java.text.ParseException; /**
Random functions for java.lang.Strings. See String.
Source code: UtilString.java. Unit tests: xbn_junit.string.JUTUtilString.java and also see the unit tests for UtilSOB..
To shorten code and Javadoc.
Equal to "xbn.string.UtilString."
**/ public static final String sUS = "xbn.string.UtilString."; /**Create a UtilString. This constructor does nothing.
**/ public UtilString() { } private UtilChar uChar = new UtilChar(); public final String[] getAOHexDigitAsStr(String s_tr) { String[] as = new String[s_tr.length()]; try { for(int i = 0; i < s_tr.length(); i++) { as[i] = uChar.getHexDigitAsString(s_tr.charAt(i)); } } catch(NullPointerException npx) { throwAX("getAOHexDigitAsStr: s_tr is null."); } return as; } /**Get a random hex number with the requested number of digits.
@param i_digits The number of digits in length the returned value should be. Must be greater than -1. @return "" If i_digits is zero.Conditionally get the string, if it's not null.
Equal to getConditional(s_value, "")
Conditionally get the string, if it's not null.
Equal to getConditional(null, s_value, null, s_whenObjectNull)
Convenience function to conditionally display a variable when non-null.
Equal to getConditional(s_prefix, s_value, s_postfix, "")
Convenience function to conditionally display a variable when non-null.
Equal to getConditional(s_prefix, s_value, s_postfix, s_whenValueNull, "")
Get the string value (plus prefix and postfix) only when not-null. When null, get the alternative ("when-null") value.
@param s_prefix The string to put before the non-null value. When null, no prefix is used (which is the same behavior as when this is equal to empty string). @param s_value The value. When null, all parameters except s_whenValueNull are ignored. When not null, (only) s_whenValueNull is ignored. @param s_prefix The string to put after the non-null value. When null, no postfix is used (which is the same behavior as when this is equal to empty string). @param s_whenValueNull When s_value is null, then this is the entire text that is returned (no prefix or postfix). When s_value is not null, this parameter is ignored. May be null or any number of characters in length. To emphasize, if both an s_value are null, then 'null' is returned. @param s_whenValueEmpty When s_value is zero characters in length, then this is the entire text that is returned (no prefix or postfix). When s_value is not empty, this parameter is ignored. May be null or any number of characters in length. This behaves in the same manner as s_whenValueNull, when s_value is empty. @return s_whenValueNull If s_value is null.s_prefix + s_value + s_postfix
If s_value is not null. Note that if s_prefix is null, it is omitted. If s_postfix is null, it is omitted.
**/
public String getConditional(String s_prefix, String s_value, String s_postfix, String s_whenValueNull, String s_whenValueEmpty) {
if(s_value == null) {
return s_whenValueNull;
}
if(s_value.length() < 1) {
return s_whenValueEmpty;
}
StringBuffer sb = new StringBuffer(s_value);
if(s_prefix != null) {
//There is a prefix, and it goes first, before
//everything else.
sb.insert(0, s_prefix);
}
if(s_postfix != null) {
//There is a prefix, and it goes last, after
//everything else.
sb.append(s_postfix);
}
return sb.toString();
}
/**
Get a boolean from the value in the string.
@param s_potentialBoolean The string containing a boolean value. @return true If s_potentialBoolean equals "true" (case sensitive).Get an int from the value in the string.
Equal to getInt(s_potentialInt, false)
Get an int from the value in the string.
TODO: A critical difference between this and isNumber: This function uses Integer.valueOf
, and therefore a huge number (like 8374018734087120847104387208472784) is considered invalid according to this function, but valid according to isNumber (would return true).
Integer.valueOf(s_potentialInt).intValue()
**/
public int getInt(String s_potentialInt, boolean b_nfxInsteadOfax) {
throwAXIfNull(s_potentialInt, "s_potentialInt", "getInt");
try {
return Integer.valueOf(s_potentialInt).intValue();
} catch(NumberFormatException nfx) {
String sMsg = "ERROR in UtilString.getInt: s_potentialInt ('" + s_potentialInt + "') is not null, but is also not a valid int according Integer.valueOf('" + s_potentialInt + "').intValue().";
if(b_nfxInsteadOfax) {
throw new NumberFormatException(sMsg);
}
//They want ax and not nfx
throwAX(sMsg);
}
//Never reached. Required for compile.
return -1;
}
/**
Get an long from the value in the string.
Equal to getLong(s_potentialLong, false)
Get an long from the value in the string.
@param s_potentialLong The string containing an long value. @param b_nfxInsteadOfax If the s_potentialLong is null, or contains an illegal value, according toLong.valueOf(s_potentialLong).longValue()
**/
public long getLong(String s_potentialLong, boolean b_nfxInsteadOfax) {
throwAXIfNull(s_potentialLong, "s_potentialLong", "getLong");
try {
return Long.valueOf(s_potentialLong).longValue();
} catch(NumberFormatException nfx) {
String sMsg = "ERROR in UtilString.getLong: s_potentialLong ('" + s_potentialLong + "') is not null, but is also not a valid long according Long.valueOf('" + s_potentialLong + "').longValue().";
if(b_nfxInsteadOfax) {
throw new NumberFormatException(sMsg);
}
//They want ax and not nfx
throwAX(sMsg);
}
//Never reached. Required for compile.
return -1;
}
/**
Get a Date object from the potential date string and date format.
@returngetDate(s_potentialDate, new SimpleDateFormat(s_dateFormat))
**/
public Date getDate(String s_potentialDate, String s_dateFormat) {
try {
getDate(s_potentialDate, new SimpleDateFormat(s_dateFormat));
} catch(NullPointerException npx) {
throwAX("getDate: s_dateFormat is null.");
} catch(IllegalArgumentException iax) {
throwAX("getDate: s_dateFormat ('" + s_dateFormat + "') is illegal according to SimpleDateFormat.constructor: " + iax.toString());
}
//Never reached. Required for compile.
return null;
}
/**
Get a Date object from the potential date string and SimpleDateFormat.
@param s_potentialDate String containing a date that conforms to s_dateFormat. May not be null. @param simple_dateFormat The SimpleDateFormat that s_potentialDate must conform to. May not be null. @returnsimple_dateFormat.parse(s_potentialDate)
**/
public Date getDate(String s_potentialDate, SimpleDateFormat simple_dateFormat) {
try {
return simple_dateFormat.parse(s_potentialDate);
} catch(ParseException px) {
throwAX("getDate: s_potentialDate ('" + s_potentialDate + "') does not conform to simple_dateFormat [" + simple_dateFormat.toString() + "]: " + px.toString());
}
//Never reached. Required for compile.
return null;
}
/**
Is the string a legally formatted email address?
@param s_potentialEmail The string to analyze. @return false If any of the following conditions are met:Does the string contain a valid boolean value?. Note that the behavior of this function is distinct from java.lang.Boolean.valueOf.
@param s_potentialBoolean The string to analyze. @return true If s_potentialBoolean equals "true" or "false".Is the string a valid integer?. An integer is a number without a decimal point.
Equal to isNumber(s_potentialDigit, false)
Is the string a valid decimal number?. A decimal number may or may not have a decimal point.
Equal to isNumber(s_potentialDigit, true)
Is the string a valid digit?
A digit is defined with the following rules:
TODO: A critical difference between this and getInt: This function does string analysis, and therefore a huge number (8374018734087120847104387208472784) is considered valid according to this function, while invalid according to getInt (would throw an exception)
@param s_potentialDigit The string to analyze. @param b_decimalAllowed If true, then the digit is allowed to have (exactly one) decimal point. If false, the digit is not allowed to have a decimal point, and therefore must be an integer. @return true If the string conforms to the rules.If either string is contained in or equal to the other, get information describing the containment.
@returngetContainedIdx(getSOBS(s_x, "getContainedIdx"), getSOBS(s_y, "getContainedIdx"))
**/
public final i_i_i getContainedIdxs(String s_x, String s_y) {
return getContainedIdxs(getSOBS(s_x, sGCI), getSOBS(s_y, sGCI));
}
/**
If either string is contained in (or equal to) the other, get information describing the containment.
@returngetContainedIdx(getSOBS(s_x, "getContainedIdx"), getSOBS(s_y, "getContainedIdx"), gcic_two)
The array is created only once, and populated in this function repeatedly.
**/ public final i_i_i getContainedIdxs(String s_x, String s_y, GCICTwo gcic_two) { return getContainedIdxs(getSOBS(s_x, sGCI), getSOBS(s_y, sGCI), gcic_two); } /**If any string is contained in (or equal to) any other, get information describing the containment.
Equal to getContainedIdxs(getAOSOBS(a_string), (new GCIConfig()))
If any string is contained in any other, get information describing the containment.
Equal to getContainedIdxs(getAOSOBS(a_string), (new GCIConfig()))
Get a copy of the String where each line is quoted.
@returngetQuotedLines(getSOBSB(s_tr, sUS + "getQuotedLines")).toString()
**/
public final String getQuotedLines(String s_tr) {
return getQuotedLines(getSOBSB(s_tr, sUS + sGQL)).toString();
}
/**
Get a copy of the String where each line is quoted.
@returngetQuotedLines(getSOBSB(s_tr, sUS + "getQuotedLines"), s_quote).toString()
**/
public final String getQuotedLines(String s_tr, String s_quote) {
return getQuotedLines(getSOBSB(s_tr, sUS + sGQL), s_quote).toString();
}
/**
Get a copy of the String where each line is quoted.
@returngetQuotedLines(getSOBSB(s_tr, sUS + "getQuotedLines"), s_quoteStart, s_quoteEnd).toString()
**/
public final String getQuotedLines(String s_tr, String s_quoteStart, String s_quoteEnd) {
return getQuotedLines(getSOBSB(s_tr, sUS + sGQL), s_quoteStart, s_quoteEnd).toString();
}
/**
Get a copy of the String where each line is quoted.
@returngetQuotedLines(getSOBSB(s_tr, sUS + "getQuotedLines"), s_quoteStart, s_quoteEnd, s_lineSep).toString()
**/
public final String getQuotedLines(String s_tr, String s_quoteStart, String s_quoteEnd, String s_lineSep) {
return getQuotedLines(getSOBSB(s_tr, sUS + sGQL), s_quoteStart, s_quoteEnd, s_lineSep).toString();
}
/**
Is the value of the String a valid hexidecimal number?
@returnisHexidecimal(getSOBS(s_potentialHex, "s_potentialHex", sUS + ".isHexidecimal"))
**/
public boolean isHexidecimal(String s_potentialHex) {
return isHexidecimal(getSOBS(s_potentialHex, "s_potentialHex", sUS + ".isHexidecimal"));
}
/**
Does the String contain only whitespace?
@param s_potentialTabSpace The String analyzed, to see if it contains only whitespace characters. May not be null or zero characters in length. @returnisTabSpace(getSOBS(s_potentialTabSpace, "s_potentialTabSpace", sUS + ".isTabSpace"))
**/
public boolean isTabSpace(String s_potentialTabSpace) {
return isTabSpace(getSOBS(s_potentialTabSpace, "s_potentialTabSpace", "isTabSpace"));
}
/**
Does the String not contain any whitespace characters?
@param s_tr The String analyzed, to see if it contains only non-whitespace characters. May not be null or zero characters in length. @returnhasNoTabSpace(getSOBS(s_tr, sUS + ".hasNoTabSpace"))
**/
public boolean hasNoTabSpace(String s_tr) {
return hasNoTabSpace(getSOBS(s_tr, sUS + "hasNoTabSpace"));
}
/**
Get a copy of the String, after appending a duplicated string onto it.
@returndupAppend(getSOBSB(s_tr, sUS + ".getDupAppend"), s_toDuplicate, i_dupCount).toString()
**/
public final String getDupAppend(String s_tr, String s_toDuplicate, int i_dupCount) {
return getDupAppend(getSOBSB(s_tr, sUS + "getDupAppend"), s_toDuplicate, i_dupCount).toString();
}
/**
Get the priovided string, duplicated.
@returngetDupAppend("", s_tr, i_dupCount)
**/
public String getDuped(String s_tr, int i_dupCount) {
return getDupAppend(sES, s_tr, i_dupCount);
}
/**
Get the array index of the first non-white-space character.
@returngetIdxOf1stNonWS(getSOBS(s_tr, sUS + ".getIdxOf1stNonWS"))
**/
public final int getIdxOf1stNonWS(String s_tr) {
return getIdxOf1stNonWS(getSOBS(s_tr, sUS + "getIdxOf1stNonWS"));
}
/**
Get the array index of the last non-white-space character.
@returngetIdxOfLastNonWS(getSOBS(s_tr, sUS + ".getIdxOfLastNonWS"))
**/
public final int getIdxOfLastNonWS(String s_tr) {
return getIdxOfLastNonWS(getSOBS(s_tr, sUS + "getIdxOfLastNonWS"));
}
private static final String sGIO1CNIA = "getIdxOf1stCharNIA";
/**
Get the array index of the first character that is not a member of the array.
@returngetIdxOf1stCharNIA(getSOBS(s_tr, sUS + "getIdxOf1stCharNIA"), a_char)
**/
public final int getIdxOf1stCharNIA(String s_tr, char[] a_char) {
return getIdxOf1stCharNIA(getSOBS(s_tr, sUS + sGIO1CNIA), a_char);
}
/**
Get the array index of the first character that is not a member of the array.
@returngetIdxOf1stCharNIA(getSOBS(s_tr, sUS + "getIdxOf1stCharNIA"), a_char, 0, s_tr.length(), b_validateAOC)
**/
public final int getIdxOf1stCharNIA(String s_tr, char[] a_char, boolean b_validateAOC) {
try {
return getIdxOf1stCharNIA(getSOBS(s_tr, sUS + sGIO1CNIA), a_char, 0, s_tr.length(), b_validateAOC);
} catch(NullPointerException npx) {
throwAX("getIdxOf1stCharNIA: s_tr is null.");
}
//Never reached. Required for compile.
return -1;
}
/**
Get the array index of the first character that is not a member of the array.
@returngetIdxOf1stCharNIA(getSOBS(s_tr, sUS + "getIdxOf1stCharNIA"), a_char, i_idxStart, i_idxAfterEnd)
**/
public final int getIdxOf1stCharNIA(String s_tr, char[] a_char, int i_idxStart, int i_idxAfterEnd) {
return getIdxOf1stCharNIA(getSOBS(s_tr, sUS + sGIO1CNIA), a_char, i_idxStart, i_idxAfterEnd);
}
/**
Get the array index of the first character that does not exist in the array.
@returngetIdxOf1stCharNIA(getSOBS(s_tr, sUS + "getIdxOf1stCharNIA"), a_char, i_idxStart, i_idxAfterEnd, b_validateAOC)
**/
public final int getIdxOf1stCharNIA(String s_tr, char[] a_char, int i_idxStart, int i_idxAfterEnd, boolean b_validateAOC) {
return getIdxOf1stCharNIA(getSOBS(s_tr, sUS + sGIO1CNIA), a_char, i_idxStart, i_idxAfterEnd, b_validateAOC);
}
private static final String sGIOLCNIA = "getIdxOfLastCharNIA";
/**
Get the array index of the last character that is not a member of the array.
@returngetIdxOfLastCharNIA(getSOBS(s_tr, sUS + "getIdxOfLastCharNIA"), a_char)
**/
public final int getIdxOfLastCharNIA(String s_tr, char[] a_char) {
return getIdxOfLastCharNIA(getSOBS(s_tr, sUS + sGIOLCNIA), a_char);
}
/**
Get the array index of the last character that is not a member of the array.
@returngetIdxOfLastCharNIA(getSOBS(s_tr, sUS + "getIdxOfLastCharNIA"), a_char, 0, length(), b_validateAOC)
**/
public final int getIdxOfLastCharNIA(String s_tr, char[] a_char, boolean b_validateAOC) {
try {
return getIdxOfLastCharNIA(getSOBS(s_tr, sUS + sGIOLCNIA), a_char, 0, s_tr.length(), b_validateAOC);
} catch(NullPointerException npx) {
throwAX("getIdxOf1stCharNIA: s_tr is null.");
}
//Never reached. Required for compile.
return -1;
}
/**
Get the array index of the last character that is not a member of the array.
@returngetIdxOfLastCharNIA(getSOBS(s_tr, sUS + "getIdxOfLastCharNIA"), a_char, i_idxStart, i_idxAfterEnd)
**/
public final int getIdxOfLastCharNIA(String s_tr, char[] a_char, int i_idxStart, int i_idxAfterEnd) {
return getIdxOfLastCharNIA(getSOBS(s_tr, sUS + sGIOLCNIA), a_char, i_idxStart, i_idxAfterEnd);
}
/**
Get the array index of the last character that does not exist in the array.
@returngetIdxOfLastCharNIA(getSOBS(s_tr, sUS + "getIdxOfLastCharNIA"), a_char, i_idxStart, i_idxAfterEnd, b_validateAOC)
**/
public final int getIdxOfLastCharNIA(String s_tr, char[] a_char, int i_idxStart, int i_idxAfterEnd, boolean b_validateAOC) {
return getIdxOfLastCharNIA(getSOBS(s_tr, sUS + sGIOLCNIA), a_char, i_idxStart, i_idxAfterEnd, b_validateAOC);
}
/**
Get a copy of the String, where the contents' invisible characters are made visible.
@returngetVisible(getSOBSB(s_tr, sUS + ".getVisible").toString()
**/
public final String getVisible(String s_tr) {
return getVisible(getSOBSB(s_tr, sUS + "getVisible")).toString();
}
/**
Does the string contain only letters, digits and underscores?
@returnisLetterDigitUnderscore(getSOBS(s_tr, sUS + ".isLetterDigitUnderscore"))
**/
public boolean isLetterDigitUnderscore(String s_tr) {
return isLetterDigitUnderscore(getSOBS(s_tr, sUS + "isLetterDigitUnderscore"));
}
/**
Does the string contain only letters and (other provided) legal characters?
@returnhasLettersOrInAOC(getSOBS(s_tr, sUS + ".hasLettersOrInAOC"), b_digitsOkOpt, ac_legal)
**/
public boolean hasLettersOrInAOC(String s_tr, boolean b_digitsOkOpt, char[] ac_legal) {
return hasLettersOrInAOC(getSOBS(s_tr, sUS + "hasLettersOrInAOC"), b_digitsOkOpt, ac_legal);
}
/**
Does the string contain only letters and (other provided) legal characters?
@returnhasLettersOrInAOC(getSOBS(s_tr, sUS + ".hasLettersOrInAOC"), b_digitsOkOpt, ac_legal, b_validateAOC)
**/
public boolean hasLettersOrInAOC(String s_tr, boolean b_digitsOkOpt, char[] ac_legal, boolean b_validateAOC) {
return hasLettersOrInAOC(getSOBS(s_tr, sUS + "hasLettersOrInAOC"), b_digitsOkOpt, ac_legal, b_validateAOC);
}
/**
Does the string contain only digits and (other provided) legal characters?
@returnhasDigitsOrInAOC(getSOBS(s_tr, sUS + ".hasDigitsOrInAOC"), b_lettersOkOpt, ac_legal)
**/
public boolean hasDigitsOrInAOC(String s_tr, boolean b_lettersOkOpt, char[] ac_legal) {
return hasDigitsOrInAOC(getSOBS(s_tr, sUS + "hasDigitsOrInAOC"), b_lettersOkOpt, ac_legal);
}
/**
Does the string contain only digits and (other provided) legal characters?
@returnhasDigitsOrInAOC(getSOBS(s_tr, sUS + ".hasDigitsOrInAOC"), b_lettersOkOpt, ac_legal, b_validateAOC)
**/
public boolean hasDigitsOrInAOC(String s_tr, boolean b_lettersOkOpt, char[] ac_legal, boolean b_validateAOC) {
return hasDigitsOrInAOC(getSOBS(s_tr, sUS + "hasDigitsOrInAOC"), b_lettersOkOpt, ac_legal, b_validateAOC);
}
/**
Does the string contain only letters, digits and (other provided) legal characters?
@returnhasLDOrInAOC(getSOBS(s_tr, sUS + ".hasLDOrInAOC"), ac_legal)
**/
public boolean hasLDOrInAOC(String s_tr, char[] ac_legal) {
return hasLDOrInAOC(getSOBS(s_tr, sUS + "hasLDOrInAOC"), ac_legal);
}
/**
Does the string contain only letters, digits and (other provided) legal characters?
@returnhasLDOrInAOC(getSOBS(s_tr, sUS + ".hasLDOrInAOC"), ac_legal, b_validateAOC)
**/
public boolean hasLDOrInAOC(String s_tr, char[] ac_legal, boolean b_validateAOC) {
return hasLDOrInAOC(getSOBS(s_tr, sUS + "hasLDOrInAOC"), ac_legal, b_validateAOC);
}
/**
Does the string contain only legal characters?
@returnhasLegalChars(getSOBS(s_tr, sUS + ".hasLegalChars"), ac_legal)
**/
public boolean hasLegalChars(String s_tr, char[] ac_legal) {
return hasLegalChars(getSOBS(s_tr, sUS + "hasLegalChars"), ac_legal);
}
/**
Does the string contain only legal characters?
@returnisLegal(getSOBS(s_tr, sUS + ".hasLegalChars"), false, false, ac_legal, b_validateAOC)
**/
public boolean hasLegalChars(String s_tr, char[] ac_legal, boolean b_validateAOC) {
return isLegal(getSOBS(s_tr, sUS + "hasLegalChars"), false, false, ac_legal, b_validateAOC);
}
/**
Does the string contain only legal characters?
@returnisLegal(getSOBS(s_tr, sUS + ".isLegal"), b_lettersOkOpt, b_digitsOkOpt, ac_legal)
**/
public boolean isLegal(String s_tr, boolean b_lettersOkOpt, boolean b_digitsOkOpt, char[] ac_legal) {
return isLegal(getSOBS(s_tr, sUS + "isLegal"), b_lettersOkOpt, b_digitsOkOpt, ac_legal);
}
/**
Does the string contain only legal characters?
@returnisLegal(getSOBS(s_tr, sUS + ".isLegal"), b_lettersOkOpt, b_digitsOkOpt, ac_legal, b_validateAOC)
**/
public boolean isLegal(String s_tr, boolean b_lettersOkOpt, boolean b_digitsOkOpt, char[] ac_legal, boolean b_validateAOC) {
return isLegal(getSOBS(s_tr, sUS + "isLegal"), b_lettersOkOpt, b_digitsOkOpt, ac_legal, b_validateAOC);
}
/**
Does the string not contain any letters or (other provided) illegal characters?
@returnisNotLettersOrInAOC(getSOBS(s_tr, sUS + ".isNotLettersOrInAOC"), b_digitsBadOpt, ac_legal)
**/
public boolean isNotLettersOrInAOC(String s_tr, boolean b_digitsBadOpt, char[] ac_legal) {
return isNotLettersOrInAOC(getSOBS(s_tr, sUS + "isNotLettersOrInAOC"), b_digitsBadOpt, ac_legal);
}
/**
Does the string not contain any letters or (other provided) illegal characters?
@returnisNotLettersOrInAOC(getSOBS(s_tr, sUS + ".isNotLettersOrInAOC"), b_digitsBadOpt, ac_legal, b_validateAOC)
**/
public boolean isNotLettersOrInAOC(String s_tr, boolean b_digitsBadOpt, char[] ac_legal, boolean b_validateAOC) {
return isNotLettersOrInAOC(getSOBS(s_tr, sUS + "isNotLettersOrInAOC"), b_digitsBadOpt, ac_legal, b_validateAOC);
}
/**
Does the string not contain any digits or (other provided) illegal characters?
@returnisNotDigitsOrInAOC(getSOBS(s_tr, sUS + ".isNotDigitsOrInAOC"), b_digitsBadOpt, ac_legal)
**/
public boolean isNotDigitsOrInAOC(String s_tr, boolean b_lettersBadOpt, char[] ac_legal) {
return isNotDigitsOrInAOC(getSOBS(s_tr, sUS + "isNotDigitsOrInAOC"), b_lettersBadOpt, ac_legal);
}
/**
Does the string not contain any digits or (other provided) illegal characters?
@returnisNotDigitsOrInAOC(getSOBS(s_tr, sUS + ".isNotDigitsOrInAOC"), b_lettersBadOpt, ac_legal, b_validateAOC)
**/
public boolean isNotDigitsOrInAOC(String s_tr, boolean b_lettersBadOpt, char[] ac_legal, boolean b_validateAOC) {
return isNotDigitsOrInAOC(getSOBS(s_tr, sUS + "isNotDigitsOrInAOC"), b_lettersBadOpt, ac_legal, b_validateAOC);
}
/**
Does the string not contain any letters, digits or (other provided) illegal characters?
@returnisNotLDOrInAOC(getSOBS(s_tr, sUS + ".isNotLDOrInAOC"), ac_legal)
**/
public boolean isNotLDOrInAOC(String s_tr, char[] ac_legal) {
return isNotLDOrInAOC(getSOBS(s_tr, sUS + "isNotLDOrInAOC"), ac_legal);
}
/**
Does the string not contain any letters, digits or (other provided) illegal characters?
@returnisNotLDOrInAOC(getSOBS(s_tr, sUS + ".isNotLDOrInAOC"), ac_legal, b_validateAOC)
**/
public boolean isNotLDOrInAOC(String s_tr, char[] ac_legal, boolean b_validateAOC) {
return isNotLDOrInAOC(getSOBS(s_tr, sUS + "isNotLDOrInAOC"), ac_legal, b_validateAOC);
}
/**
Does the string not contain any illegal characters?
@returnhasNoIllegalChars(getSOBS(s_tr, sUS + ".hasNoIllegalChars"), ac_illegal)
**/
public boolean hasNoIllegalChars(String s_tr, char[] ac_illegal) {
return hasNoIllegalChars(getSOBS(s_tr, sUS + "hasNoIllegalChars"), ac_illegal);
}
/**
Does the string not contain any illegal characters?
@returnisNotIllegal(getSOBS(s_tr, sUS + ".hasNoIllegalChars"), false, false, ac_illegal, b_validateAOC)
**/
public boolean hasNoIllegalChars(String s_tr, char[] ac_illegal, boolean b_validateAOC) {
return isLegal(getSOBS(s_tr, sUS + "hasNoIllegalChars"), false, false, ac_illegal, b_validateAOC);
}
/**
Does the string not contain any illegal characters?
@returnisNotIllegal(getSOBS(s_tr, sUS + ".isNotIllegal"), b_lettersBadOpt, b_digitsBadOpt, ac_illegal)
**/
public boolean isNotIllegal(String s_tr, boolean b_lettersBadOpt, boolean b_digitsBadOpt, char[] ac_illegal) {
return isNotIllegal(getSOBS(s_tr, sUS + "isNotIllegal"), b_lettersBadOpt, b_digitsBadOpt, ac_illegal);
}
/**
Does the string not contain any illegal characters?
@returnisNotIllegal(getSOBS(s_tr, sUS + ".isNotLegal"), b_lettersBadOpt, b_digitsBadOpt, ac_illegal, b_validateAOC)
**/
public boolean isNotIllegal(String s_tr, boolean b_lettersBadOpt, boolean b_digitsBadOpt, char[] ac_illegal, boolean b_validateAOC) {
return isNotIllegal(getSOBS(s_tr, sUS + "isNotLegal"), b_lettersBadOpt, b_digitsBadOpt, ac_illegal, b_validateAOC);
}
/**
Create an SOBStringBuffer with the String.
@return null If s_tr is null.(new StringBuffer(s_tr))
If s_tr is non-null.
**/
public StringBuffer getSB(String s_tr) {
if(s_tr == null) {
return null;
}
return (new StringBuffer(s_tr));
}
/**
Return a copy of the provided string, in which all occurances are replaced.
@returngetReplaceAll(getSOBSB(s_tr, sUS + ".getReplaceAll"), s_replaceWhat, s_replaceWith)
**/
public final String getReplaceAll(String s_tr, String s_replaceWhat, String s_replaceWith) {
return getReplaceAll(getSOBSB(s_tr, sUS + "getReplaceAll"), s_replaceWhat, s_replaceWith).toString();
}
/**
Replace all occurances, with multiple passes, until no instances of the search string remain.
@returngetReplaceUntil(getSOBSB(s_tr, sUS + ".getReplaceUntil"), s_replaceWhat, s_replaceWith)
**/
public final String getReplaceUntil(String s_tr, String s_replaceWhat, String s_replaceWith) {
return getReplaceUntil(getSOBSB(s_tr, sUS + "replaceUntil"), s_replaceWhat, s_replaceWith).toString();
}
/**
What is the first array index containing an int not equal to element zero?
This is useful in unit tests that tests multiple versions of the same function, when you want to ensure that each returns the same value.
@param a_int The int array to analyze. May not be null or equal to zero elements in length. Element zero may not be null. @return -1 If a_int.length is one element in length, or every element in the array is equal.Create an SOBString from the String.
@returngetSOBS(s_tr, sUS + ".s_tr", s_callingClsFnc)
**/
public final SOBString getSOBS(String s_tr, String s_callingClsFnc) {
return getSOBS(s_tr, "s_tr", s_callingClsFnc);
}
/**
Create an SOBString from the String.
@param s_tr The String to create a new SOBString with. May not be null. @param s_sDescription The descriptive name of s_tr, for potential error messages. @param s_callingClsFnc The function from which the potential error message should appear as if it is coming from. @return(new SOBString(s_tr))
**/
public final SOBString getSOBS(String s_tr, String s_sDescription, String s_callingClsFnc) {
try {
return new SOBString(s_tr);
} catch(NullPointerException npx) {
throwAX(s_callingClsFnc + ": " + s_sDescription + " is null.");
}
//Never reached. Required for compile.
return null;
}
/**
Create an SOBStringBuffer from the String.
@returngetSOBSB(s_tr, "s_tr", s_callingClsFnc)
**/
public final SOBStringBuffer getSOBSB(String s_tr, String s_callingClsFnc) {
return getSOBSB(s_tr, "s_tr", s_callingClsFnc);
}
/**
Create an SOBStringBuffer from the String.
@param s_tr The String to create a new SOBStringBuffer with. May not be null. @param s_sDescription The descriptive name of s_tr, for potential error messages. @param s_callingClsFnc The function from which the potential error message should appear as if it is coming from. @return(new SOBStringBuffer(s_tr))
**/
public final SOBStringBuffer getSOBSB(String s_tr, String s_sDescription, String s_callingClsFnc) {
try {
return (new SOBStringBuffer(s_tr));
} catch(NullPointerException npx) {
throwAX(s_callingClsFnc + ": " + s_sDescription + " is null.");
}
//Never reached. Required for compile.
return null;
}
/**
Get an array of SOBStrings from the array of strings.
@param a_string The array of strings to create an array of SOBStrings from. @return null If a_string is null.Get an array of SOBStringBuffers from the array of strings.
@param a_string The array of strings to create an array of SOBStringBuffers from. @return null If a_string is null.