AbstractProcedureMutator

public abstract class AbstractProcedureMutator extends Mutator
Known Direct Subclasses

Base class for all procedure definition and procedure call mutators, providing a base implementation of the mutation state variables and related I/O.

Inherited Constant Summary

Field Summary

protected final BlocklyController mController
protected Info extends ProcedureInfo mProcedureInfo
protected final ProcedureManager mProcedureManager

Inherited Field Summary

Protected Constructor Summary

AbstractProcedureMutator(Factory factory, BlocklyController controller)
Base constructor for subclasses.

Public Method Summary

final List<String>
final ProcedureInfo
String
abstract void
final void
serialize(XmlSerializer serializer)
Serializes the Mutator's state to an XML <mutation> element.
final void
setProcedureName(String newProcedureName)
Sets the procedure name for this mutator (and thus mBlock) when it is not on the workspace, not managed by the ProcedureManager.
void
update(XmlPullParser parser)
Updates the block using the mutation in the XML.

Protected Method Summary

abstract List<Input>
void
onAttached(Block block)
Called immediately after the mutator is attached to the block.
abstract Info
parseAndValidateMutationXml(XmlPullParser parser)
abstract void
serializeInfo(XmlSerializer serializer, Info info)
abstract void
setProcedureNameImpl(String newProcedureName)
Updates the ProcedureInfo with a new name, and updates the name field.
void
updateBlock()
Applies the mutation to mBlock.
String
writeMutationString(Info procedureInfo)
Writes an XML mutation string for the provided values.

Inherited Method Summary

Fields

protected final BlocklyController mController

protected Info extends ProcedureInfo mProcedureInfo

protected final ProcedureManager mProcedureManager

Protected Constructors

protected AbstractProcedureMutator (Factory factory, BlocklyController controller)

Base constructor for subclasses.

Parameters
factory The factory constructing this mutator.
controller The BlocklyController for this activity.

Public Methods

public final List<String> getArgumentNameList ()

Returns
  • The list of argument names.

public final ProcedureInfo getProcedureInfo ()

public String getProcedureName ()

Returns
  • The procedure name associated with this mutator. May be null if not attached to a block.

public abstract void mutate (ProcedureInfo info)

Parameters
info

public final void serialize (XmlSerializer serializer)

Serializes the Mutator's state to an XML <mutation> element. Compare with block.mutationToDom() on web Blockly (added by extensions or mixins), or Mutator.toXMLElement() on blockly-ios.

Parameters
serializer The XmlSerializer to output to.
Throws
IOException If the stream backing serializer fails.

public final void setProcedureName (String newProcedureName)

Sets the procedure name for this mutator (and thus mBlock) when it is not on the workspace, not managed by the ProcedureManager.

Parameters
newProcedureName The new name to use.

public void update (XmlPullParser parser)

Updates the block using the mutation in the XML.

Parameters
parser The parser with the <mutation> element.
Throws
IOException If the input stream fails.
XmlPullParserException If the input is not valid XML.
BlockLoadingException If the input is not a valid procedure mutation.

Protected Methods

protected abstract List<Input> buildUpdatedInputs ()

Returns
  • A new list of Inputs with which to reshape the block during mutation.

protected void onAttached (Block block)

Called immediately after the mutator is attached to the block. Can be used to perform additional block initialization related to this mutator.

Parameters
block

protected abstract Info parseAndValidateMutationXml (XmlPullParser parser)

Parameters
parser
Throws
BlockLoadingException
IOException
XmlPullParserException

protected abstract void serializeInfo (XmlSerializer serializer, Info info)

Parameters
serializer
info
Throws
IOException

protected abstract void setProcedureNameImpl (String newProcedureName)

Updates the ProcedureInfo with a new name, and updates the name field. This should never be called directly. Use setProcedureName(String) or mutate(ProcedureInfo).

Parameters
newProcedureName The updated name. Cannot be null.

protected void updateBlock ()

Applies the mutation to mBlock.

protected String writeMutationString (Info procedureInfo)

Writes an XML mutation string for the provided values.

Parameters
procedureInfo The procedure info to write.
Returns
  • Serialized XML <mutation> tag, encoding the values.