xbn.string
Class UtilSOB

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.string.UtilSOB
Direct Known Subclasses:
UtilString, UtilStringBuffer

public class UtilSOB
extends XBNObject

Random functions for StringOrBuffers. See StringOrBuffer.

Source code:  UtilSOB.java.  Unit tests:  xbn_junit.JUTUtilSOB.java.


Field Summary
static String sUSOB
          To shorten code and Javadoc.
 
Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
UtilSOB()
          Create a UtilSOB.
 
Method Summary
 void dupAppend(StringOrBuffer str_orBfr, String s_toDuplicate, int i_dupCount)
          Append a duplicated string onto the StringOrBuffer.
 i_i_i getContainedIdxs(StringOrBuffer[] a_strOrBfr)
          If any StringOrBuffer is contained in (or equal to) any other, get information describing the containment.
 i_i_i getContainedIdxs(StringOrBuffer[] a_strOrBfr, GCIConfig gci_config)
          If any string is contained in any other, get information describing the containment.
 i_i_i getContainedIdxs(StringOrBuffer sob_x, StringOrBuffer sob_y)
          If either string is contained in or equal to the other, get information describing the containment.
 i_i_i getContainedIdxs(StringOrBuffer sob_x, StringOrBuffer sob_y, GCICTwo gcic_two)
          If either string is contained in (or equal to) the other, get information describing the containment.
 SOBStringBuffer getDupAppend(StringOrBuffer str_orBfr, String s_toDuplicate, int i_dupCount)
          Get a copy of the StringOrBuffer (as an SOBStringBuffer), after appending a duplicated string onto it.
 i_i_i_i getGSAInfo()
          What just happened in the just-called getStringAround?.
 int getIdxOf1stCharNIA(StringOrBuffer str_orBfr, char[] a_char)
          Get the array index of the first character that is not a member of the array.
 int getIdxOf1stCharNIA(StringOrBuffer str_orBfr, char[] a_char, boolean b_validateAOC)
          Get the array index of the first character that is not a member of the array.
 int getIdxOf1stCharNIA(StringOrBuffer str_orBfr, char[] a_char, int i_idxStart, int i_idxFirstfterEnd)
          Get the array index of the first character that is not a member of the array.
 int getIdxOf1stCharNIA(StringOrBuffer str_orBfr, char[] a_char, int i_idxStart, int i_idxFirstfterEnd, boolean b_validateAOC)
          Get the array index of the first character that does not exist in the array.
 int getIdxOf1stNonWS(StringOrBuffer str_orBfr)
          Get the array index of the first non-white-space character.
 int getIdxOfLastCharNIA(StringOrBuffer str_orBfr, char[] a_char)
          Get the array index of the last character that is not a member of the array.
 int getIdxOfLastCharNIA(StringOrBuffer str_orBfr, char[] a_char, boolean b_validateAOC)
          Get the array index of the last character that is not a member of the array.
 int getIdxOfLastCharNIA(StringOrBuffer str_orBfr, char[] a_char, int i_idxStart, int i_idxFirstfterEnd)
          Get the array index of the last character that is not a member of the array.
 int getIdxOfLastCharNIA(StringOrBuffer str_orBfr, char[] a_char, int i_idxStart, int i_idxFirstfterEnd, boolean b_validateAOC)
          Get the array index of the last character that does not exist in the array.
 int getIdxOfLastNonWS(StringOrBuffer str_orBfr)
          Get the array index of the last non-white-space character.
 StringOrBuffer getQuotedLines(StringOrBuffer str_orBfr)
          Get a copy of the StringOrBuffer (as an SOBStringBuffer) where each line is quoted.
 StringOrBuffer getQuotedLines(StringOrBuffer str_orBfr, String s_quote)
          Get a copy of the StringOrBuffer (as an SOBStringBuffer) where each line is quoted.
 StringOrBuffer getQuotedLines(StringOrBuffer str_orBfr, String s_quoteStart, String s_quoteEnd)
          Get a copy of the StringOrBuffer (as an SOBStringBuffer) where each line is quoted.
 StringOrBuffer getQuotedLines(StringOrBuffer str_orBfr, String s_quoteStart, String s_quoteEnd, String s_lineSep)
          Get a copy of the StringOrBuffer (as a StringBuffer) where each line is quoted.
 SOBStringBuffer getReplaceAll(StringOrBuffer sob_searchIn, String s_searchFor, String s_replaceWith)
          Return a copy of the provided StringOrBuffer (as an SOBStringBuffer), in which all occurances are replaced.
 SOBStringBuffer getReplaceUntil(StringOrBuffer sob_searchIn, String s_searchFor, String s_replaceWith)
          Replace all occurances, with multiple passes, until no instances of the search string remain.
 SOBString getSOBS(StringOrBuffer str_orBfr, String s_callingFunc)
          Create an SOBString from the StringOrBuffer.
 SOBString getSOBS(StringOrBuffer str_orBfr, String s_description, String s_callingFunc)
          Create an SOBString from the StringOrBuffer.
 SOBStringBuffer getSOBSB(StringOrBuffer str_orBfr, String s_callingFunc)
          Create an SOBStringBuffer from the StringOrBuffer.
 SOBStringBuffer getSOBSB(StringOrBuffer str_orBfr, String s_description, String s_callingFunc)
          Create an SOBString from the StringOrBuffer.
 String getStringAround(StringOrBuffer str_orBfr, int i_charIdx, String s_delimLeft, String s_delimRight, boolean b_endsOfStrAltDelims, boolean b_includeDelimiters)
          Get a string surrounding the provided character index, having specific delimiters.
 StringOrBuffer getVisible(StringOrBuffer str_orBfr)
          Get a copy of the StringOrBuffer (as an SOBStringBuffer), where the contents' invisible characters are made visible.
 boolean hasDigitsOrInAOC(StringOrBuffer str_orBfr, boolean b_lettersOkOpt, char[] ac_legal)
          Does the string contain only digits and (other provided) legal characters?
 boolean hasDigitsOrInAOC(StringOrBuffer str_orBfr, boolean b_lettersOkOpt, char[] ac_legal, boolean b_validateAOC)
          Does the string contain only digits and (other provided) legal characters?
 boolean hasLDOrInAOC(StringOrBuffer str_orBfr, char[] ac_legal)
          Does the string contain only letters, digits and (other provided) legal characters?
 boolean hasLDOrInAOC(StringOrBuffer str_orBfr, char[] ac_legal, boolean b_validateAOC)
          Does the string contain only letters, digits and (other provided) legal characters?
 boolean hasLegalChars(StringOrBuffer str_orBfr, char[] ac_legal)
          Does the string contain only legal characters?
 boolean hasLegalChars(StringOrBuffer str_orBfr, char[] ac_legal, boolean b_validateAOC)
          Does the string contain only legal characters?
 boolean hasLettersOrInAOC(StringOrBuffer str_orBfr, boolean b_digitsOkOpt, char[] ac_legal)
          Does the string contain only letters and (other provided) legal characters?
 boolean hasLettersOrInAOC(StringOrBuffer str_orBfr, boolean b_digitsOkOpt, char[] ac_legal, boolean b_validateAOC)
          Does the string contain only letters and (other provided) legal characters?
 boolean hasNoIllegalChars(StringOrBuffer str_orBfr, char[] ac_illegal)
          Does the string not contain any illegal characters?
 boolean hasNoIllegalChars(StringOrBuffer str_orBfr, char[] ac_illegal, boolean b_validateAOC)
          Does the string not contain any illegal characters?
 boolean hasNoTabSpace(StringOrBuffer str_orBfr)
          Does the StringOrBuffer not contain any tab and space characters?
 int indexOfWord(StringOrBuffer str_orBfr, String s_searchWord, int i_idxLeft, int i_idxAfterRight)
          Find the first occurance of the search string, where it is an entire word (not part of a larger word).
 int indexOfWord(StringOrBuffer str_orBfr, String s_searchWord, int i_idxLeft, int i_idxAfterRight, boolean b_bounded)
          Find the left-most occurance of the search string, where it is an entire word (not part of a larger word).
 boolean isHexidecimal(StringOrBuffer sob_potentialHex)
          Is the value of the StringOrBuffer a valid hexidecimal number?.
 boolean isLegal(StringOrBuffer str_orBfr, boolean b_lettersOkOpt, boolean b_digitsOkOpt, char[] ac_legal)
          Does the string contain only legal characters?
 boolean isLegal(StringOrBuffer str_orBfr, boolean b_lettersOkOpt, boolean b_digitsOkOpt, char[] ac_legal, boolean b_validateAOC)
          Does the string contain only legal characters?
 boolean isLetterDigitUnderscore(StringOrBuffer str_orBfr)
          Does the string contain only letters, digits and underscores?
 boolean isNotDigitsOrInAOC(StringOrBuffer str_orBfr, boolean b_lettersBadOpt, char[] ac_legal)
          Does the string not contain any digits or (other provided) illegal characters?
 boolean isNotDigitsOrInAOC(StringOrBuffer str_orBfr, boolean b_lettersBadOpt, char[] ac_legal, boolean b_validateAOC)
          Does the string not contain any digits or (other provided) illegal characters?
 boolean isNotIllegal(StringOrBuffer str_orBfr, boolean b_lettersBadOpt, boolean b_digitsBadOpt, char[] ac_illegal)
          Does the string not contain any illegal characters?
 boolean isNotIllegal(StringOrBuffer str_orBfr, boolean b_lettersBadOpt, boolean b_digitsBadOpt, char[] ac_illegal, boolean b_validateAOC)
          Does the string not contain any illegal characters?
 boolean isNotLDOrInAOC(StringOrBuffer str_orBfr, char[] ac_legal)
          Does the string not contain any letters, digits or (other provided) illegal characters?
 boolean isNotLDOrInAOC(StringOrBuffer str_orBfr, char[] ac_legal, boolean b_validateAOC)
          Does the string not contain any letters, digits or (other provided) illegal characters?
 boolean isNotLettersOrInAOC(StringOrBuffer str_orBfr, boolean b_digitsBadOpt, char[] ac_legal)
          Does the string not contain any letters or (other provided) illegal characters?
 boolean isNotLettersOrInAOC(StringOrBuffer str_orBfr, boolean b_digitsBadOpt, char[] ac_legal, boolean b_validateAOC)
          Does the string not contain any letters or (other provided) illegal characters?
 boolean isTabSpace(StringOrBuffer sob_potentialTabSpace)
          Does the StringOrBuffer contain only tabs and spaces?
 int lastIndexOfWord(StringOrBuffer str_orBfr, String s_searchWord, int i_idxLeft, int i_idxAfterRight)
          Find the last occurance of the search string, where it is an entire word (not part of a larger word).
 int lastIndexOfWord(StringOrBuffer str_orBfr, String s_searchWord, int i_idxLeft, int i_idxAfterRight, boolean b_bounded)
          Find the right-most occurance of the search string, where it is an entire word (not part of a larger word).
 void makeVisible(StringOrBuffer str_orBfr)
          Translate the contents of the StringOrBuffer, so all invisible characters are made visible.
 void quoteLines(StringOrBuffer str_orBfr)
          Quote each line within the StringOrBuffer.
 void quoteLines(StringOrBuffer str_orBfr, String s_quote)
          Quote each line within the StringOrBuffer.
 void quoteLines(StringOrBuffer str_orBfr, String s_quoteStart, String s_quoteEnd)
          Quote each line within the StringOrBuffer.
 void quoteLines(StringOrBuffer str_orBfr, String s_quoteStart, String s_quoteEnd, String s_lineSep)
          Quote each line within the StringOrBuffer.
 int replaceAll(StringOrBuffer sob_searchIn, String s_searchFor, String s_replaceWith)
          Replace all occurances.
 i_i replaceUntil(StringOrBuffer sob_searchIn, String s_searchFor, String s_replaceWith)
          Replace all occurances, with multiple passes, until no instances of the search string remain.
 void throwAXIfBadSOB(StringOrBuffer str_orBfr, String s_sobDescription, String s_callingFunc)
          If the StringOrBuffer is null or empty (the string contained within is zero characters in length), then die.
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sUSOB

