xbn.string
Class TrimChars

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.string.TrimChars
Direct Known Subclasses:
TCInvisible

public class TrimChars
extends XBNObject

Trim characters off the ends of a string.

Source code:  TrimChars.java


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
TrimChars()
          Create a TrimChars with default settings.
TrimChars(char[] ac_charsToTrim)
          Create a TrimChars.
TrimChars(char[] ac_toTrim, boolean b_validateACToTrim)
          Create a TrimChars.
TrimChars(char[] ac_charsToTrim, boolean b_checkRightForEsc, char c_escape)
          Create a TrimChars.
TrimChars(char[] ac_toTrim, boolean b_checkRightForEsc, char c_escape, boolean b_validateParams)
          Create a TrimChars.
TrimChars(char[] ac_charsToTrim, char c_escape)
          Create a TrimChars.
TrimChars(char[] ac_toTrim, TALConfig tal_config)
          Create a TrimChars.
TrimChars(char[] ac_toTrim, TALConfig tal_config, boolean b_validateParams)
          Create a TrimChars.
TrimChars(char[] ac_toTrim, TALConfig tal_config, boolean b_checkRightForEsc, char c_escape)
          Create a TrimChars.
TrimChars(char[] ac_toTrim, TALConfig tal_config, boolean b_checkRightForEsc, char c_escape, boolean b_validateParams)
          Create a TrimChars.
TrimChars(TALConfig tal_config)
          Create a TrimChars.
 
Method Summary
 boolean doCheckRightForEsc()
          Should only non-escaped characters be trimmed from the right side?
 String get(String s_tr)
          Get a copy of the string where characters have been trimmed.
 StringBuffer get(StringBuffer str_buffer)
          Get a copy of the StringBuffer where characters have been trimmed.
 StringBuffer get(StringBuffer str_buffer, int i_idxLeft, int i_idxAfterRight)
          Get a copy of the StringBuffer where characters have been trimmed.
 String get(String s_tr, int i_idxLeft, int i_idxAfterRight)
          Get a copy of the string where characters have been trimmed.
 SOBStringBuffer get(StringOrBuffer str_orBfr)
          Get a copy of the StringOrBuffer (as an SOBStringBuffer) where characters have been trimmed.
 SOBStringBuffer get(StringOrBuffer str_orBfr, int i_idxLeft, int i_idxAfterRight)
          Get a copy of the StringOrBuffer (as an SOBStringBuffer) where characters have been trimmed.
 String getAllLines(String s_tr)
          Get a copy of the string where characters have been trimmed from the ends of every line.
 StringBuffer getAllLines(StringBuffer str_buffer)
          Get a copy of the StringBuffer where characters have been trimmed from the ends of every line.
 SOBStringBuffer getAllLines(StringOrBuffer str_orBfr)
          Get a copy of the StringOrBuffer where characters have been trimmed from the ends of every line.
 APChar getAPCToTrim()
          Get the array of characters to be trimmed.
 char getEscapeChar()
          The escape character, when only non-escaped chararcters are trimmed from the right side.
 TALConfig getTALConfig()
          Get the TALConfig, which holds the configuration for trimAllLines.
 i_i getTrimData()
          Get information about the just-called trim or get.
 i_i trim(StringBuffer str_buffer)
          Trim characters off the ends of the StringBuffer.
 i_i trim(StringBuffer str_buffer, int i_idxLeft, int i_idxAfterRight)
          Trim characters off the ends of the StringBuffer.
 i_i trim(StringOrBuffer str_orBfr)
          Trim characters off the ends of the StringOrBuffer.
 i_i trim(StringOrBuffer str_orBfr, int i_idxLeft, int i_idxAfterRight)
          Trim characters off the ends of the StringOrBuffer.
 void trimAllLines(StringBuffer str_buffer)
          Trim characters off the ends of every line in the StringBuffer.
 void trimAllLines(StringOrBuffer str_orBfr)
          TrimChars the characters from the start and end of each line within the StringOrBuffer.
 
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
 

Constructor Detail

TrimChars

public TrimChars()

Create a TrimChars with default settings.

Equal to TrimChars(UtilChar.getAOCTabSpace())


TrimChars

public TrimChars(char[] ac_charsToTrim)

Create a TrimChars.

Equal to TrimChars(ac_charsToTrim, bFALSE_IN_PRODUCTION)


TrimChars

public TrimChars(char[] ac_charsToTrim,
                 boolean b_checkRightForEsc,
                 char c_escape)

Create a TrimChars.

Equal to TrimChars(ac_charsToTrim, b_checkRightForEsc, c_escape, bFALSE_IN_PRODUCTION)


TrimChars

