/* 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.template; import xbn.XBNObject; import xbn.output.Outputter; import xbn.string.escape.USCIgnore; import xbn.string.UtilChar; import xbn.string.UtilString; /**

Configuration for when parsing the source text for a single Template. See the constructor for TemplateDataOrString.

Source code:  TParseConfig.java.

@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public class TParseConfig extends XBNObject { private GapConfig gc = null; private boolean bIgnoreSurrTxt = false; private USCIgnore usci = null; private Outputter optrDbg = null; /**

Create a TParseConfig with default settings.

Equal to TParseConfig(false)

**/ public TParseConfig() { this(false); } /**

Create a TParseConfig.

Equal to TParseConfig(gap_config, false)

**/ public TParseConfig(GapConfig gap_config) { this(gap_config, false); } /**

Create a TParseConfig.

Equal to TParseConfig((new GapConfig()), b_ignoreSurrTxt)

**/ public TParseConfig(boolean b_ignoreSurrTxt) { this((new GapConfig()), b_ignoreSurrTxt); } /**

Create a TParseConfig.

Equal to TParseConfig(false, euscu_ignore)

**/ public TParseConfig(USCIgnore euscu_ignore) { this(false, euscu_ignore); } /**

Create a TParseConfig.

Equal to TParseConfig(false, optr_dbg)

**/ public TParseConfig(Outputter optr_dbg) { this(false, optr_dbg); } /**

Create a TParseConfig.

Equal to TParseConfig(gap_config, b_ignoreSurrTxt, (new Outputter()))

**/ public TParseConfig(GapConfig gap_config, boolean b_ignoreSurrTxt) { this(gap_config, b_ignoreSurrTxt, (new Outputter())); } /**

Create a TParseConfig.

Equal to TParseConfig(gap_config, false, euscu_ignore)

**/ public TParseConfig(GapConfig gap_config, USCIgnore euscu_ignore) { this(gap_config, false, euscu_ignore); } /**

Create a TParseConfig.

Equal to TParseConfig(gap_config, false, optr_dbg)

**/ public TParseConfig(GapConfig gap_config, Outputter optr_dbg) { this(gap_config, false, optr_dbg); } /**

Create a TParseConfig.

Equal to TParseConfig((new GapConfig()), b_ignoreSurrTxt, euscu_ignore)

**/ public TParseConfig(boolean b_ignoreSurrTxt, USCIgnore euscu_ignore) { this((new GapConfig()), b_ignoreSurrTxt, euscu_ignore); } /**

Create a TParseConfig.

Equal to TParseConfig((new GapConfig()), b_ignoreSurrTxt, optr_dbg)

**/ public TParseConfig(boolean b_ignoreSurrTxt, Outputter optr_dbg) { this((new GapConfig()), b_ignoreSurrTxt, optr_dbg); } /**

Create a TParseConfig.

Equal to TParseConfig(false, euscu_ignore, optr_dbg)

**/ public TParseConfig(USCIgnore euscu_ignore, Outputter optr_dbg) { this(false, euscu_ignore, optr_dbg); } /**

Create a TParseConfig.

Equal to TParseConfig(gap_config, b_ignoreSurrTxt, euscu_ignore, (new Outputter()))

**/ public TParseConfig(GapConfig gap_config, boolean b_ignoreSurrTxt, USCIgnore euscu_ignore) { this(gap_config, b_ignoreSurrTxt, euscu_ignore, (new Outputter())); } /**

Create a TParseConfig.

Equal to TParseConfig(gap_config, b_ignoreSurrTxt, (new USCIgnore()), optr_dbg)

**/ public TParseConfig(GapConfig gap_config, boolean b_ignoreSurrTxt, Outputter optr_dbg) { this(gap_config, b_ignoreSurrTxt, (new USCIgnore()), optr_dbg); } /**

Create a TParseConfig.

Equal to TParseConfig(gap_config, false, euscu_ignore, optr_dbg)

**/ public TParseConfig(GapConfig gap_config, USCIgnore euscu_ignore, Outputter optr_dbg) { this(gap_config, false, euscu_ignore, optr_dbg); } /**

Create a TParseConfig.

Equal to TParseConfig((new GapConfig()), b_ignoreSurrTxt, euscu_ignore, optr_dbg)

**/ public TParseConfig(boolean b_ignoreSurrTxt, USCIgnore euscu_ignore, Outputter optr_dbg) { this((new GapConfig()), b_ignoreSurrTxt, euscu_ignore, optr_dbg); } /**

Create an TParseConfig.

@param gap_config The configuration defining a gap. May not be null. @param b_ignoreSurroundingText If true, then surrounding text is ignored, which saves memory when you don't need it anyway. @param euscu_ignore Configuration determiting how to deal with characters--other than c_escape and the tag delimiter--that are escaped. May not be null and both euscu_ignore.isSpcfcIgnored(gap_config.getTagDelimiter()) and euscu_ignore.isSpcfcIgnored(gap_config.getEscapeChar()) must equal false. @param optr_dbg The Outputter used for debugging purposes. May not be null. **/ public TParseConfig(GapConfig gap_config, boolean b_ignoreSurrTxt, USCIgnore euscu_ignore, Outputter optr_dbg) { throwAXIfNull(gap_config, "gap_config", sCNSTR); throwAXIfNull(euscu_ignore, "euscu_ignore", sCNSTR); throwAXIfNull(optr_dbg, "optr_dbg", sCNSTR); if((new UtilChar()).isInvisible(gap_config.getTagDelimiter())) { throwAX("constructor: gap_config.getTagDelimiter() ('" + (new UtilString()).getVisible(gap_config.getTagDelimiter() + sES) + "') is a whitespace character."); } if(euscu_ignore.isSpcfcIgnored(gap_config.getTagDelimiter())) { throwAX("constructor: gap_config.getTagDelimiter() ('" + gap_config.getTagDelimiter() + "') is an ignored character. In other words, euscu_ignore.isSpcfcIgnored(gap_config.getTagDelimiter()) equals true."); } if(euscu_ignore.isSpcfcIgnored(gap_config.getEscapeChar())) { throwAX("constructor: gap_config.getEscapeChar() ('" + gap_config.getEscapeChar() + "') is an ignored character. In other words, euscu_ignore.isSpcfcIgnored(gap_config.getEscapeChar()) equals true."); } gc = gap_config; bIgnoreSurrTxt = b_ignoreSurrTxt; usci = euscu_ignore; optrDbg = optr_dbg; } /**

Get the GapConfig for direct manipulation.

@return gap_config Exactly as provided to the constructor. **/ public final GapConfig getGapConfig() { return gc; } /**

Should surrounding text be ignored?

@return b_ignoreSurrTxt, as provided to the constructor. **/ public final boolean doIgnoreSurrTxt() { return bIgnoreSurrTxt; } /**

Get the USCIgnore for direct manipulation.

@return euscu_ignore Exactly as provided to the constructor. **/ public final USCIgnore getUSCIgnore() { return usci; } /**

Get the Outputter used for debugging for direct manipulation.

@return optr_dbg, as provided to the constructor. **/ public Outputter getOptrDebug() { return optrDbg; } /**

Get some information about this TParseConfig.

**/ public String toString() { return this.getClass().getName() + ": doIgnoreSurrTxt()=" + doIgnoreSurrTxt() + ", [" + getGapConfig().toString() + "], [" + getUSCIgnore().toString() + "], [" + getOptrDebug().toString() + "]"; } }