• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TypedArrays类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.gwt.typedarrays.shared.TypedArrays的典型用法代码示例。如果您正苦于以下问题:Java TypedArrays类的具体用法?Java TypedArrays怎么用?Java TypedArrays使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TypedArrays类属于com.google.gwt.typedarrays.shared包,在下文中一共展示了TypedArrays类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: putMethod

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public Promise<HTTPResponse> putMethod(String url, byte[] contents) {
    return new Promise<>(resolver -> {
        JsHttpRequest request = JsHttpRequest.create();
        request.open("PUT", url);
        request.setRequestHeader("Content-Type", "application/octet-stream");
        request.setOnLoadHandler(request1 -> {
            if (request1.getReadyState() == 4) {
                if (request1.getStatus() >= 200 && request1.getStatus() < 300) {
                    resolver.result(new HTTPResponse(request1.getStatus(), null));
                } else {
                    resolver.error(new HTTPError(request1.getStatus()));
                }
            }
        });
        Uint8Array push = TypedArrays.createUint8Array(contents.length);
        for (int i = 0; i < contents.length; i++) {
            push.set(i, contents[i]);
        }
        request.send(push.buffer());
    });
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:23,代码来源:JsHttpProvider.java


示例2: send

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public void send(ByteBuffer data) {
  int len = data.limit();
  // TODO(haustein) Sending the view directly does not work for some reason.
  // May be a chrome issue...?
  //  Object trick = data;
  // ArrayBufferView ta = ((HasArrayBufferView) trick).getTypedArray();
  // Int8Array view = Int8Array.create(ta.getBuffer(), ta.getByteOffset(), len)
  // ws.send(view);
  ArrayBuffer buf = TypedArrays.createArrayBuffer(len);
  Uint8Array view = TypedArrays.createUint8Array(buf);
  for (int i = 0; i < len; i++) {
    view.set(i, data.get(i));
  }
  ws.send(buf);
}
 
开发者ID:playn,项目名称:playn,代码行数:17,代码来源:HtmlWebSocket.java


示例3: BSInputStream

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
/**
  * Creates a new BSInputStream object.
* @param bsInputStream 
  */
 public BSInputStream(BSInputStream toCopy) {
  this.zp = new ZPCodec(toCopy.zp);
  for (int i = 0; i < toCopy.ctx.length; i++) {
	  if (toCopy.ctx[i] != null) {
		  ctx[i] = new BitContext((short) (toCopy.ctx[i].get() & 0xFF));
	  }
  }
  if (toCopy.data != null) {
	  data = TypedArrays.createUint8Array(toCopy.data.length());
	  data.set(toCopy.data);
  }
  eof = toCopy.eof;
  blocksize = toCopy.blocksize;
  bptr = toCopy.bptr;
  size = toCopy.size;
 }
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:21,代码来源:BSInputStream.java


示例4: loadBinary

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的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();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:21,代码来源:AssetDownloader.java


示例5: doSend

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public void doSend(byte[] data) {
    // Log.d(TAG, "doSend");
    if (isClosed) {
        return;
    }
    Uint8Array push = TypedArrays.createUint8Array(data.length);
    for (int i = 0; i < data.length; i++) {
        push.set(i, data[i]);
    }
    send(push);
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:13,代码来源:WebSocketConnection.java


示例6: convertBytes

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
public static byte[] convertBytes(ArrayBuffer buffer) {
    Uint8Array array = TypedArrays.createUint8Array(buffer);
    byte[] res = new byte[array.length()];
    for (int i = 0; i < res.length; i++) {
        res[i] = (byte) (array.get(i));
    }
    return res;
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:9,代码来源:Conversion.java


示例7: read

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public Promise<FilePart> read(int fileOffset, int len) {
    return new Promise<>(resolver -> {
        JsFileReader fileReader = JsFileReader.create();
        fileReader.setOnLoaded(message -> {
            Uint8Array array = TypedArrays.createUint8Array(message);
            byte[] data = new byte[len];
            for (int i = 0; i < len; i++) {
                data[i] = (byte) (array.get(i));
            }
            resolver.result(new FilePart(fileOffset, len, data));
        });
        fileReader.readAsArrayBuffer(jsFile.slice(fileOffset, fileOffset + len));
    });
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:16,代码来源:JsFileInput.java


示例8: FloatBuffer

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
FloatBuffer (ByteBuffer byteBuffer) {
  super((byteBuffer.capacity() >> 2));
  this.byteBuffer = byteBuffer;
  this.byteBuffer.clear();
  this.floatArray = TypedArrays.createFloat32Array(
    byteBuffer.byteArray.buffer(), byteBuffer.byteArray.byteOffset(), capacity);
}
 
开发者ID:playn,项目名称:playn,代码行数:8,代码来源:FloatBuffer.java


示例9: IntBuffer

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
IntBuffer(ByteBuffer byteBuffer) {
  super((byteBuffer.capacity() >> 2));
  this.byteBuffer = byteBuffer;
  this.byteBuffer.clear();
  this.intArray = TypedArrays.createInt32Array(
      byteBuffer.byteArray.buffer(),
      byteBuffer.byteArray.byteOffset(), capacity);
}
 
开发者ID:playn,项目名称:playn,代码行数:9,代码来源:IntBuffer.java


示例10: ShortBuffer

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
ShortBuffer(ByteBuffer byteBuffer) {
  super((byteBuffer.capacity() >> 1));
  this.byteBuffer = byteBuffer;
  this.byteBuffer.clear();
  this.shortArray = TypedArrays.createInt16Array(
      byteBuffer.byteArray.buffer(),
      byteBuffer.byteArray.byteOffset(), capacity);
}
 
开发者ID:playn,项目名称:playn,代码行数:9,代码来源:ShortBuffer.java


示例11: getTypedArray

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
/**
 * Returns the typed array of the given native buffer. Set byteSize to -1 to use remaining().
 */
private ArrayBufferView getTypedArray(Buffer buffer, int type, int byteSize) {
  if (!(buffer instanceof HasArrayBufferView)) {
    throw new RuntimeException("Native buffer required " + buffer);
  }
  HasArrayBufferView arrayHolder = (HasArrayBufferView) buffer;
  int bufferElementSize = arrayHolder.getElementSize();

  ArrayBufferView webGLArray = arrayHolder.getTypedArray();
  if (byteSize == -1) {
    byteSize = buffer.remaining() * bufferElementSize;
  }
  if (byteSize == buffer.capacity() * bufferElementSize && type == arrayHolder.getElementType()) {
    return webGLArray;
  }

  int byteOffset = webGLArray.byteOffset() + buffer.position() * bufferElementSize;

  switch (type) {
    case FLOAT:
      return TypedArrays.createFloat32Array(webGLArray.buffer(), byteOffset, byteSize / 4);
    case UNSIGNED_BYTE:
      return TypedArrays.createUint8Array(webGLArray.buffer(), byteOffset, byteSize);
    case UNSIGNED_SHORT:
      return TypedArrays.createUint16Array(webGLArray.buffer(), byteOffset, byteSize / 2);
    case INT:
      return TypedArrays.createInt32Array(webGLArray.buffer(), byteOffset, byteSize / 4);
    case SHORT:
      return TypedArrays.createInt16Array(webGLArray.buffer(), byteOffset, byteSize / 2);
    case BYTE:
      return TypedArrays.createInt8Array(webGLArray.buffer(), byteOffset, byteSize);
    default:
      throw new IllegalArgumentException("Type: " + type);
  }
}
 
开发者ID:playn,项目名称:playn,代码行数:38,代码来源:HtmlGL20.java


示例12: getBytes

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public RFuture<ByteBuffer> getBytes(final String path) {
  if (!TypedArrays.isSupported()) return RFuture.failure(
    new UnsupportedOperationException("TypedArrays not supported by this browser."));
  return doXhr(pathPrefix + path, XMLHttpRequest.ResponseType.ArrayBuffer).
    map(new Function<XMLHttpRequest,ByteBuffer>() {
      public ByteBuffer apply (XMLHttpRequest xhr) {
        return TypedArrayHelper.wrap(xhr.getResponseArrayBuffer());
      }
    });
}
 
开发者ID:playn,项目名称:playn,代码行数:12,代码来源:HtmlAssets.java


示例13: downloadFile

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
private void downloadFile(final String url) {
	XMLHttpRequest request = XMLHttpRequest.create();
	request.open("GET", url);
	request.setResponseType(ResponseType.ArrayBuffer);
	request.setOnReadyStateChange(new ReadyStateChangeHandler() {
		@Override
		public void onReadyStateChange(XMLHttpRequest xhr) {
			if (xhr.getReadyState() == XMLHttpRequest.DONE) {
				downloadsInProgress--;
				if (xhr.getStatus() == 200) {
					FileItem entry = getCachedFile(url);
					entry.data = TypedArrays.createUint8Array(xhr.getResponseArrayBuffer());
					entry.dataSize = entry.data.byteLength();
					filesMemoryUsage += entry.dataSize;
					checkFilesMemory();
					context.startProcessing();
					fireReady(url);
					continueDownload();
				} else {
					GWT.log("Error downloading " + url);
					GWT.log("response status: " + xhr.getStatus() + " " + xhr.getStatusText());
					context.setStatus(ProcessingContext.STATUS_ERROR);
					fileCache.get(url).downloadStarted = false;
				}
			}
		}
	});
	request.send();
	fileCache.get(url).downloadStarted = true;
	downloadsInProgress++;
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:32,代码来源:PageDecoder.java


示例14: IWCodec

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
/**
 * Creates a new IWCodec object.
 */
public IWCodec()
{
  ctxStart = new BitContext[32];

  for(int i = 0; i < 32; i++)
  {
    ctxStart[i] = new BitContext();
  }

  ctxBucket = new BitContext[10][8];

  for(int i = 0; i < 10; i++)
  {
    for(int j = 0; j < 8; j++)
    {
      ctxBucket[i][j] = new BitContext();
    }
  }

  quant_hi      = TypedArrays.createInt32Array(10);
  quant_lo      = TypedArrays.createInt32Array(16);
  coeffstate    = TypedArrays.createInt8Array(256);
  bucketstate   = TypedArrays.createInt8Array(16);
  curband       = 0;
  curbit        = 1;
  ctxMant       = new BitContext();
  ctxRoot       = new BitContext();
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:32,代码来源:IWCodec.java


示例15: doSend

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public void doSend(byte[] data) {
    if (isClosed) {
        return;
    }
    Uint8Array push = TypedArrays.createUint8Array(data.length);
    for (int i = 0; i < data.length; i++) {
        push.set(i, data[i]);
    }
    send(push);
}
 
开发者ID:dsaved,项目名称:africhat-platform-0.1,代码行数:12,代码来源:WebSocketConnection.java


示例16: read

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public void read(final int fileOffset, final byte[] data, final int offset, final int len, final FileReadCallback callback) {
    JsFileReader fileReader = JsFileReader.create();
    fileReader.setOnLoaded(new JsFileLoadedClosure() {
        @Override
        public void onLoaded(ArrayBuffer message) {
            Uint8Array array = TypedArrays.createUint8Array(message);
            for (int i = 0; i < len; i++) {
                data[offset + i] = (byte) (array.get(i));
            }
            callback.onFileRead(fileOffset, data, offset, len);
        }
    });
    fileReader.readAsArrayBuffer(jsFile.slice(fileOffset, fileOffset + len));
}
 
开发者ID:dsaved,项目名称:africhat-platform-0.1,代码行数:16,代码来源:JsFileInput.java


示例17: send

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的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 );
  }
}
 
开发者ID:realityforge,项目名称:gwt-websockets-example,代码行数:14,代码来源:Example.java


示例18: onMessage

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的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" );
}
 
开发者ID:realityforge,项目名称:gwt-websockets-example,代码行数:12,代码来源:Example.java


示例19: IntBuffer

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
IntBuffer(ByteBuffer byteBuffer) {
  super((byteBuffer.capacity() >> 2));
  this.byteBuffer = byteBuffer;
  this.byteBuffer.clear();
  this.intArray = TypedArrays.createInt32Array(
      byteBuffer.byteArray.buffer(), 
      byteBuffer.byteArray.byteOffset(), capacity);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:9,代码来源:IntBuffer.java


示例20: ByteBuffer

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
/** Constructs a {@code ByteBuffer} with given capacity.
 *
 * @param capacity the capacity of the buffer. */
ByteBuffer (int capacity) {
    this(TypedArrays.createArrayBuffer(capacity));
}
 
开发者ID:playn,项目名称:playn,代码行数:7,代码来源:ByteBuffer.java



注:本文中的com.google.gwt.typedarrays.shared.TypedArrays类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BERTaggedObject类代码示例发布时间:2022-05-22
下一篇:
Java RedirectionException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap