public class Binary
extends org.mozilla.javascript.ScriptableObject
implements org.mozilla.javascript.Wrapper
A wrapper around a Java byte array compliant to the Binary/ByteArray/ByteString
classes defined in the Binary/B proposal.
To register Binary, ByteArray and ByteString as a host objects in Rhino call the
defineClass() function with this class as argument.
defineClass(org.ringojs.wrappers.Binary);
The JavaScript Binary class serves as common base class for ByteArray and ByteString
and can't be instantiated. ByteArray implements a modifiable and resizable byte buffer,
while ByteString implements an immutable byte sequence. The ByteArray and ByteString
constructors can take several arguments. Have a look at the proposal for details.
When passed to a Java method that expects a byte array, instances of thes class
are automatically unwrapped.| Constructor and Description |
|---|
Binary() |
Binary(org.ringojs.wrappers.Binary.Type type) |
Binary(org.mozilla.javascript.Scriptable scope,
org.ringojs.wrappers.Binary.Type type,
byte[] bytes) |
Binary(org.mozilla.javascript.Scriptable scope,
org.ringojs.wrappers.Binary.Type type,
byte[] bytes,
int offset,
int length) |
Binary(org.mozilla.javascript.Scriptable scope,
org.ringojs.wrappers.Binary.Type type,
int length) |
| Modifier and Type | Method and Description |
|---|---|
Object |
byteAt(Object index) |
Object |
charAt(Object index) |
Object |
charCodeAt(Object index) |
static Object |
concat(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
Object[] args,
org.mozilla.javascript.Function func) |
static Object |
construct(org.mozilla.javascript.Context cx,
Object[] args,
org.mozilla.javascript.Function ctorObj,
boolean inNewExpr) |
void |
copy(int srcStartIndex,
int srcEndIndex,
Binary target,
Object targetIndex) |
String |
decodeToString(Object charset) |
protected void |
ensureLength(int minLength) |
static void |
finishInit(org.mozilla.javascript.Scriptable scope,
org.mozilla.javascript.FunctionObject ctor,
org.mozilla.javascript.Scriptable prototype) |
Object |
get(int index,
org.mozilla.javascript.Scriptable start) |
Object |
get(Object index) |
byte[] |
getBytes() |
String |
getClassName() |
int |
getLength() |
org.ringojs.wrappers.Binary.Type |
getType() |
boolean |
has(int index,
org.mozilla.javascript.Scriptable start) |
int |
indexOf(Object arg,
Object from,
Object to) |
Object |
jsunwrap() |
int |
lastIndexOf(Object arg,
Object from,
Object to) |
void |
put(int index,
org.mozilla.javascript.Scriptable start,
Object value) |
void |
set(Object index,
int value) |
protected void |
setLength(int newLength) |
void |
setLength(Object length) |
Object |
slice(Object begin,
Object end) |
Object |
split(Object delim,
Object options) |
Object |
toArray(Object charset) |
Object |
toByteArray(Object sourceCharset,
Object targetCharset) |
Object |
toByteString(Object sourceCharset,
Object targetCharset) |
String |
toString() |
Object |
unwrap()
Unwrap the object by returning the wrapped value.
|
protected static Binary |
wrap(org.ringojs.wrappers.Binary.Type type,
byte[] bytes,
org.mozilla.javascript.Scriptable scope,
org.mozilla.javascript.Scriptable prototype) |
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, equivalentValues, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizepublic Binary()
public Binary(org.ringojs.wrappers.Binary.Type type)
public Binary(org.mozilla.javascript.Scriptable scope,
org.ringojs.wrappers.Binary.Type type,
int length)
public Binary(org.mozilla.javascript.Scriptable scope,
org.ringojs.wrappers.Binary.Type type,
byte[] bytes)
public Binary(org.mozilla.javascript.Scriptable scope,
org.ringojs.wrappers.Binary.Type type,
byte[] bytes,
int offset,
int length)
@JSConstructor public static Object construct(org.mozilla.javascript.Context cx, Object[] args, org.mozilla.javascript.Function ctorObj, boolean inNewExpr)
public static void finishInit(org.mozilla.javascript.Scriptable scope,
org.mozilla.javascript.FunctionObject ctor,
org.mozilla.javascript.Scriptable prototype)
throws NoSuchMethodException
NoSuchMethodExceptionpublic org.ringojs.wrappers.Binary.Type getType()
public Object get(int index, org.mozilla.javascript.Scriptable start)
get in interface org.mozilla.javascript.Scriptableget in class org.mozilla.javascript.ScriptableObjectpublic boolean has(int index,
org.mozilla.javascript.Scriptable start)
has in interface org.mozilla.javascript.Scriptablehas in class org.mozilla.javascript.ScriptableObjectpublic void put(int index,
org.mozilla.javascript.Scriptable start,
Object value)
put in interface org.mozilla.javascript.Scriptableput in class org.mozilla.javascript.ScriptableObject@JSGetter public int getLength()
@JSSetter public void setLength(Object length)
protected void setLength(int newLength)
@JSFunction public Object get(Object index)
get in class org.mozilla.javascript.ScriptableObject@JSFunction public void set(Object index, int value)
@JSFunction public Object toByteArray(Object sourceCharset, Object targetCharset) throws UnsupportedEncodingException
UnsupportedEncodingException@JSFunction public Object toByteString(Object sourceCharset, Object targetCharset) throws UnsupportedEncodingException
UnsupportedEncodingException@JSFunction
public void copy(int srcStartIndex,
int srcEndIndex,
Binary target,
Object targetIndex)
@JSFunction public Object toArray(Object charset) throws UnsupportedEncodingException
UnsupportedEncodingException@JSFunction public static Object concat(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function func)
protected static Binary wrap(org.ringojs.wrappers.Binary.Type type, byte[] bytes, org.mozilla.javascript.Scriptable scope, org.mozilla.javascript.Scriptable prototype)
@JSFunction(value="unwrap") public Object jsunwrap()
public Object unwrap()
unwrap in interface org.mozilla.javascript.Wrapperpublic byte[] getBytes()
public String getClassName()
getClassName in interface org.mozilla.javascript.ScriptablegetClassName in class org.mozilla.javascript.ScriptableObjectprotected void ensureLength(int minLength)
Copyright © 2016. All rights reserved.