public static final String sUSOB

To shorten code and Javadoc.

Equal to "xbn.string.UtilSOB"

Constructor Detail

UtilSOB

public UtilSOB()

Create a UtilSOB. This constructor does nothing.

Method Detail

indexOfWord

public final int indexOfWord(StringOrBuffer str_orBfr,
                             String s_searchWord,
                             int i_idxLeft,
                             int i_idxAfterRight)

Find the first occurance of the search string, where it is an entire word (not part of a larger word).

Returns:
indexOfWord(str_orBfr, s_searchWord, i_idxLeft, i_idxAfterRight, true)

indexOfWord

public final int indexOfWord(StringOrBuffer str_orBfr,
                             String s_searchWord,
                             int i_idxLeft,
                             int i_idxAfterRight,
                             boolean b_bounded)

Find the left-most occurance of the search string, where it is an entire word (not part of a larger word).

Parameters:
str_orBfr - The StringOrBuffer in which to search for s_searchWord. Provided directly to str_orBfr.indexOf.
i_idxLeft - The left-most index to search. Provided directly to str_orBfr.indexOf.
i_idxAfterRight - The index after the right-most index to search. Provided directly to str_orBfr.indexOf.
b_bounded - Should the search string be bounded within i_idxLeft and i_idxAfterRight? Provided directly to str_orBfr.indexOf.
Returns:
Array index indicating the left-most occurance of the search string, when the...
  • ...first character in the search string is either...
    • ...the character at i_idxLeft, or
    • ...immediately preceded by a character that is not a letter, digit or underscore.
  • ...and the right-most character is either (if b_bounded equals ...
    • ...true), the character at (i_idxAfterRight - 1), or
    • ...false), the character at (str_orBfr.length() - 1), or
    • ...true or false) before (i_idxAfterRight - 1), and the character immediately following is not a letter, digit or underscore.

