Command class
class Command extends Packet { final String command; Map<String, dynamic> _parameters = new Map(); List<String> _options = new List(); final Completer<Answer> _answer = new Completer(); Future get answer => _answer.future; Command(String this.command, {Map<String, dynamic> parameters: null, List<String> options: null}){ if(parameters != null){ _parameters = parameters; } if(options != null){ _options = options; } } void gotAnswer(Answer pA){ _answer.complete(pA); } void gotAnswerError(Map<String, dynamic> pE){ _answer.completeError(pE); } String toString(){ final StringBuffer lResult = new StringBuffer(command); _parameters.forEach((String pKey, dynamic pValue){ if(pValue is String || pValue is num || pValue is bool){ lResult ..write(" ") ..write(Packet.escape(pKey)) ..write("=") ..write(Packet.escape(pValue.toString())); } else if(pValue is List){ final String lKey = Packet.escape(pKey); lResult.write(pValue.map((dynamic pItem){ return "${lKey}=${Packet.escape(pItem.toString())}"; }).join("|")); } }); _options.forEach((String pOption){ lResult ..write(" -") ..write(Packet.escape(pOption)); }); return lResult.toString(); } }
Extends
Packet > Command
Constructors
Properties
Methods
void gotAnswerError(Map<String, dynamic> pE) #
void gotAnswerError(Map<String, dynamic> pE){ _answer.completeError(pE); }
String toString() #
Returns a string representation of this object.
docs inherited from Object
String toString(){ final StringBuffer lResult = new StringBuffer(command); _parameters.forEach((String pKey, dynamic pValue){ if(pValue is String || pValue is num || pValue is bool){ lResult ..write(" ") ..write(Packet.escape(pKey)) ..write("=") ..write(Packet.escape(pValue.toString())); } else if(pValue is List){ final String lKey = Packet.escape(pKey); lResult.write(pValue.map((dynamic pItem){ return "${lKey}=${Packet.escape(pItem.toString())}"; }).join("|")); } }); _options.forEach((String pOption){ lResult ..write(" -") ..write(Packet.escape(pOption)); }); return lResult.toString(); }