/* 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.string.UtilString; /**

Random functions to create, manipulate and analyze template gaps.

Source code:  UtilGap.java

The functions in both this and TConfigDefaults were originally in xbn.template.util.UtilTemplate. To avoid circular dependencies, it's all been split into these three pieces.

@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public class UtilGap extends XBNObject { private UtilString uStr = new UtilString(); /**

Create a UtilGap. This constructor does nothing.

**/ public UtilGap() { } /**

Get the tag that starts or ends a gap.

@return getTag(TConfigDefaults.getTagDelimiter(), s_tagText) **/ public final String getTag(String s_tagText) { return getTag(TConfigDefaults.getTagDelimiter(), s_tagText); } /**

Get the tag that starts or ends a gap.

@param c_tagDelimiter The tag delimiter. This character must not be the escape slash ('\\'), nor may it exist anywhere in s_tagText. @param s_tagText The text contained inside the start or end tag of a gap. Must be non-null, at least one and no more than TConfigDefaults.getMaxTagTxtLength characters in length, and only contai~JD~tcd~EJD~n letters, digits and underscores, except c_tagDelimiter. @return c_tagDelimiter (as a string) + s_tagText + c_tagDelimiter **/ public final String getTag(char c_tagDelimiter, String s_tagText) { if(c_tagDelimiter == '\\') { throwAX("getTag: c_tagDelimiter equals the escape slash ('\\')."); } String sTagDelim = new Character(c_tagDelimiter).toString(); if(s_tagText == null || s_tagText.length() < 1 || s_tagText.length() > TConfigDefaults.getMaxTagTxtLength() || !uStr.isLetterDigitUnderscore(s_tagText) || s_tagText.indexOf(sTagDelim) != -1) { throwAX("getTag: s_tagText must be non-null, between one and TConfigDefaults.getMaxTagTxtLength() (" + TConfigDefaults.getMaxTagTxtLength() + ") characters in length (inclusive), and must only contain letters, digits and underscores, except c_tagDelimiter ('" + c_tagDelimiter + "'). Currently '" + s_tagText + "'."); } return (new StringBuffer(sTagDelim)).append(s_tagText).append(sTagDelim).toString(); } }