lastIndexOfWord

public final int lastIndexOfWord(StringOrBuffer str_orBfr,
                                 String s_searchWord,
                                 int i_idxLeft,
                                 int i_idxAfterRight)

Find the last occurance of the search string, where it is an entire word (not part of a larger word).

Returns:
lastIndexOfWord(str_orBfr, s_searchWord, i_idxLeft, i_idxAfterRight, true)

lastIndexOfWord

public final int lastIndexOfWord(StringOrBuffer str_orBfr,
                                 String s_searchWord,
                                 int i_idxLeft,
                                 int i_idxAfterRight,
                                 boolean b_bounded)

Find the right-most occurance of the search string, where it is an entire word (not part of a larger word).

Parameters:
str_orBfr - The StringOrBuffer in which to search for s_searchWord. Provided directly to str_orBfr.indexOf.
i_idxLeft - The left-most index to search. Provided directly to str_orBfr.indexOf.
i_idxAfterRight - The index after the right-most index to search. Provided directly to str_orBfr.indexOf.
b_bounded - Should the search string be bounded within i_idxLeft and i_idxAfterRight? Provided directly to str_orBfr.indexOf.
Returns:
Array index indicating the right-most occurance of the search string, when the...
  • ...first character in the search string is either...
    • ...the character at i_idxLeft, or
    • ...immediately preceded by a character that is not a letter, digit or underscore.
  • ...and the right-most character is either (if b_bounded equals ...
    • ...true), the character at (i_idxAfterRight - 1), or
    • ...false), the character at (str_orBfr.length() - 1), or
    • ...true or false) before (i_idxAfterRight - 1), and the character immediately following is not a letter, digit or underscore.

getQuotedLines

public final StringOrBuffer getQuotedLines(StringOrBuffer str_orBfr)

Get a copy of the StringOrBuffer (as an SOBStringBuffer) where each line is quoted.

Returns:
The contents of getSOBSB: quoteLines(getSOBSB(str_orBfr, "getQuotedLines"))

getQuotedLines

public final StringOrBuffer getQuotedLines(StringOrBuffer str_orBfr,
                                           String s_quote)

Get a copy of the StringOrBuffer (as an SOBStringBuffer) where each line is quoted.

Returns:
The contents of getSOBSB: quoteLines(getSOBSB(str_orBfr, "getQuotedLines"), s_quote)

getQuotedLines

public final StringOrBuffer getQuotedLines(StringOrBuffer str_orBfr,
                                           String s_quoteStart,
                                           String s_quoteEnd)

