/* 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.config; import xbn.XBNObject; import xbn.array.VWChar; import xbn.array.APChar; import xbn.array.primitive.PACChar; import xbn.array.primitive.PARCStrict; import xbn.array.primitive.PAROrderDir; import xbn.string.UtilChar; /**
Configuration related to variables in a ConfigReader, provided via CRConfig. Provided to ConfigReader via CRConfig.
Source code: CRCDelimiters.java
Specifically, this class defines two things: The delimiters found between variable names and values (for example: '=') and the special string value to be considered as "null".
@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public class CRCDelimiters extends XBNObject { private APChar apcVarDelims = null; private char cMLCStart = ' '; private char cMLCEnd = ' '; private char cSingleLineCmt = ' '; /**Create a CRCDelimiters.
Equal to CRCDelimiters(ac_varDelims, '#')
Create a CRCDelimiters.
Equal to CRCDelimiters(ac_varDelims, '{', '}', c_singleLineCmt)
Create a CRCDelimiters.
Equal to CRCDelimiters(ac_varDelims, c_mlcStart, c_mlcEnd, '#')
Create a CRCDelimiters.
This object is provided directly to the CRConfig constructor. Some extra parameter restrictions are enforced there.
No character (either equalling or existing in any of these parameters) may equal another, nor may they be invisible.
@param ac_varDelims The delimiters to separate the names and values of ConfigReader variables. Must be non null and at least one element in length. All values must be unique, and ordered ascending. See getVarDelimsAPC. @param c_mlcStart The character used to delimit the start of a multi-line comment. May not equal c_mlcEnd or c_singleLineCmt. See getMLCStart. @param c_mlcEnd The character used to delimit the end of a multi-line comment. May not equal c_mlcStart or c_singleLineCmt. See getMLCEnd. @param c_singleLineCmt The character used to delimit the start of a single-line comment. May not equal c_mlcStart or c_mlcEnd. See getDelimSL. **/ public CRCDelimiters(char[] ac_varDelims, char c_mlcStart, char c_mlcEnd, char c_singleLineCmt) { PACChar pacc = new PACChar(ac_varDelims, new PARCStrict(new PAROrderDir(true), UtilChar.getAOCInvisible())); pacc.crashIfBad("xbn.config.CRCDelimiters.constructor", "ac_varDelims"); apcVarDelims = new APChar(ac_varDelims, true); ZCICharErr cice = new ZCICharErr(); cice.ciInvisible(c_mlcStart, "c_mlcStart"); cice.ciInvisible(c_mlcEnd, "c_mlcEnd"); cice.ciInvisible(c_singleLineCmt, "c_singleLineCmt"); VWChar vwc = new VWChar(); vwc.addArray(ac_varDelims); vwc.add(c_mlcStart); vwc.add(c_mlcEnd); vwc.add(c_singleLineCmt); char[] ac = vwc.getAOChar(); pacc = new PACChar(ac, new PARCStrict()); if(!pacc.isValid()) { throwAX("constructor: ac_varDelims (['" + apcVarDelims.getList("', '") + "']) is valid. However, all characters in ac_varDelims, along with c_mlcStart ('" + c_mlcStart + "'), c_mlcEnd ('" + c_mlcEnd + "') and c_singleLineCmt ('" + c_singleLineCmt + "'), must be unique."); } cMLCStart = c_mlcStart; cMLCEnd = c_mlcEnd; cSingleLineCmt = c_singleLineCmt; } /**Get an APChar containing the variable delimiters.
A variable delimiter is what is found between the name and value of a variable.
@return(new APChar(ac_varDelims, true))
Where ac_varDelims is exactly as provided to the constructor. The APChar is created only once.
**/
public final APChar getVarDelimsAPC() {
return apcVarDelims;
}
/**
What character is used to delimit the start of a multi-line comment?
@return c_mlcStart Exactly as provided to the constructor. **/ public final char getMLCStart() { return cMLCStart; } /**What character is used to delimit the end of a multi-line comment?
@return c_mlcEnd Exactly as provided to the constructor. **/ public final char getMLCEnd() { return cMLCEnd; } /**What character is used to delimit the start of a single-line comment?
@return c_singleLineCmt Exactly as provided to the constructor. **/ public final char getSingleLineCmt() { return cSingleLineCmt; } /**Get some information about this CRCDelimiters.
**/ public String toString() { return this.getClass().getName() + ": getVarDelimsAPC()=" + getVarDelimsAPC().toString() + ", " + "', getMLCStart()='" + getMLCStart() + "', getMLCEnd()='" + getMLCEnd() + "', getSingleLineCmt()='" + getSingleLineCmt() + "'"; } }