/* 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.padchop; import xbn.XBNObject; import xbn.string.UtilString; /**
Holds and manages configuration for a PadChopString. See PadChopString.
Source code: PCSConfig.java.
Create a PCSConfig.
Equal to PCSConfig(i_length, (new SpcfcCfgChop()), (new SpcfcCfgPad()))
Create a PCSConfig.
Equal to PCSConfig(i_length, sc_chop, sc_pad, (new SpcfcCfgIfNull()))
Create a PCSConfig.
@param i_length The length to chop or pad to. Must be greater than zero. See getLength and setLength. @param sc_chop The chop-specific configuration. If null, chopping does not occur. See getSpcfcCfgChop and setSpcfcCfgChop. @param sc_pad The pad-specific configuration. If null, padding does not occur. See getSpcfcCfgPad and setSpcfcCfgPad. @param sc_ifNull The crash-if-null-specific configuration. May not be null. See getSpcfcCfgIfNull and setSpcfcCfgIfNull. **/ public PCSConfig(int i_length, SpcfcCfgChop sc_chop, SpcfcCfgPad sc_pad, SpcfcCfgIfNull sc_ifNull) { setLength(i_length); setSpcfcCfgChop(sc_chop); setSpcfcCfgPad(sc_pad); setSpcfcCfgIfNull(sc_ifNull); } /**What is the length to pad/chop to?
@return i_length Exactly as provided to setLength. **/ public final int getLength() { return iLength; } /**If the string's length exceeds getLength, should it it be chopped?. See getLength
@return(getSpcfcCfgChop() != null)
**/
public final boolean doChop() {
return (getSpcfcCfgChop() != null);
}
/**
If the string's length does not meet getLength, should it it be padded?. See getLength
@return(getSpcfcCfgPad() != null)
**/
public final boolean doPad() {
return (getSpcfcCfgPad() != null);
}
/**
Get the SpcfcCfgChop for direct manipulation.
The existence of this object declares that chopping will take place. See doChop.
@return sc_chop Exactly as provided to setSpcfcCfgChop. **/ public final SpcfcCfgChop getSpcfcCfgChop() { return scc; } /**Get the SpcfcCfgPad for direct manipulation.
The existence of this object declares that padding will take place. See doPad.
@return sc_pad Exactly as provided to setSpcfcCfgPad. **/ public final SpcfcCfgPad getSpcfcCfgPad() { return scp; } /**Get the SpcfcCfgIfNull for direct manipulation.
@return pcs_IfNullCfg Exactly as provided to setSpcfcCfgIfNull. **/ public final SpcfcCfgIfNull getSpcfcCfgIfNull() { return scin; } /**Set the SpcfcCfgChop.
Get with getSpcfcCfgChop
.
Set the SpcfcCfgPad.
Get with getSpcfcCfgPad
.
Set the SpcfcCfgIfNull.
Get with getSpcfcCfgIfNull
.
Set the length to pad/chop to.
Get with getLength
Get some information about this PadChopString.
**/ public String toString() { UtilString uStr = new UtilString(); String sPCSC = null; if(getSpcfcCfgChop() == null) { sPCSC = "getSpcfcCfgChop()=null"; } else { sPCSC = uStr.getConditional("[", getSpcfcCfgChop().toString(), "]"); } String sSpcfcCfg = null; if(getSpcfcCfgPad() == null) { sSpcfcCfg = "getSpcfcCfgPad()=null"; } else { sSpcfcCfg = uStr.getConditional("[", getSpcfcCfgPad().toString(), "]"); } return this.getClass().getName() + ": getLength()=" + getLength() + ", " + sPCSC + ", " + sSpcfcCfg + ", [" + getSpcfcCfgIfNull().toString() + "]"; } }