Get a copy of the StringOrBuffer (as an SOBStringBuffer) where each line is quoted.

Returns:
The contents of getSOBSB: quoteLines(getSOBSB(str_orBfr, "getQuotedLines"), s_quoteStart, s_quoteEnd)

getQuotedLines

public final StringOrBuffer getQuotedLines(StringOrBuffer str_orBfr,
                                           String s_quoteStart,
                                           String s_quoteEnd,
                                           String s_lineSep)

Get a copy of the StringOrBuffer (as a StringBuffer) where each line is quoted.

Returns:
The contents of getSOBSB: quoteLines(getSOBSB(str_orBfr, "getQuotedLines"), s_quoteStart, s_quoteEnd, s_lineSep)

quoteLines

public final void quoteLines(StringOrBuffer str_orBfr)

Quote each line within the StringOrBuffer.

Equal to quoteLines(str_orBfr, "'")


quoteLines

public final void quoteLines(StringOrBuffer str_orBfr,
                             String s_quote)

Quote each line within the StringOrBuffer.

Equal to quoteLines(str_orBfr, s_quote, s_quote)


quoteLines

public final void quoteLines(StringOrBuffer str_orBfr,
                             String s_quoteStart,
                             String s_quoteEnd)

Quote each line within the StringOrBuffer.

Equal to quoteLines(str_orBfr, s_quoteStart, s_quoteEnd, sLINE_SEP)


quoteLines

public final void quoteLines(StringOrBuffer str_orBfr,
                             String s_quoteStart,
                             String s_quoteEnd,
                             String s_lineSep)

Quote each line within the StringOrBuffer. Intended for display purposes only, to emphasize the tabs and spaces existing at the ends of each line. See TrimChars.trimAllLines and makeVisible.

Parameters:
str_orBfr - The StringOrBuffer to get a quoted copy of. May not be null.
s_quoteStart - . The quote to put at the beginning of each line. May not be null or zero characters in length.
s_quoteEnd - The quote to put at the end of each line. May not be null or zero characters in length.
s_lineSep - Whatever you define the line separator to be. May not be null or zero characters in length.

getStringAround

public final String getStringAround(StringOrBuffer str_orBfr,
                                    int i_charIdx,
                                    String s_delimLeft,
                                    String s_delimRight,
                                    boolean b_endsOfStrAltDelims,
                                    boolean b_includeDelimiters)

Get a string surrounding the provided character index, having specific delimiters.

For information regarding the call just made to this function, see getGSAInfo.

Parameters:
str_orBfr - The string to get the substring from. May not be null, and must be long enough such that all these conditions are met:
  1. str_orBfr.indexOf(s_delimLeft) may not equal -1 and the index of the last character in s_delimLeft must equal [i_charIdx - 1] or less. Exception: It is legal for the left delimiter to not exist if b_sosAltLeftDelim equals true.
  2. str_orBfr.indexOf(s_delimRight) may not equal -1 and the index of the first character in s_delimRight must equal i_charIdx or greater. Exception: It is legal for the right delimiter to not exist if b_sosAltRightDelim equals true.
  3. i_charIdx must be a legal character array index for str_orBfr.
i_charIdx - The character index existing somewhere within str_orBfr, and between s_delimLeft and s_delimRight.
s_delimLeft - The left delimiter, defining the start of the string to be returned. May not be null, or zero characters in length. The left delimiter closest to i_charIdx (on the left) is used.
s_delimRight - The right delimiter, defining the end of the string to be returned. May not be null, or zero characters in length. The left delimiter closest to i_charIdx (on the right) is used.
b_endsOfStrAltDelims - If s_delimLeft does not exist before, and/or s_delimRight does not after i_charIdx, is the start/end of the string (index str_orBfr.length) a legal substitute for s_delimLeft/s_delimRight? If true and s_delimLeft/s_delimRight does not exist, then the start/end of the string is the delimiter. If false, then both s_delimLeft and s_delimRight are required to exist.
b_includeDelimiters - Should s_delimLeft and s_delimRight be included in the string that is returned? If true, yes (when b_eosAltRightDelim equals true, the left and right delimiters are included only if they exist). If false, no.
Returns:
For example. Say...
  • ...str_orBfr equals: <A HREF="http://sourceforge.net/projects/xbnjava">click here</a>
  • ...both s_delimLeft and s_delimRight equal \"
  • ...i_charIdx equals 12, which is the index of the colon ':'.

Value of Value of getGSAInfo(]...
b_endsOfStrAltDelims b_includeDelimiters Returned value .i1 .i2 .i3 .i4
false false http://sourceforge.net/projects/xbnjava 8 9 34 34
false true "http://sourceforge.net/projects/xbnjava" 8 8 34 35

Say...

  • ...str_orBfr equals: <A HREF=http://sourceforge.net/projects/xbnjava">click here</a>
  • ...both s_delimLeft and s_delimRight equal \"
  • ...i_charIdx equals 12, which is the index of the colon ':'.

Value of Value of getGSAInfo(]...
b_endsOfStrAltDelims b_includeDelimiters Returned value .i1 .i2 .i3 .i4
true true <A HREF=http://sourceforge.net/projects/xbnjava" 8 0 34 35
true false <A HREF=http://sourceforge.net/projects/xbnjava 8 0 34 34
false true AssertException n/a


getGSAInfo

public i_i_i_i getGSAInfo()

What just happened in the just-called getStringAround?. See getStringAround.

