Package org.microproxy.starlark
Class ScriptUdpMessage
java.lang.Object
org.microproxy.starlark.ScriptUdpMessage
- All Implemented Interfaces:
org.microproxy.thirdparty.starlark.eval.StarlarkValue,org.microproxy.thirdparty.starlark.eval.Structure
public final class ScriptUdpMessage
extends Object
implements org.microproxy.thirdparty.starlark.eval.Structure
One datagram of a UDP flow (CONNECT-UDP), as
on_udp_message sees it: data,
text (None when the payload is not valid UTF-8), from_client and
timestamp (seconds since the epoch). Assign data or text to change what is
sent on, or make a changed copy with with_data and with_text and return it. UDP
keeps message boundaries: a message is one datagram.-
Method Summary
Modifier and TypeMethodDescriptionstatic org.microproxy.thirdparty.starlark.syntax.TypeConstructorTypes the builtins that return this class (seeScriptType).Returns the error message to print for an attempt to access an undefined field.com.google.common.collect.ImmutableList<String> Returns the names of this value's fields, in some undefined but stable order.org.microproxy.thirdparty.starlark.syntax.StarlarkTypegetStarlarkType(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics) Returns the Starlark type of this struct.Returns the value of the field with the given name, or null if the field does not exist.voidrepr(org.microproxy.thirdparty.starlark.eval.Printer printer, org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics) Prints an official representation of object x.voidUpdates the named field of this value as if by the Starlark statementthis.field = value.A copy of this message with another payload.A copy of this message with the UTF-8 encoding oftext.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.microproxy.thirdparty.starlark.eval.StarlarkValue
checkHashable, debugPrint, isAcyclic, isImmutable, str, truthMethods inherited from interface org.microproxy.thirdparty.starlark.eval.Structure
getValue
-
Method Details
-
getAssociatedTypeConstructor
public static org.microproxy.thirdparty.starlark.syntax.TypeConstructor getAssociatedTypeConstructor()Types the builtins that return this class (seeScriptType).- Returns:
- the Starlark type constructor for a UDP message value
-
getStarlarkType
public org.microproxy.thirdparty.starlark.syntax.StarlarkType getStarlarkType(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics) Description copied from interface:org.microproxy.thirdparty.starlark.eval.StructureReturns the Starlark type of this struct. For efficiency, implementations should override this method to return a memoized value.- Specified by:
getStarlarkTypein interfaceorg.microproxy.thirdparty.starlark.eval.StarlarkValue- Specified by:
getStarlarkTypein interfaceorg.microproxy.thirdparty.starlark.eval.Structure- Parameters:
semantics- the interpreter settings used to determine the type- Returns:
- the type of this value, or null when no type information is provided
-
getValue
Description copied from interface:org.microproxy.thirdparty.starlark.eval.StructureReturns the value of the field with the given name, or null if the field does not exist. The interpreter (Starlark code) calls the getValue below, which has access to StarlarkSemantics.The set of names for which
getValuereturns non-null should matchgetFieldNamesif possible.- Specified by:
getValuein interfaceorg.microproxy.thirdparty.starlark.eval.Structure- Parameters:
name- the name of the field to retrieve- Returns:
- the field value, or null if the field does not exist
-
getFieldNames
Description copied from interface:org.microproxy.thirdparty.starlark.eval.StructureReturns the names of this value's fields, in some undefined but stable order.A call to
getValuefor each of these names should return non-null, though this is not enforced.The Starlark expression
dir(x)reports the union ofgetFieldNames()and any StarlarkMethod-annotated fields and methods of this value.- Specified by:
getFieldNamesin interfaceorg.microproxy.thirdparty.starlark.eval.Structure- Returns:
- the field names in a stable order
-
setField
public void setField(String field, Object value) throws org.microproxy.thirdparty.starlark.eval.EvalException Description copied from interface:org.microproxy.thirdparty.starlark.eval.StructureUpdates the named field of this value as if by the Starlark statementthis.field = value.- Specified by:
setFieldin interfaceorg.microproxy.thirdparty.starlark.eval.Structure- Parameters:
field- the name of the field to updatevalue- the new Starlark value for the field- Throws:
org.microproxy.thirdparty.starlark.eval.EvalException- if the update failed because this value is immutable, does not support field update, or update of that particular field, or because the value was inappropriate.
-
withData
public ScriptUdpMessage withData(Object data) throws org.microproxy.thirdparty.starlark.eval.EvalException A copy of this message with another payload.- Parameters:
data- the payload of the copy, as bytes or a string (UTF-8)- Returns:
- the copy, with the same direction and timestamp
- Throws:
org.microproxy.thirdparty.starlark.eval.EvalException- ifdatais neither bytes nor a string
-
withText
A copy of this message with the UTF-8 encoding oftext.- Parameters:
text- the text of the copy- Returns:
- the copy, with the same direction and timestamp
-
getErrorMessageForUnknownField
Description copied from interface:org.microproxy.thirdparty.starlark.eval.StructureReturns the error message to print for an attempt to access an undefined field.May return null to use a default error message.
- Specified by:
getErrorMessageForUnknownFieldin interfaceorg.microproxy.thirdparty.starlark.eval.Structure- Parameters:
field- the undefined field name- Returns:
- the diagnostic message, or null to use the default
-
repr
public void repr(org.microproxy.thirdparty.starlark.eval.Printer printer, org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics) Description copied from interface:org.microproxy.thirdparty.starlark.eval.StarlarkValuePrints an official representation of object x.Convention is that the string should be parseable back to the value x. If this isn't feasible then it should be a short human-readable description enclosed in angled brackets, e.g.
"<foo object>".- Specified by:
reprin interfaceorg.microproxy.thirdparty.starlark.eval.StarlarkValue- Parameters:
printer- a printer to be used for formatting nested values.semantics- the interpreter settings used to format nested values
-