// Creates the storeProcedure and stores the language
super.transitions[StoredProcedureStatesEnum.STORED_PROCEDURE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
new GrammarTransition( StoredProcedureStatesEnum.STORED_PROCEDURE_STATE,
StoredProcedureStatesEnum.LANGUAGE_STATE,
UniversalTag.OCTET_STRING.getValue(),
new GrammarAction( "Stores the language" )
{
public void action( Asn1Container container ) throws DecoderException
{
StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;
TLV tlv = storedProcedureContainer.getCurrentTLV();
StoredProcedure storedProcedure = null;
// Store the value.
if ( tlv.getLength() == 0 )
{
// We can't have a void language !
String msg = I18n.err( I18n.ERR_04038 );
LOG.error( msg );
throw new DecoderException( msg );
}
else
{
// Only this field's type is String by default
String language = Strings.utf8ToString(tlv.getValue().getData());
if ( LOG.isDebugEnabled() )
{
LOG.debug( "SP language found: " + language );
}
storedProcedure = new StoredProcedure();
storedProcedure.setLanguage( language );
storedProcedureContainer.setStoredProcedure( storedProcedure );
}
}
} );
// procedure OCTETSTRING, (Value)
// ...
// Stores the procedure.
super.transitions[StoredProcedureStatesEnum.LANGUAGE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
new GrammarTransition( StoredProcedureStatesEnum.LANGUAGE_STATE,
StoredProcedureStatesEnum.PROCEDURE_STATE,
UniversalTag.OCTET_STRING.getValue(),
new GrammarAction(
"Stores the procedure" )
{
public void action( Asn1Container container ) throws DecoderException
{
StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;
TLV tlv = storedProcedureContainer.getCurrentTLV();
StoredProcedure storedProcedure = storedProcedureContainer.getStoredProcedure();
// Store the value.
if ( tlv.getLength() == 0 )
{
// We can't have a void procedure !
String msg = I18n.err( I18n.ERR_04039 );
LOG.error( msg );
throw new DecoderException( msg );
}
else
{
byte[] procedure = tlv.getValue().getData();
storedProcedure.setProcedure( procedure );
}
if ( LOG.isDebugEnabled() )
{
LOG.debug( "Procedure found : " + Strings.utf8ToString(storedProcedure.getProcedure()) );
}
}
} );
// parameters SEQUENCE OF Parameter { (Value)
// ...
// The list of parameters will be created with the first parameter.
// We can have an empty list of parameters, so the PDU can be empty
super.transitions[StoredProcedureStatesEnum.PROCEDURE_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
new GrammarTransition( StoredProcedureStatesEnum.PROCEDURE_STATE,
StoredProcedureStatesEnum.PARAMETERS_STATE,
UniversalTag.SEQUENCE.getValue(),
new GrammarAction(
"Stores the parameters" )
{
public void action( Asn1Container container ) throws DecoderException
{
StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;
storedProcedureContainer.setGrammarEndAllowed( true );
}
} );
// parameter SEQUENCE OF { (Value)
// ...
// Nothing to do.
super.transitions[StoredProcedureStatesEnum.PARAMETERS_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
new GrammarTransition( StoredProcedureStatesEnum.PARAMETERS_STATE,
StoredProcedureStatesEnum.PARAMETER_STATE,
UniversalTag.SEQUENCE.getValue(),
null );
// Parameter ::= {
// type OCTETSTRING, (Value)
// ...
//
// We can create a parameter, and store its type
super.transitions[StoredProcedureStatesEnum.PARAMETER_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
new GrammarTransition( StoredProcedureStatesEnum.PARAMETER_STATE,
StoredProcedureStatesEnum.PARAMETER_TYPE_STATE,
UniversalTag.OCTET_STRING.getValue(),
new GrammarAction( "Store parameter type" )
{
public void action( Asn1Container container ) throws DecoderException
{
StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;
TLV tlv = storedProcedureContainer.getCurrentTLV();
StoredProcedure storedProcedure = storedProcedureContainer.getStoredProcedure();
// Store the value.
if ( tlv.getLength() == 0 )
{
// We can't have a void parameter type !
String msg = I18n.err( I18n.ERR_04040 );
LOG.error( msg );
throw new DecoderException( msg );
}
else
{
StoredProcedureParameter parameter = new StoredProcedureParameter();
byte[] parameterType = tlv.getValue().getData();
parameter.setType( parameterType );
// We store the type in the current parameter.
storedProcedure.setCurrentParameter( parameter );
if ( LOG.isDebugEnabled() )
{
LOG.debug( "Parameter type found : " + Strings.dumpBytes(parameterType) );
}
}
}
} );
// Parameter ::= {
// ...
// value OCTETSTRING (Tag)
// }
// Store the parameter value
super.transitions[StoredProcedureStatesEnum.PARAMETER_TYPE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
new GrammarTransition( StoredProcedureStatesEnum.PARAMETER_TYPE_STATE,
StoredProcedureStatesEnum.PARAMETER_VALUE_STATE,
UniversalTag.OCTET_STRING.getValue(),
new GrammarAction( "Store parameter value" )
{
public void action( Asn1Container container ) throws DecoderException
{
StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;