UniversalTag.INTEGER.getValue(),
new GrammarAction<PagedResultsContainer>( "Set PagedSearchControl size" )
{
public void action( PagedResultsContainer container ) throws DecoderException
{
Value value = container.getCurrentTLV().getValue();
try
{
// Check that the value is into the allowed interval
int size = IntegerDecoder.parse( value, Integer.MIN_VALUE, Integer.MAX_VALUE );
// We allow negative value to absorb a bug in some M$ client.
// Those negative values will be transformed to Integer.MAX_VALUE.
if ( size < 0 )
{
size = Integer.MAX_VALUE;
}
if ( IS_DEBUG )
{
LOG.debug( "size = " + size );
}
container.getDecorator().setSize( size );
}
catch ( IntegerDecoderException e )
{
String msg = I18n.err( I18n.ERR_04050 );
LOG.error( msg, e );
throw new DecoderException( msg );
}
}
} );
/**
* Transition from size to cookie
* realSearchControlValue ::= SEQUENCE OF {
* ...
* cookie OCTET STRING
* }
*
* Stores the cookie flag
*/
super.transitions[PagedResultsStates.SIZE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
new GrammarTransition<PagedResultsContainer>( PagedResultsStates.SIZE_STATE,
PagedResultsStates.COOKIE_STATE, UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<PagedResultsContainer>( "Set PagedSearchControl cookie" )
{
public void action( PagedResultsContainer container ) throws DecoderException
{
Value value = container.getCurrentTLV().getValue();
if ( container.getCurrentTLV().getLength() == 0 )
{
container.getDecorator().setCookie( StringConstants.EMPTY_BYTES );
}
else
{
container.getDecorator().setCookie( value.getData() );
}
// We can have an END transition
container.setGrammarEndAllowed( true );
}