public TrimChars(char[] ac_charsToTrim,
                 char c_escape)

Create a TrimChars.

Equal to TrimChars(ac_charsToTrim, true, c_escape)


TrimChars

public TrimChars(TALConfig tal_config)

Create a TrimChars.

Equal to TrimChars((UtilChar.getAOCTabSpace(), tal_config)


TrimChars

public TrimChars(char[] ac_toTrim,
                 TALConfig tal_config)

Create a TrimChars.

Equal to TrimChars((ac_toTrim, tal_config, bFALSE_IN_PRODUCTION)


TrimChars

public TrimChars(char[] ac_toTrim,
                 boolean b_validateACToTrim)

Create a TrimChars.

Equal to TrimChars(ac_toTrim, (new TALConfig()), b_validateACToTrim)


TrimChars

public TrimChars(char[] ac_toTrim,
                 TALConfig tal_config,
                 boolean b_validateParams)

Create a TrimChars.

Equal to TrimChars(ac_toTrim, tal_config, false, ' ', b_validateACToTrim)


TrimChars

public TrimChars(char[] ac_toTrim,
                 TALConfig tal_config,
                 boolean b_checkRightForEsc,
                 char c_escape)

Create a TrimChars.

Equal to TrimChars(ac_toTrim, tal_config, b_checkRightForEsc, c_escape, bFALSE_IN_PRODUCTION)


TrimChars

public TrimChars(char[] ac_toTrim,
                 boolean b_checkRightForEsc,
                 char c_escape,
                 boolean b_validateParams)

Create a TrimChars.

Equal to TrimChars(ac_toTrim, (new TALConfig()), b_checkRightForEsc, c_escape, b_validateParams)


TrimChars

public TrimChars(char[] ac_toTrim,
                 TALConfig tal_config,
                 boolean b_checkRightForEsc,
                 char c_escape,
                 boolean b_validateParams)

Create a TrimChars.

Parameters:
ac_toTrim - The array of characters to trim. May not be null or zero elements in length. Must have all unique values, ordered ascending ('a', 'b', 'c', ...). See getAPCToTrim.
tal_config - The configuration for trimAllLines. May not be null, and tal_config.getLineSeparator may not contain any characters existing in ac_toTrim (or c_escape, if b_checkRightForEsc is true). See getTALConfig
b_checkRightForEsc - If true, then before the right side is trimmed, it is ensured that the character that is about to be eliminated, is not escaped. If it is, trimming stops. When b_trimRight equals false, this must equal false. See doCheckRightForEsc.
c_escape - The escape character, when b_checkRightForEsc is true (this may not equal any member of ac_toTrim). When b_checkRightForEsc equals false, this must equal ' '. See getEscapeChar.
b_validateParams - If true, then all documented parameter restrictions are checked, and an AssertException is thrown when any violation is found. When false, be darn-tooting sure the parameters coform to documented restrictions.
Method Detail

getAPCToTrim

public final APChar getAPCToTrim()

Get the array of characters to be trimmed.

Returns:
new APChar(ac_toTrim) Where ac_toTrim is exactly as provided to the constructor.

getTALConfig

public final TALConfig getTALConfig()

Get the TALConfig, which holds the configuration for trimAllLines. See trimAllLines.

Returns:
tal_config Exactly as provided to the constructor.

doCheckRightForEsc

public final boolean doCheckRightForEsc()

Should only non-escaped characters be trimmed from the right side?

When this equals true, getEscapeChar is used. When this returns false, getEscapeChar is ignored.

Returns:
b_checkRightForEsc Exactly as provided to the constructor.

getEscapeChar

public final char getEscapeChar()

The escape character, when only non-escaped chararcters are trimmed from the right side.

When this character preceds a to-be-trimmed character existing on the right hand side of a string, then it is not trimmed.

See doCheckRightForEsc. If doCheckRightForEsc equals false, this is ignored.

Returns:
c_escape Exactly as provided to the constructor.

get

public final String get(String s_tr)

Get a copy of the string where characters have been trimmed.

Returns:
get([UtilString].getSOBSB(s_tr, "xbn.string.TrimChars.get")).toString()

get

public final String get(String s_tr,
                        int i_idxLeft,
                        int i_idxAfterRight)

Get a copy of the string where characters have been trimmed.

Returns:
get([UtilString].getSOBSB(s_tr, "xbn.string.TrimChars.get"), i_idxLeft, i_idxAfterRight).toString()

get

public final StringBuffer get(StringBuffer str_buffer)

Get a copy of the StringBuffer where characters have been trimmed.

Returns:
get([UtilStringBuffer].getSOBSB(str_buffer, "xbn.string.TrimChars.get")).getStringBuffer()

get

public final StringBuffer get(StringBuffer str_buffer,
                              int i_idxLeft,
                              int i_idxAfterRight)

Get a copy of the StringBuffer where characters have been trimmed.

Returns:
get([UtilStringBuffer].getSOBSB(str_buffer, "xbn.string.TrimChars.get"), i_idxLeft, i_idxAfterRight).getStringBuffer()

get

public final SOBStringBuffer get(StringOrBuffer str_orBfr)

Get a copy of the StringOrBuffer (as an SOBStringBuffer) where characters have been trimmed.

Returns:
The contents of getSOBSB: trim([UtilSOB].getSOBSB(str_orBfr, "xbn.string.TrimChars.get"))

get

public final SOBStringBuffer get(StringOrBuffer str_orBfr,
                                 int i_idxLeft,
                                 int i_idxAfterRight)

Get a copy of the StringOrBuffer (as an SOBStringBuffer) where characters have been trimmed.

Returns:
The contents of getSOBSB: trim([UtilSOB].getSOBSB(str_orBfr, "xbn.string.TrimChars.get"), i_idxLeft, i_idxAfterRight)

trim

public final i_i trim(StringBuffer str_buffer)

Trim characters off the ends of the StringBuffer.

Returns:
trim([UtilStringBuffer].getSOBSB(str_buffer, "xbn.string.TrimChars.trim"))

trim

public final i_i trim(StringBuffer str_buffer,
                      int i_idxLeft,
                      int i_idxAfterRight)

Trim characters off the ends of the StringBuffer.

Returns:
trim([UtilStringBuffer].getSOBSB(str_buffer, "xbn.string.TrimChars.trim"), i_idxLeft, i_idxAfterRight)

trim

public final i_i trim(StringOrBuffer str_orBfr)

Trim characters off the ends of the StringOrBuffer.

Returns:
trim(str_orBfr, 0, str_orBfr.length())

trim

public final i_i trim(StringOrBuffer str_orBfr,
                      int i_idxLeft,
                      int i_idxAfterRight)

Trim characters off the ends of the StringOrBuffer.

Parameters:
str_orBfr - The StringOrBuffer to trim. May not be null.
i_idxLeft - The left-most index in str_orBfr to start trimming from. If -1, then do not trim characters from the left side. Otherwise, must be a valid string index for str_orBfr, may not be greater than i_idxAfterRight (assuming i_idxAfterRight is not equal to -1).
i_idxAfterRight - The string index after the right-most index in str_orBfr to start trimming from. If -1, then do not trim characters from the right side. Otherwise, must be a valid string index for str_orBfr, and may not be less than i_idxLeft (assuming i_idxLeft is not equal to -1).
Returns:
null If both i_idxLeft and i_idxRight are equal to -1.
A i_i where i1 is the number of characters trimmed off the left side (if i_idxLeft equals -1, i1 will equal 0), and i2 is the number of characters trimmed off the right side (if i_idxAfterRight equals -1, i2 will equal 0).

getTrimData

public final i_i getTrimData()

Get information about the just-called trim or get. See trim and get.

Returns:
An i_i where i1 is the number of characters eliminated from the left side of the string, and i2 is the number eliminated from the right.
null If trim and get were never called, or threw an exception for any reason.

getAllLines

public final String getAllLines(String s_tr)

Get a copy of the string where characters have been trimmed from the ends of every line.

Returns:
getAllLines([UtilString].getSOBSB(s_tr, "xbn.string.TrimChars.getAllLines")).toString()

getAllLines

public final StringBuffer getAllLines(StringBuffer str_buffer)

Get a copy of the StringBuffer where characters have been trimmed from the ends of every line.

Returns:
getAllLines([UtilStringBuffer].getSOBSB(str_buffer, "xbn.string.TrimChars.getAllLines")).toString()

getAllLines

public final SOBStringBuffer getAllLines(StringOrBuffer str_orBfr)

Get a copy of the StringOrBuffer where characters have been trimmed from the ends of every line.

Returns:
The contents of getSOBSB: trimAllLines([UtilSOB].getSOBSB(str_orBfr, "xbn.string.TrimChars.getAllLines"))

trimAllLines

public final void trimAllLines(StringBuffer str_buffer)

Trim characters off the ends of every line in the StringBuffer.

Equal to trimAllLines([UtilStringBuffer].getSOBSB(str_buffer, "xbn.string.TrimChars.trimAllLines"))


trimAllLines

public final void trimAllLines(StringOrBuffer str_orBfr)

TrimChars the characters from the start and end of each line within the StringOrBuffer. The configuration for this function is held by getTALConfig.

Parameters:
str_orBfr - The StringOrBuffer to trim. May not be null.



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