Returns:
An i_i_i_i, where...
  • ...i1 is the actual index at which s_delimLeft was found.
  • ...i2 is the left-most index of str_orBfr that was returned (which may be different than i1, depending on the value of b_includeDelimiters).
  • ...i3 is the actual index at which s_delimRight was found.
  • ...i4 is the index after the right-most index of str_orBfr that was returned (which may or may not be different than i3, depending on the value of b_includeDelimiters).

null If getStringAround was never called, or threw an exception for any reason.

getContainedIdxs

public final i_i_i getContainedIdxs(StringOrBuffer sob_x,
                                    StringOrBuffer sob_y)

If either string is contained in or equal to the other, get information describing the containment.

Returns:
getContainedIdx(sob_x, sob_y, (new GCICTwo()))

getContainedIdxs

public final i_i_i getContainedIdxs(StringOrBuffer sob_x,
                                    StringOrBuffer sob_y,
                                    GCICTwo gcic_two)

If either string is contained in (or equal to) the other, get information describing the containment.

Equal to getContainedIdxs((new StringOrBuffer[]{sob_x, sob_y}), gcic_two)

The array is created only once, and populated in this function repeatedly.


getContainedIdxs

public final i_i_i getContainedIdxs(StringOrBuffer[] a_strOrBfr)

If any StringOrBuffer is contained in (or equal to) any other, get information describing the containment.

Equal to getSOBS(a_strOrBfr, (new GCIConfig()))


getContainedIdxs

public final i_i_i getContainedIdxs(StringOrBuffer[] a_strOrBfr,
                                    GCIConfig gci_config)

If any string is contained in any other, get information describing the containment.

Parameters:
a_strOrBfr - The array of StringOrBuffers to analyze for containment. May not be null or zero elements in length, and no element may be null or zero characters in length.
Returns:
null If no containment was detected.
An i_i_i where i1 is the array index of the containing string, i2 is the array index of the contained string, and i3 is the string index of the containing string, at which the first character of the contained string begins.

isHexidecimal

public boolean isHexidecimal(StringOrBuffer sob_potentialHex)

Is the value of the StringOrBuffer a valid hexidecimal number?. A hex digit only contains digits and (lowercase) letters from a through f.

Parameters:
sob_potentialHex - The StringOrBuffer analyzed, to see if it is a hexidecimal number. May not be null or zero characters in length.
Returns:
isLegal(sob_potentialHex, false, true, UtilChar.getAOCHexLetters())


isTabSpace

public boolean isTabSpace(StringOrBuffer sob_potentialTabSpace)

Does the StringOrBuffer contain only tabs and spaces?

Parameters:
sob_potentialHex - The StringOrBuffer analyzed, to see if it contains only tab and space characters. May not be null or zero characters in length.
Returns:
hasLegalChars(sob_potentialTabSpace, UtilChar.getAOCTabSpace())


hasNoTabSpace

public boolean hasNoTabSpace(StringOrBuffer str_orBfr)

Does the StringOrBuffer not contain any tab and space characters?

Parameters:
sob_potentialHex - The StringOrBuffer analyzed, to see if it contains only non-tab and non-space characters. May not be null or zero characters in length.
Returns:
hasNoIllegalChars(str_orBfr, UtilChar.getAOCTabSpace())


dupAppend

public final void dupAppend(StringOrBuffer str_orBfr,
                            String s_toDuplicate,
                            int i_dupCount)

Append a duplicated string onto the StringOrBuffer.

Parameters:
sb_appendTo - The StringBuffer to append to. May not be null.
s_toDuplicate - The string to duplicate and then append. May not be null or zero characters in length.
i_dupCount - The number of times to duplicate s_toDuplicate. May not be less than zero. If equal to zero, then nothing is appended to sb_appendTo.

getDupAppend

public final SOBStringBuffer getDupAppend(StringOrBuffer str_orBfr,
                                          String s_toDuplicate,
                                          int i_dupCount)

Get a copy of the StringOrBuffer (as an SOBStringBuffer), after appending a duplicated string onto it.

Returns:
The contents of getSOBSB: dupAppend(getSOBSB(str_orBfr, "getDupAppend"), s_toDuplicate, i_dupCount)

getIdxOf1stNonWS

public final int getIdxOf1stNonWS(StringOrBuffer str_orBfr)

Get the array index of the first non-white-space character.

Returns:
getIdxOf1stCharNIA(str_orBfr, UtilChar.getAOCInvisible(), bFALSE_IN_PRODUCTION)

getIdxOfLastNonWS

public final int getIdxOfLastNonWS(StringOrBuffer str_orBfr)

Get the array index of the last non-white-space character.

Returns:
getIdxOfLastCharNIA(str_orBfr, UtilChar.getAOCInvisible(), bFALSE_IN_PRODUCTION)

getIdxOf1stCharNIA

public final int getIdxOf1stCharNIA(StringOrBuffer str_orBfr,
                                    char[] a_char)

Get the array index of the first character that is not a member of the array.

Returns:
getIdxOf1stCharNIA(str_orBfr, a_char, bFALSE_IN_PRODUCTION)

getIdxOf1stCharNIA

public final int getIdxOf1stCharNIA(StringOrBuffer str_orBfr,
                                    char[] a_char,
                                    boolean b_validateAOC)

Get the array index of the first character that is not a member of the array.

Returns:
getIdxOf1stCharNIA(str_orBfr, a_char, 0, str_orBfr.length(), b_validateAOC)

getIdxOf1stCharNIA

public final int getIdxOf1stCharNIA(StringOrBuffer str_orBfr,
                                    char[] a_char,
                                    int i_idxStart,
                                    int i_idxFirstfterEnd)

Get the array index of the first character that is not a member of the array.

