*/
public void init(RuntimeServices rs, InternalContextAdapter context, Node node)
throws TemplateInitException
{
super.init(rs, context, node);
RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();
// handle deprecated config settings
counterName = rsvc.getString(RuntimeConstants.COUNTER_NAME);
hasNextName = rsvc.getString(RuntimeConstants.HAS_NEXT_NAME);
counterInitialValue = rsvc.getInt(RuntimeConstants.COUNTER_INITIAL_VALUE);
// only warn once per instance...
if (!warned && Logger.isWarnEnabled(this.getClass()))
{
warned = true;
// ...and only if they customize these settings
if (!"velocityCount".equals(counterName))
{
Logger.warn(this,"The "+RuntimeConstants.COUNTER_NAME+
" property has been deprecated. It will be removed"+
" (along with $velocityCount itself) in Velocity 2.0. "+
" Instead, please use $foreach.count to access"+
" the loop counter.");
}
if (!"velocityHasNext".equals(hasNextName))
{
Logger.warn(this,"The "+RuntimeConstants.HAS_NEXT_NAME+
" property has been deprecated. It will be removed"+
" (along with $velocityHasNext itself ) in Velocity 2.0. "+
" Instead, please use $foreach.hasNext to access"+
" this value from now on.");
}
if (counterInitialValue != 1)
{
Logger.warn(this,"The "+RuntimeConstants.COUNTER_INITIAL_VALUE+
" property has been deprecated. It will be removed"+
" (along with $velocityCount itself) in Velocity 2.0. "+
" Instead, please use $foreach.index to access"+
" the 0-based loop index and $foreach.count"+
" to access the 1-based loop counter.");
}
}
maxNbrLoops = rsvc.getInt(RuntimeConstants.MAX_NUMBER_LOOPS,
Integer.MAX_VALUE);
if (maxNbrLoops < 1)
{
maxNbrLoops = Integer.MAX_VALUE;
}
skipInvalidIterator =
rsvc.getBoolean(RuntimeConstants.SKIP_INVALID_ITERATOR, true);
if (rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false))
{
// If we are in strict mode then the default for skipInvalidItarator
// is true. However, if the property is explicitly set, then honor the setting.
skipInvalidIterator = rsvc.getBoolean(RuntimeConstants.SKIP_INVALID_ITERATOR, false);
}
/*
* this is really the only thing we can do here as everything
* else is context sensitive