SearchRequestDecorator searchRequestDecorator = container.getMessage();
TLV tlv = container.getCurrentTLV();
// Store the value.
SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();
if ( tlv.getLength() == 0 )
{
String msg = I18n.err( I18n.ERR_04106 );
LOG.error( msg );
throw new DecoderException( msg );
}
else
{
String type = getType(tlv.getValue().getData());
substringFilter.setType( type );
// We now have to get back to the nearest filter which
// is not terminal.
searchRequestDecorator.setTerminalFilter( substringFilter );
}
}
} );
// --------------------------------------------------------------------------------------------
// Transition from typeSubstring to substrings
// --------------------------------------------------------------------------------------------
// Filter ::= CHOICE {
// ...
// substrings [4] SubstringFilter,
// ...
//
// SubstringFilter ::= SEQUENCE {
// ...
// substrings SEQUENCE OF CHOICE {
// ...
//
// Init substring type
super.transitions[LdapStatesEnum.TYPE_SUBSTRING_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
LdapStatesEnum.TYPE_SUBSTRING_STATE, LdapStatesEnum.SUBSTRINGS_STATE, UniversalTag.SEQUENCE.getValue(),
new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Substring Filter substringsSequence " )
{
public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
{
TLV tlv = container.getCurrentTLV();
if ( tlv.getLength() == 0 )
{
LOG.error( I18n.err( I18n.ERR_04107 ) );
throw new DecoderException( "The substring sequence is empty" );
}
}
} );
// --------------------------------------------------------------------------------------------
// Transition from substrings to Initial
// --------------------------------------------------------------------------------------------
// SubstringFilter ::= SEQUENCE {
// ...
// substrings SEQUENCE OF CHOICE {
// initial [0] LDAPSTRING,
// ...
//
// Store initial value
super.transitions[LdapStatesEnum.SUBSTRINGS_STATE.ordinal()][LdapConstants.SUBSTRINGS_FILTER_INITIAL_TAG] = new GrammarTransition(
LdapStatesEnum.SUBSTRINGS_STATE, LdapStatesEnum.INITIAL_STATE, LdapConstants.SUBSTRINGS_FILTER_INITIAL_TAG,
new GrammarAction<LdapMessageContainer<SearchRequestDecorator>>( "Store substring filter initial Value" )
{
public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
{
SearchRequestDecorator searchRequestDecorator = container.getMessage();
TLV tlv = container.getCurrentTLV();
// Store the value.
SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();
if ( tlv.getLength() == 0 )
{
String msg = I18n.err( I18n.ERR_04108 );
LOG.error( msg );
throw new DecoderException( msg );
}
substringFilter.setInitialSubstrings( Strings.utf8ToString(tlv.getValue().getData()) );
// We now have to get back to the nearest filter which is
// not terminal.
searchRequestDecorator.unstackFilters( container );
}