Returns:
getIdxOf1stCharNIA(str_orBfr, a_char, i_idxStart, i_idxFirstfterEnd, bFALSE_IN_PRODUCTION)

getIdxOf1stCharNIA

public final int getIdxOf1stCharNIA(StringOrBuffer str_orBfr,
                                    char[] a_char,
                                    int i_idxStart,
                                    int i_idxFirstfterEnd,
                                    boolean b_validateAOC)

Get the array index of the first character that does not exist in the array.

See getIdxOfLastCharNIA for parameter documentation. The only difference between this and that is the side/direction searched.


getIdxOfLastCharNIA

public final int getIdxOfLastCharNIA(StringOrBuffer str_orBfr,
                                     char[] a_char)

Get the array index of the last character that is not a member of the array.

Returns:
getIdxOfLastCharNIA(str_orBfr, a_char, bFALSE_IN_PRODUCTION)

getIdxOfLastCharNIA

public final int getIdxOfLastCharNIA(StringOrBuffer str_orBfr,
                                     char[] a_char,
                                     boolean b_validateAOC)

Get the array index of the last character that is not a member of the array.

Returns:
getIdxOfLastCharNIA(str_orBfr, a_char, 0, length(), b_validateAOC)

getIdxOfLastCharNIA

public final int getIdxOfLastCharNIA(StringOrBuffer str_orBfr,
                                     char[] a_char,
                                     int i_idxStart,
                                     int i_idxFirstfterEnd)

Get the array index of the last character that is not a member of the array.

Returns:
getIdxOfLastCharNIA(str_orBfr, a_char, i_idxStart, i_idxFirstfterEnd, bFALSE_IN_PRODUCTION)

getIdxOfLastCharNIA

public final int getIdxOfLastCharNIA(StringOrBuffer str_orBfr,
                                     char[] a_char,
                                     int i_idxStart,
                                     int i_idxFirstfterEnd,
                                     boolean b_validateAOC)

Get the array index of the last character that does not exist in the array.

See getIdxOf1stCharNIA.

