(Reitveld is really on the fritz tonight and I can't submit my comments there)

Do you think this would make a good addition to the ArrayHelper class?

http://code.google.com/p/gwt-google-apis/source/browse/trunk/ajaxloader/ajaxloader/src/com/google/gwt/ajaxloader/client/ArrayHelper.java

On Sun, Jul 5, 2009 at 11:35 AM, <[email protected]> wrote:
>
> Reviewers: t.broyer,
>
> Description:
> This patch adds getBytes() method to Blob (Gears 0.5.21.0)
>
> Please review this at http://galgwt-reviews.appspot.com/41604
>
> Affected files:
>   gears/src/com/google/gwt/gears/client/blob/Blob.java
>
>
> Index: gears/src/com/google/gwt/gears/client/blob/Blob.java
> ===================================================================
> --- gears/src/com/google/gwt/gears/client/blob/Blob.java        (revision 
> 1519)
> +++ gears/src/com/google/gwt/gears/client/blob/Blob.java        (working copy)
> @@ -16,6 +16,7 @@
>  package com.google.gwt.gears.client.blob;
>
>  import com.google.gwt.core.client.JavaScriptObject;
> +import com.google.gwt.core.client.JsArrayInteger;
>
>  /**
>   * A Blob is a reference to an opaque block of binary data.
> @@ -57,6 +58,18 @@
>    protected Blob() {
>      // required for overlay types
>    }
> +
> +  public byte[] getBytes() {
> +    return toJavaArray(nativeGetBytes());
> +  }
> +
> +  public byte[] getBytes(int offset) {
> +    return toJavaArray(nativeGetBytes(offset));
> +  }
> +
> +  public byte[] getBytes(int offset, int length) {
> +    return toJavaArray(nativeGetBytes(offset, length));
> +  }
>
>    public native int getLength()/*-{
>      return this.length;
> @@ -65,4 +78,25 @@
>    public native Blob slice(int offset, int length)/*-{
>      return this.slice(offset, length);
>    }-*/;
> +
> +  private native JsArrayInteger nativeGetBytes() /*-{
> +    return this.getBytes();
> +  }-*/;
> +
> +  private native JsArrayInteger nativeGetBytes(int offset) /*-{
> +    return this.getBytes(offset);
> +  }-*/;
> +
> +  private native JsArrayInteger nativeGetBytes(int offset, int length) /*-{
> +    return this.getBytes(offset, length);
> +  }-*/;
> +
> +  private byte[] toJavaArray(JsArrayInteger bytes) {
> +    int length = bytes.length();
> +    byte[] ret = new byte[length];
> +    for (int i = 0; i < length; i++) {
> +      ret[i] = (byte) bytes.get(i);
> +    }
> +    return ret;
> +  }
>  }
>
>
>
> >
>



-- 
Eric Z. Ayers - GWT Team - Atlanta, GA USA
http://code.google.com/webtoolkit/

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to