public class HelperBase
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
HelperBase.DATA_TYPE
Support data types for reading and writing to buffers.
|
Modifier and Type | Field and Description |
---|---|
protected JavaScript |
_actor
The JavaScript actor that this is helping.
|
protected jdk.nashorn.api.scripting.ScriptObjectMirror |
_currentObj
The JavaScript object that this is a helper for.
|
Constructor and Description |
---|
HelperBase(java.lang.Object actor,
jdk.nashorn.api.scripting.ScriptObjectMirror helping)
Construct a helper for the specified actor and JavaScript object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_appendNumericToBuffer(io.vertx.core.buffer.Buffer buffer,
java.lang.Object data,
HelperBase.DATA_TYPE type)
Append a numeric instance of the specified type to a buffer.
|
protected void |
_appendToBuffer(java.lang.Object data,
HelperBase.DATA_TYPE type,
java.lang.String imageType,
io.vertx.core.buffer.Buffer buffer)
Append data to be sent to the specified buffer.
|
protected void |
_error(jdk.nashorn.api.scripting.ScriptObjectMirror emitter,
java.lang.String message)
Emit the error message in the director thread by emitting
an "error" event on the specified JavaScript object.
|
protected void |
_error(jdk.nashorn.api.scripting.ScriptObjectMirror emitter,
java.lang.String message,
java.lang.Throwable throwable)
Emit the error message in the director thread by emitting
an "error" event on the specified JavaScript object.
|
protected void |
_error(java.lang.String message)
Handle an error by emitting an error event, or if there is no
error event handler registered, by invoking the error() method
of the associated actor.
|
protected void |
_error(java.lang.String message,
java.lang.Throwable throwable)
Handle an error by emitting an error event, or if there is no
error event handler registered, by invoking the error() method
of the associated actor.
|
protected java.lang.Object |
_extractFromBuffer(io.vertx.core.buffer.Buffer buffer,
HelperBase.DATA_TYPE type,
int position)
Extract a numeric instance of the specified type from a buffer.
|
protected void |
_issueResponse(java.lang.Runnable response)
Execute the specified response in the director thread.
|
protected static java.util.TreeSet<java.lang.String> |
_removeDuplicates(java.lang.String[] original)
Given an array of strings, return an array where everything is
converted to lower case, duplicates are removed, and the order
is alphabetical.
|
protected int |
_sizeOfType(HelperBase.DATA_TYPE type)
Return the size of a data type.
|
protected static byte[] |
_toJavaBytes(java.lang.Object object)
Convert the native JavaScript array or JavaScript string into a Java byte array.
|
protected java.lang.Object |
_toJSArray(byte[] buffer)
Convert a Java byte array into the JavaScript integer array.
|
jdk.nashorn.api.scripting.ScriptObjectMirror |
getHelping()
Return the JavaScript object that this helper is helping.
|
protected JavaScript _actor
protected jdk.nashorn.api.scripting.ScriptObjectMirror _currentObj
public HelperBase(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror helping)
actor
- The actor associated with this helper.helping
- The object that this is helping.public jdk.nashorn.api.scripting.ScriptObjectMirror getHelping()
protected void _error(java.lang.String message)
message
- The error message.protected void _error(java.lang.String message, java.lang.Throwable throwable)
message
- The error message.throwable
- The throwable.protected void _error(jdk.nashorn.api.scripting.ScriptObjectMirror emitter, java.lang.String message)
emitter
- The JavaScript object that should emit an "error" event.message
- The error message.protected void _error(jdk.nashorn.api.scripting.ScriptObjectMirror emitter, java.lang.String message, java.lang.Throwable throwable)
emitter
- The JavaScript object that should emit an "error" event.message
- The error message.throwable
- The exception that caused the error.protected void _appendNumericToBuffer(io.vertx.core.buffer.Buffer buffer, java.lang.Object data, HelperBase.DATA_TYPE type)
buffer
- The buffer to which to appenddata
- The data to be appendedtype
- The type of data.protected void _appendToBuffer(java.lang.Object data, HelperBase.DATA_TYPE type, java.lang.String imageType, io.vertx.core.buffer.Buffer buffer)
data
- The data to append.type
- The type of data append.imageType
- If the type is IMAGE, then then the image encoding to use, or
null to use the default (JPG).buffer
- The buffer.protected java.lang.Object _extractFromBuffer(io.vertx.core.buffer.Buffer buffer, HelperBase.DATA_TYPE type, int position)
buffer
- The buffer containing the data.type
- The type to extract.position
- The position in the buffer from which to extract it.protected void _issueResponse(java.lang.Runnable response)
response
- The response to execute.protected static java.util.TreeSet<java.lang.String> _removeDuplicates(java.lang.String[] original)
original
- The array of stringsprotected int _sizeOfType(HelperBase.DATA_TYPE type)
type
- The objectprotected java.lang.Object _toJSArray(byte[] buffer) throws IllegalActionException
buffer
- The input Java byte array to be converted.IllegalActionException
- If the conversion fails.protected static byte[] _toJavaBytes(java.lang.Object object) throws IllegalActionException
object
- The input in JavaScript object, either a JavaScrypt integer array or
a JavaScript string. If the string starts with "0x", it is interpreted as hex bytes.IllegalActionException
- If the conversion fails.