Parameters:
str_orBfr - The StringOrBuffer to analyze. May not be null, or zero characters in length.
a_char - The array of characters........................... Must be non-null, at least one character in length, and each element must be unique and sorted ascending.
i_idxStart - The first/left-most array index (inclusive) at which to start analyzing. Must be between zero, and length, inclusive, and may not be greater than i_idxFirstfterEnd.
i_idxFirstfterEnd - The last/right-most array index (exclusive) at which to stop analyzing. Must be between zero, and length(), inclusive, and may not be less than or equal to i_idxStart.
b_validateAOC - If true, then it is verified that a_char conforms to its documented restrictions (an AssertException is thrown when any are violated). If false, it is assumed that it does conform. Set this to false only when you are positive a_char is valid, otherwise you will get unpredictable results/errors. Beeeeeeeee careful (reference to Disney's Alladin).
Returns:
The array index at which the last character-not-in-a_char exists, or -1, if (1) only characters in a_char exists, or (2) length() equals zero.

getVisible

public final StringOrBuffer getVisible(StringOrBuffer str_orBfr)

Get a copy of the StringOrBuffer (as an SOBStringBuffer), where the contents' invisible characters are made visible.

Returns:
The contents of getSOBSB: makeVisible(getSOBSB(str_orBfr, "getVisible"))

makeVisible

public final void makeVisible(StringOrBuffer str_orBfr)

Translate the contents of the StringOrBuffer, so all invisible characters are made visible.

Specifically each '\n', '\f', '\r' and '\t' is translated to "\\n", "\\f", "\\r", "\\t", respectively.

Parameters:
str_orBfr - The StringOrBuffer to translate.

isLetterDigitUnderscore

public boolean isLetterDigitUnderscore(StringOrBuffer str_orBfr)

Does the string contain only letters, digits and underscores?

Returns:
isLegal(str_orBfr, true, true, new char[] {'_'})

hasLettersOrInAOC

public boolean hasLettersOrInAOC(StringOrBuffer str_orBfr,
                                 boolean b_digitsOkOpt,
                                 char[] ac_legal)

Does the string contain only letters and (other provided) legal characters?

Returns:
hasLettersOrInAOC(str_orBfr, b_digitsOkOpt, ac_legal, bFALSE_IN_PRODUCTION)

hasLettersOrInAOC

public boolean hasLettersOrInAOC(StringOrBuffer str_orBfr,
                                 boolean b_digitsOkOpt,
                                 char[] ac_legal,
                                 boolean b_validateAOC)

Does the string contain only letters and (other provided) legal characters?

Returns:
isLegal(str_orBfr, true, b_digitsOkOpt, ac_legal, b_validateAOC)

hasDigitsOrInAOC

public boolean hasDigitsOrInAOC(StringOrBuffer str_orBfr,
                                boolean b_lettersOkOpt,
                                char[] ac_legal)

Does the string contain only digits and (other provided) legal characters?

Returns:
hasDigitsOrInAOC(str_orBfr, b_lettersOkOpt, ac_legal, bFALSE_IN_PRODUCTION)

hasDigitsOrInAOC

public boolean hasDigitsOrInAOC(StringOrBuffer str_orBfr,
                                boolean b_lettersOkOpt,
                                char[] ac_legal,
                                boolean b_validateAOC)

Does the string contain only digits and (other provided) legal characters?

Returns:
isLegal(str_orBfr, b_lettersOkOpt, true, ac_legal, b_validateAOC)

hasLDOrInAOC

public boolean hasLDOrInAOC(StringOrBuffer str_orBfr,
                            char[] ac_legal)

Does the string contain only letters, digits and (other provided) legal characters?

Returns:
hasLDOrInAOC(str_orBfr, ac_legal, bFALSE_IN_PRODUCTION)

hasLDOrInAOC

public boolean hasLDOrInAOC(StringOrBuffer str_orBfr,
                            char[] ac_legal,
                            boolean b_validateAOC)

Does the string contain only letters, digits and (other provided) legal characters?

Returns:
hasLDOrInAOC(str_orBfr, true, true, ac_legal, b_validateAOC)

hasLegalChars

public boolean hasLegalChars(StringOrBuffer str_orBfr,
                             char[] ac_legal)

Does the string contain only legal characters?

Returns:
hasLegalChars(str_orBfr, ac_legal, bFALSE_IN_PRODUCTION)

hasLegalChars

public boolean hasLegalChars(StringOrBuffer str_orBfr,
                             char[] ac_legal,
                             boolean b_validateAOC)

Does the string contain only legal characters?

Returns:
isLegal(str_orBfr, false, false, ac_legal, b_validateAOC)

isLegal

public boolean isLegal(StringOrBuffer str_orBfr,
                       boolean b_lettersOkOpt,
                       boolean b_digitsOkOpt,
                       char[] ac_legal)

Does the string contain only legal characters?

Returns:
isLegal(str_orBfr, b_lettersOkOpt, b_digitsOkOpt, ac_legal, bFALSE_IN_PRODUCTION)

isLegal

public boolean isLegal(StringOrBuffer str_orBfr,
                       boolean b_lettersOkOpt,
                       boolean b_digitsOkOpt,
                       char[] ac_legal,
                       boolean b_validateAOC)

Does the string contain only legal characters?

Returns:
true If every character causes UtilChar.isLegal(c, b_lettersOkOpt, b_digitsOkOpt, ac_legal, b_validateAOC) to return true. b_validateAOC is only passed once. On the second and subsequent times, this parameter is set to false.
false If any character is not considered legal.

isNotLettersOrInAOC

public boolean isNotLettersOrInAOC(StringOrBuffer str_orBfr,
                                   boolean b_digitsBadOpt,
                                   char[] ac_legal)

Does the string not contain any letters or (other provided) illegal characters?

Returns:
isNotLettersOrInAOC(str_orBfr, b_digitsBadOpt, ac_legal, bFALSE_IN_PRODUCTION)

isNotLettersOrInAOC

public boolean isNotLettersOrInAOC(StringOrBuffer str_orBfr,
                                   boolean b_digitsBadOpt,
                                   char[] ac_legal,
                                   boolean b_validateAOC)

Does the string not contain any letters or (other provided) illegal characters?

Returns:
isNotIllegal(str_orBfr, true, b_digitsBadOpt, ac_legal, b_validateAOC)

isNotDigitsOrInAOC

public boolean isNotDigitsOrInAOC(StringOrBuffer str_orBfr,
                                  boolean b_lettersBadOpt,
                                  char[] ac_legal)

Does the string not contain any digits or (other provided) illegal characters?

Returns:
isNotDigitsOrInAOC(str_orBfr, b_digitsBadOpt, ac_legal, bFALSE_IN_PRODUCTION)

isNotDigitsOrInAOC

public boolean isNotDigitsOrInAOC(StringOrBuffer str_orBfr,
                                  boolean b_lettersBadOpt,
                                  char[] ac_legal,
                                  boolean b_validateAOC)

Does the string not contain any digits or (other provided) illegal characters?

Returns:
isNotIllegal(str_orBfr, b_lettersBadOpt, true, ac_legal, b_validateAOC)

isNotLDOrInAOC

public boolean isNotLDOrInAOC(StringOrBuffer str_orBfr,
                              char[] ac_legal)

Does the string not contain any letters, digits or (other provided) illegal characters?

Returns:
isNotLDOrInAOC(str_orBfr, ac_legal, bFALSE_IN_PRODUCTION)

isNotLDOrInAOC

public boolean isNotLDOrInAOC(StringOrBuffer str_orBfr,
                              char[] ac_legal,
                              boolean b_validateAOC)

Does the string not contain any letters, digits or (other provided) illegal characters?

Returns:
isNotIllegal(str_orBfr, true, true, ac_legal, b_validateAOC)

hasNoIllegalChars

public boolean hasNoIllegalChars(StringOrBuffer str_orBfr,
                                 char[] ac_illegal)

Does the string not contain any illegal characters?

Returns:
hasNoIllegalChars(str_orBfr, ac_illegal, bFALSE_IN_PRODUCTION)

hasNoIllegalChars

public boolean hasNoIllegalChars(StringOrBuffer str_orBfr,
                                 char[] ac_illegal,
                                 boolean b_validateAOC)

Does the string not contain any illegal characters?

Returns:
isNotIllegal(str_orBfr, false, false, ac_illegal, b_validateAOC)

isNotIllegal

public boolean isNotIllegal(StringOrBuffer str_orBfr,
                            boolean b_lettersBadOpt,
                            boolean b_digitsBadOpt,
                            char[] ac_illegal)

Does the string not contain any illegal characters?

Returns:
isNotIllegal(str_orBfr, b_lettersBadOpt, b_digitsBadOpt, ac_illegal, bFALSE_IN_PRODUCTION)

isNotIllegal

public boolean isNotIllegal(StringOrBuffer str_orBfr,
                            boolean b_lettersBadOpt,
                            boolean b_digitsBadOpt,
                            char[] ac_illegal,
                            boolean b_validateAOC)

Does the string not contain any illegal characters?

Returns:
true If every character causes UtilChar.isNotIllegal(c, b_lettersBadOpt, b_digitsBadOpt, ac_illegal, b_validateAOC) to return true (in other words: If every character is not illegal/is legal). b_validateAOC is only passed once. On the second and subsequent times, this parameter is set to false.
false If UtilChar.isNotIllegal returns false for any character.

getReplaceAll

public final SOBStringBuffer getReplaceAll(StringOrBuffer sob_searchIn,
                                           String s_searchFor,
                                           String s_replaceWith)

Return a copy of the provided StringOrBuffer (as an SOBStringBuffer), in which all occurances are replaced.

Returns:
The contents of getSOBSB: replaceAll(getSOBSB(sob_searchIn, "getReplaceAll"), s_searchFor, s_replaceWith)

replaceAll

public final int replaceAll(StringOrBuffer sob_searchIn,
                            String s_searchFor,
                            String s_replaceWith)

Replace all occurances. This function returns an int, representing the number of replacements made.

Note

Say the contents of sob_searchIn equals "aaaaa", s_searchFor equals "aa" and s_replaceWith equals "a". The resulting contents of sob_searchIn will be "aaa". In sequence

  1. "aaaaa" is what we're starting with.
  2. Elements zero and one are replaced with a single "a", resulting in "aaaa".
  3. The next "aa" is found at element one, not zero. After replacing elements one and two, we're left with "aaa"
  4. We resume the search at array index two. There are no more occurances of "aa" found at that point, so were done.
  5. This function returns two, reflecting the number of replacements.

Why this behavior? In order to prevent infinite loops. If the search were to resume at the same index (after a replacement), then replacing "a" with "aa" (duplicating, instead of removing duplicates) would never move beyond the index of the first instance of "a". It would just infinitely replace that first "a" with "aa", eventually causing an OutOfMemoryError.

The moral of the story: Run this multiple times in order to replace a superset with it's subset. Say "sLINE_SEP + sLINE_SEP" with "sLINE_SEP" (to eliminate all empty lines). Just keep replacing until this function returns zero.

Parameters:
sob_searchIn - The string to search through and (potentially) do replacements in. May not be null.
s_searchFor - The string to search for, in sob_searchIn. May not be null or zero characters in length.
s_replaceWith - The string to replace all occurances of s_searchFor with. May not be null or equal to s_searchFor
Returns:
The number of replacements made.

getReplaceUntil

public final SOBStringBuffer getReplaceUntil(StringOrBuffer sob_searchIn,
                                             String s_searchFor,
                                             String s_replaceWith)

Replace all occurances, with multiple passes, until no instances of the search string remain.

Returns:
The SOBStringBuffer after calling replaceUntil((new SOBStringBuffer(sob_searchIn, sUSOB + "getReplaceUntil")), s_searchFor, s_replaceWith)

replaceUntil

public final i_i replaceUntil(StringOrBuffer sob_searchIn,
                              String s_searchFor,
                              String s_replaceWith)

Replace all occurances, with multiple passes, until no instances of the search string remain.

This repeatedly calls replaceAll(sob_searchIn, s_searchFor, s_replaceWith) until zero is returned. See replaceAll for parameter documentation.

Returns:
An i_i containing exactly two ints:
  • i1 is the total instances of s_searchFor that were found.
  • i2 is the total number of times replaceAll was called.

getSOBS

public final SOBString getSOBS(StringOrBuffer str_orBfr,
                               String s_callingFunc)

Create an SOBString from the StringOrBuffer.

Returns:
getSOBS(str_orBfr, "str_orBfr", s_callingFunc)

getSOBS

public final SOBString getSOBS(StringOrBuffer str_orBfr,
                               String s_description,
                               String s_callingFunc)

Create an SOBString from the StringOrBuffer.

Parameters:
str_orBfr - The StringOrBuffer to create an SOBString from. May not be null.
s_sobDescription - The descriptive name of str_orBfr, for potential error messages.
s_callingFunc - The function from which the potential error message should appear as if it is coming from.
Returns:
(new SOBString(str_orBfr.toString()))

getSOBSB

public final SOBStringBuffer getSOBSB(StringOrBuffer str_orBfr,
                                      String s_callingFunc)

Create an SOBStringBuffer from the StringOrBuffer.

Returns:
getSOBSB(str_orBfr, "str_orBfr", s_callingFunc)

getSOBSB

public final SOBStringBuffer getSOBSB(StringOrBuffer str_orBfr,
                                      String s_description,
                                      String s_callingFunc)

Create an SOBString from the StringOrBuffer.

Parameters:
str_orBfr - The StringOrBuffer to create an SOBStringBuffer from. May not be null.
s_sobDescription - The descriptive name of str_orBfr, for potential error messages.
s_callingFunc - The function from which the potential error message should appear as if it is coming from.
Returns:
(new SOBStringBuffer(str_orBfr.toString()))

throwAXIfBadSOB

public final void throwAXIfBadSOB(StringOrBuffer str_orBfr,
                                  String s_sobDescription,
                                  String s_callingFunc)

If the StringOrBuffer is null or empty (the string contained within is zero characters in length), then die. Otherwise do nothing.

Parameters:
str_orBfr - The StringOrBuffer to analyze for null-ness and emptiness.
s_sobDescription - The descriptive name of str_orBfr, for potential error messages.
s_callingFunc - The function from which a potential error message should appear as if it is coming from.



Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.

 

http://sourceforge.net/projects/xbnjava

 

SourceForge.net Logo