本文整理汇总了Java中com.google.gwt.typedarrays.shared.Int8Array类的典型用法代码示例。如果您正苦于以下问题:Java Int8Array类的具体用法?Java Int8Array怎么用?Java Int8Array使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Int8Array类属于com.google.gwt.typedarrays.shared包,在下文中一共展示了Int8Array类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBuffer
import com.google.gwt.typedarrays.shared.Int8Array; //导入依赖的package包/类
public ByteBuffer getBuffer () {
if (getRows() == 0)
// Issue #768 - CheckJNI frowns upon env->NewDirectByteBuffer with NULL buffer or capacity 0
// "JNI WARNING: invalid values for address (0x0) or capacity (0)"
// FreeType sets FT_Bitmap::buffer to NULL when the bitmap is empty (e.g. for ' ')
// JNICheck is on by default on emulators and might have a point anyway...
// So let's avoid this and just return a dummy non-null non-zero buffer
return BufferUtils.newByteBuffer(1);
int offset = getBufferAddress(address);
int length = getBufferSize(address);
Int8Array as = getBuffer(address, offset, length);
ArrayBuffer aBuf = as.buffer();
ByteBuffer buf = FreeTypeUtil.newDirectReadWriteByteBuffer(aBuf, length, offset);
return buf;
}
示例2: loadBinary
import com.google.gwt.typedarrays.shared.Int8Array; //导入依赖的package包/类
public void loadBinary (final String url, final AssetLoaderListener<Blob> listener) {
XMLHttpRequest request = XMLHttpRequest.create();
request.setOnReadyStateChange(new ReadyStateChangeHandler() {
@Override
public void onReadyStateChange (XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() != 200) {
listener.onFailure();
} else {
Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
listener.onSuccess(new Blob(data));
}
}
}
});
setOnProgress(request, listener);
request.open("GET", url);
request.setResponseType(ResponseType.ArrayBuffer);
request.send();
}
示例3: toByteArray
import com.google.gwt.typedarrays.shared.Int8Array; //导入依赖的package包/类
/** @param arrayBuffer will be converted to byte array.
* @return byte array with values stored in the buffer. */
protected static byte[] toByteArray(final ArrayBuffer arrayBuffer) {
final Int8Array array = Int8ArrayNative.create(arrayBuffer);
final int length = array.byteLength();
final byte[] byteArray = new byte[length];
for (int index = 0; index < length; index++) {
byteArray[index] = array.get(index);
}
return byteArray;
}
示例4: sendBinary
import com.google.gwt.typedarrays.shared.Int8Array; //导入依赖的package包/类
@Override
public void sendBinary(final byte[] message) {
final ArrayBuffer arrayBuffer = ArrayBufferNative.create(message.length);
final Int8Array array = Int8ArrayNative.create(arrayBuffer);
array.set(message);
try {
sendArrayBuffer(arrayBuffer);
} catch (final Throwable exception) {
throw new WebSocketException(exception);
}
}
示例5: send
import com.google.gwt.typedarrays.shared.Int8Array; //导入依赖的package包/类
private void send( final WebSocket webSocket, final String message, final boolean binary )
{
if ( binary )
{
final Int8Array arrayBuffer = TypedArrays.createInt8Array( message.length() );
arrayBuffer.set( message.getBytes() );
webSocket.send( arrayBuffer );
}
else
{
webSocket.send( message );
}
}
示例6: onMessage
import com.google.gwt.typedarrays.shared.Int8Array; //导入依赖的package包/类
public void onMessage( @Nonnull final WebSocket webSocket, @Nonnull final ArrayBuffer data )
{
logStatus( "Message", webSocket );
final Int8Array arrayBuffer = TypedArrays.createInt8Array( data );
final StringBuilder sb = new StringBuilder();
for ( int i = 0; i < arrayBuffer.length(); i++ )
{
sb.append( (char) arrayBuffer.get( i ) );
}
appendText( "binary message: " + sb, "black" );
}
示例7: Blob
import com.google.gwt.typedarrays.shared.Int8Array; //导入依赖的package包/类
public Blob (Int8Array data) {
this.data = data;
}
示例8: HttpClientResponse
import com.google.gwt.typedarrays.shared.Int8Array; //导入依赖的package包/类
public HttpClientResponse(int status, Int8Array response, XMLHttpRequest request) {
this.response = response;
this.status = new HttpStatus(status);
this.request = request;
}
示例9: sendHttpRequest
import com.google.gwt.typedarrays.shared.Int8Array; //导入依赖的package包/类
@Override
public void sendHttpRequest (final HttpRequest httpRequest, final HttpResponseListener httpResultListener) {
if (httpRequest.getUrl() == null) {
httpResultListener.failed(new GdxRuntimeException("can't process a HTTP request without URL set"));
return;
}
final String method = httpRequest.getMethod();
final String value = httpRequest.getContent();
final boolean valueInBody = method.equalsIgnoreCase(HttpMethods.POST) || method.equals(HttpMethods.PUT);
String url = httpRequest.getUrl();
if (method.equalsIgnoreCase(HttpMethods.GET)) {
if (value != null) {
url += "?" + value;
}
} else if (method.equalsIgnoreCase(HttpMethods.POST)) {
} else if (method.equalsIgnoreCase(HttpMethods.DELETE)) {
if (value != null) {
url += "?" + value;
}
} else if (method.equalsIgnoreCase(HttpMethods.PUT)) {
} else {
throw new GdxRuntimeException("Unsupported HTTP Method");
}
XMLHttpRequest request = XMLHttpRequest.create();
request.setOnReadyStateChange(new ReadyStateChangeHandler() {
@Override
public void onReadyStateChange(XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() != 200) {
httpResultListener.failed(new Throwable(xhr.getStatusText()));
requests.remove(httpRequest);
listeners.remove(httpRequest);
} else {
Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
httpResultListener.handleHttpResponse(new HttpClientResponse(xhr.getStatus(), data, xhr));
requests.remove(httpRequest);
listeners.remove(httpRequest);
}
}
}
});
request.open(method, url);
Map<String, String> content = httpRequest.getHeaders();
Set<String> keySet = content.keySet();
for (String name : keySet) {
request.setRequestHeader(name, content.get(name));
}
request.setResponseType(XMLHttpRequest.ResponseType.ArrayBuffer);
if (valueInBody)
request.send(value);
else
request.send();
requests.put(httpRequest, request);
listeners.put(httpRequest, httpResultListener);
}