ProcedureDefinitionMutator

public class ProcedureDefinitionMutator extends AbstractProcedureMutator<ProcedureInfo>

This mutator class supports procedure definition blocks for user-defined procedures (procedures_defreturn and procedures_defnoreturn blocks).

Constant Summary

String DEFNORETURN_MUTATOR_ID
String DEFRETURN_MUTATOR_ID
String NAME_FIELD_NAME
String RETURN_INPUT_NAME
String STATEMENT_INPUT_NAME

Inherited Constant Summary

Field Summary

public static final Factory<ProcedureDefinitionMutator> DEFNORETURN_FACTORY
public static final Factory<ProcedureDefinitionMutator> DEFRETURN_FACTORY

Inherited Field Summary

Public Method Summary

final boolean
void
mutate(ProcedureInfo newProcedureInfo)
Convenience method for invoking a mutation event programmatically, updating the Mutator with the provided values.
ProcedureInfo
parseAndValidateMutationXml(XmlPullParser parser)
Parses the provided XML into a ProcedureInfo that can parameterize this procedure.
void
serializeInfo(XmlSerializer serializer, ProcedureInfo info)
This outputs the mutation via the serializer.

Protected Method Summary

List<Input>
Input
String
Input
newDefinitionHeader()
Constructs the block's header Input.
void
onAttached(Block block)
Called when the mutator is attached to a block.
void
onDetached(Block block)
Unregisters the field listener when the mutator is detached from the block.
void
setProcedureNameImpl(String newName)
Sets the mutator name, including setting the associated name field on the block.
void
updateBlock()
Updates mBlock in response to a mutation, including updating the name field.

Inherited Method Summary

Constants

public static final String DEFNORETURN_MUTATOR_ID

Constant Value: "procedures_defnoreturn_mutator"

public static final String DEFRETURN_MUTATOR_ID

Constant Value: "procedures_defreturn_mutator"

public static final String NAME_FIELD_NAME

Constant Value: "name"

public static final String RETURN_INPUT_NAME

Constant Value: "RETURN"

public static final String STATEMENT_INPUT_NAME

Constant Value: "STACK"

Fields

public static final Factory<ProcedureDefinitionMutator> DEFNORETURN_FACTORY

public static final Factory<ProcedureDefinitionMutator> DEFRETURN_FACTORY

Public Methods

public final boolean hasStatementInput ()

Returns
  • Whether the function is allow to have an input.

public void mutate (ProcedureInfo newProcedureInfo)

Convenience method for invoking a mutation event programmatically, updating the Mutator with the provided values.

Parameters
newProcedureInfo The new values that define this procedure.

public ProcedureInfo parseAndValidateMutationXml (XmlPullParser parser)

Parses the provided XML into a ProcedureInfo that can parameterize this procedure.

Parameters
parser The XML parser containing the <mutation> tag.
Returns
  • A new procedure info object.
Throws
IOException If the stream backing the XML parser has a failure.
XmlPullParserException If the stream is not valid XML.
BlockLoadingException If the XML does not contain a proper procedure mutation.

public void serializeInfo (XmlSerializer serializer, ProcedureInfo info)

This outputs the mutation via the serializer.

Parameters
serializer The XML serializer
info The procedure info to serialize.
Throws
IOException If the backing output stream encounters an issue.

Protected Methods

protected List<Input> buildUpdatedInputs ()

Returns
  • A list of Inputs for a block mutation.

protected Input getDefintionStatementsInput ()

Returns
  • An Input to contain the procedure body statements.

protected String getParametersListDescription ()

Returns
  • A human-readable string describing the procedure's parameters.

protected Input newDefinitionHeader ()

Constructs the block's header Input. The new header maintains the same name field instance, but updated PARAMS argument list.

Returns
  • Return a new header Input reflecting the latest mutator state.

protected void onAttached (Block block)

Called when the mutator is attached to a block. It will make sure the procedure name on the block's name field is in sync with the mutator's PRocedureInfo, and register a listener on the name field for future edits.

Parameters
block The block the mutator is attached to.

protected void onDetached (Block block)

Unregisters the field listener when the mutator is detached from the block.

Parameters
block The block the mutator was formerly attached to.

protected void setProcedureNameImpl (String newName)

Sets the mutator name, including setting the associated name field on the block.

protected void updateBlock ()

Updates mBlock in response to a mutation, including updating the name field.