public NamingEnumeration enumerate( final ExprNode node )
throws NamingException
{
RE regex = null;
Index idx = null;
final SubstringNode snode = ( SubstringNode ) node;
AttributeType type = attributeTypeRegistry.lookup( snode.getAttribute() );
Normalizer normalizer = type.getSubstr().getNormalizer();
if ( db.hasUserIndexOn( snode.getAttribute() ) )
{
/*
* Build out regex in this block so we do not do it twice in the
* evaluator if there is no index on the attribute of the substr ava
*/
try
{
regex = snode.getRegex( normalizer );
}
catch ( RESyntaxException e )
{
NamingException ne = new NamingException( "SubstringNode '"
+ node + "' had incorrect syntax" );
ne.setRootCause( e );
throw ne;
}
/*
* Get the user index and return an index enumeration using the the
* compiled regular expression. Try to constrain even further if
* an initial term is available in the substring expression.
*/
idx = db.getUserIndex( snode.getAttribute() );
if ( null == snode.getInitial() )
{
return idx.listIndices( regex );
}
else
{
return idx.listIndices( regex, snode.getInitial() );
}
}
/*
* From this point on we are dealing with an enumeration over entries