/* 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.util.ForLineRetrieval; /**

A Template that has a specific set of unique gaps.

Source code:  TemplateOrderedGaps.java.

When you require that the Template has a specific set of unique gaps in it, use this to enforce it. This also allows TemplateFiller to "consider" these unique gaps in a certain order, even if they happen to be in a completely different order in the template text file.

See TemplateFiller.fill.

What does this "ordering" buy you? Let's say you have this template:

String sTemplate = Hello \~G\~name\~EG\~. Here is the \~G\~link\~EG\~ to that website you mentioned.

and this sub-template:

String sSublink = <A HREF="\~G\~link_url\~EG\~">\~G\~link_text\~EG\~</a>

Normally, you'd fill this template with the following code:

Template t = new Template(new FLRString(sTemplate));
Template tSubLink = new Template(new FLRString(sSublink));

TemplateFiller tf = new TemplateFiller();
tf.setTemplate(t);
tf.fill("name", "YOUR_NAME_HERE");

TemplateFiller tfSub = new TemplateFiller();
tf.setTemplate(tSubLink);
tfSub.fill("link_url", "http://sourceforge.net/projects/xbnjava");
tfSub.fill("link_text", "way cool link");

tf.fill("link", tfSub.getResult());

String sResult = tf.getResult();

Where sResult equals

Hello YOUR_NAME_HERE. Here is the <A HREF="http://sourceforge.net/projects/xbnjava">way cool link</a> to that website you mentioned.

Using this class, TemplateOrderedGaps, the code is a more concise:

Template t = new Template(new FLRString(sTemplate));
TOGTwo tog2Link = new TOGTwo((new FLRString(sSublink)), "link_url", "link_text");

TemplateFiller tf = new TemplateFiller();
tf.setTemplate(t);
tf.fill("name", "YOUR_NAME_HERE");
tf.fill("link", tog2Link, "http://sourceforge.net/projects/xbnjava", "way cool link");

String sResult = tf.getResult();

@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public class TemplateOrderedGaps extends Template { /**

Create a TemplateOrderedGaps.

Equal to TemplateOrderedGaps(null, flr_srcTxt, og_config)

**/ public TemplateOrderedGaps(ForLineRetrieval flr_srcTxt, OGConfig og_config) throws TemplateFormatException { this(null, flr_srcTxt, og_config); } /**

Create a TemplateOrderedGaps.

Equal to TemplateOrderedGaps(null, flr_srcTxt, og_config, tp_config)

**/ public TemplateOrderedGaps(ForLineRetrieval flr_srcTxt, OGConfig og_config, TParseConfig tp_config) throws TemplateFormatException { this(null, flr_srcTxt, og_config, tp_config); } /**

Create a TemplateOrderedGaps.

Equal to TemplateOrderedGaps(s_name, flr_srcTxt, og_config, (new TParseConfig()))

**/ public TemplateOrderedGaps(String s_name, ForLineRetrieval flr_srcTxt, OGConfig og_config) throws TemplateFormatException { this(s_name, flr_srcTxt, og_config, (new TParseConfig())); } /**

Create a TemplateOrderedGaps.

Equal to Template(s_name, flr_srcTxt, tp_config, og_config)

The only difference between this constructor and the super version, is that og_config (the TFilter) may not be null

**/ public TemplateOrderedGaps(String s_name, ForLineRetrieval flr_srcTxt, OGConfig og_config, TParseConfig tp_config) throws TemplateFormatException { super(s_name, flr_srcTxt, tp_config, og_config); throwAXIfNull(og_config, "og_config", sCNSTR); } /**

Create a full copy of the provided TemplateOrderedGaps.

Equal to Template(t_rdrdGaps)

**/ public TemplateOrderedGaps(TemplateOrderedGaps t_rdrdGaps) { super(t_rdrdGaps); } /**

Get the OGConfig for direct manipulation.

@return (OGConfig)getTFilter() **/ public final OGConfig getOGConfig() { return (OGConfig)getTFilter(); } }