Example usage for com.google.gwt.core.client JsArrayInteger length

List of usage examples for com.google.gwt.core.client JsArrayInteger length

Introduction

In this page you can find the example usage for com.google.gwt.core.client JsArrayInteger length.

Prototype

public final native int length() ;

Source Link

Document

Gets the length of the array.

Usage

From source file:amdb.client.slider.Slider.java

License:Apache License

private int[] jsArrayIntegerToIntArray(JsArrayInteger values) {
    int len = values.length();
    int[] vals = new int[len];
    for (int i = 0; i < len; i++) {
        vals[i] = values.get(i);//from   w  w  w .  ja v a2  s.c om
    }
    return vals;
}

From source file:com.alonsoruibal.chess.book.JSONBook.java

License:Open Source License

public void generateMoves(Board board) {
    String key2Find = "x" + Long.toHexString(board.getKey());
    totalWeight = 0;//from   w w  w . ja va  2s . c o  m
    moves = new ArrayList<Integer>();
    weights = new ArrayList<Integer>();
    JsArray<JsArrayInteger> array = getData(key2Find);
    if (array != null) {
        JsArrayInteger moveArray = array.get(0);
        JsArrayInteger weightArray = array.get(1);
        for (int i = 0, size = moveArray.length(); i < size; i++) {
            int moveInt = moveArray.get(i);
            int weight = weightArray.get(i);
            int move = Move.getFromString(board, int2MoveString(moveInt), true);
            // Add only if it is legal
            if (board.isMoveLegal(move)) {
                //GWT.log("JSONBook addMove(" + move + ", " + weight + ")", null);
                moves.add(move);
                weights.add(weight);
                totalWeight += weight;
            }
        }
    }
}

From source file:com.calclab.emite.core.client.xmpp.datetime.gwt.TimeZone.java

License:Open Source License

public static TimeZone createTimeZone(TimeZoneInfo timezoneData) {
    TimeZone tz = new TimeZone();

    tz.timezoneID = timezoneData.getID();
    tz.standardOffset = -timezoneData.getStandardOffset();

    JsArrayString jsTimezoneNames = timezoneData.getNames();

    tz.tzNames = new String[jsTimezoneNames.length()];

    for (int i = 0; i < jsTimezoneNames.length(); i++) {
        tz.tzNames[i] = jsTimezoneNames.get(i);
    }/*  ww  w . j ava2s. c o  m*/

    JsArrayInteger transitions = timezoneData.getTransitions();

    if (transitions == null || transitions.length() == 0) {
        tz.transitionPoints = null;
        tz.adjustments = null;
    } else {
        int transitionNum = transitions.length() / 2;
        tz.transitionPoints = new int[transitionNum];
        tz.adjustments = new int[transitionNum];

        for (int i = 0; i < transitionNum; ++i) {
            tz.transitionPoints[i] = transitions.get(i * 2);
            tz.adjustments[i] = transitions.get(i * 2 + 1);
        }
    }
    return tz;
}

From source file:com.github.nmorel.gwtjackson.client.deser.array.cast.PrimitiveIntegerArrayJsonDeserializer.java

License:Apache License

@Override
public int[] doDeserializeArray(JsonReader reader, JsonDeserializationContext ctx,
        JsonDeserializerParameters params) {
    JsArrayInteger jsArray = JsArrayInteger.createArray().cast();
    reader.beginArray();//from ww w .j a  va2s. c o  m
    while (JsonToken.END_ARRAY != reader.peek()) {
        if (JsonToken.NULL == reader.peek()) {
            reader.skipValue();
            jsArray.push(DEFAULT);
        } else {
            jsArray.push(reader.nextInt());
        }
    }
    reader.endArray();

    if (GWT.isScript()) {
        return reinterpretCast(jsArray);
    } else {
        int length = jsArray.length();
        int[] ret = new int[length];
        for (int i = 0; i < length; i++) {
            ret[i] = jsArray.get(i);
        }
        return ret;
    }
}

From source file:com.github.nmorel.gwtjackson.client.deser.array.cast.PrimitiveShortArrayJsonDeserializer.java

License:Apache License

@Override
public short[] doDeserializeArray(JsonReader reader, JsonDeserializationContext ctx,
        JsonDeserializerParameters params) {
    JsArrayInteger jsArray = JsArrayInteger.createArray().cast();
    reader.beginArray();/*from  ww  w .ja va2  s  .  c  o  m*/
    while (JsonToken.END_ARRAY != reader.peek()) {
        if (JsonToken.NULL == reader.peek()) {
            reader.skipValue();
            jsArray.push(DEFAULT);
        } else {
            jsArray.push(reader.nextInt());
        }
    }
    reader.endArray();

    if (GWT.isScript()) {
        return reinterpretCast(jsArray);
    } else {
        int length = jsArray.length();
        short[] ret = new short[length];
        for (int i = 0; i < length; i++) {
            ret[i] = (short) jsArray.get(i);
        }
        return ret;
    }
}

From source file:com.google.livingstories.client.lsp.Externs.java

License:Apache License

public static void bind() {
    currentParameters = Window.Location.getParameterMap();

    Set<Integer> corePanelIds = new HashSet<Integer>();
    JsArrayInteger corePanelIdsJs = getCorePanelIds();
    if (corePanelIdsJs != null) {
        for (int i = 0; i < corePanelIdsJs.length(); i++) {
            corePanelIds.add(corePanelIdsJs.get(i));
        }/*from   w  ww .  j a va 2  s  .  c o  m*/
    }

    Dictionary itemTypes = Dictionary.getDictionary("ITEM_TYPES");
    for (String key : itemTypes.keySet()) {
        String itemType = itemTypes.get(key);
        int panelId = Integer.valueOf(key);
        boolean isCurrentFilteredType = corePanelIds.contains(panelId);
        ContentItemType contentType = getContentTypeForFilters(itemType);
        if (contentType == null) {
            throw new IllegalArgumentException("No matching content type: " + itemType);
        } else if (contentType != ContentItemType.ASSET) {
            contentTypesToPanelIds.put(contentType, panelId);
            if (isCurrentFilteredType) {
                coreItemTypes.add(contentType);
            }
        } else {
            AssetType assetType = getAssetTypeForFilters(itemType);
            assetTypesToPanelIds.put(assetType, panelId);
            if (isCurrentFilteredType) {
                coreItemTypes.add(ContentItemType.ASSET);
                coreItemAssetTypes.add(assetType);
            }
        }
    }

    Dictionary themes = Dictionary.getDictionary("THEMES");
    for (String key : themes.keySet()) {
        themesById.put(Integer.valueOf(key), themes.get(key));
    }

    parseContentItems(getContentItemsJs());
}

From source file:com.googlecode.gwt.charts.client.ajaxloader.ArrayHelper.java

License:Apache License

/**
 * Takes an array of Integers to be interpreted as bytes and returns a Java
 * Array of the byte primitive type.//w w  w. j  a va 2s .co  m
 * 
 * @param bytes a JavaScript array to return. 
 */
public static byte[] toJavaArrayBytes(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;
}

From source file:core.util.Base64.java

License:GNU General Public License

public static byte[] convert(JsArrayInteger a) {
    byte[] bytes = new byte[a.length()];
    for (int i = 0; i < a.length(); ++i)
        bytes[i] = (byte) a.get(i);

    return bytes;
}

From source file:core.util.StringsPlatform.java

License:GNU General Public License

public static byte[] toBytes(String s) {
    JsArrayInteger a = jsToBytes(s);
    byte[] bytes = new byte[a.length()];

    for (int i = 0; i < a.length(); ++i)
        bytes[i] = (byte) a.get(i);

    return bytes;
}

From source file:edu.caltech.ipac.firefly.visualize.WebPlotResultParser.java

private static void checkForIntAryResult(String key, WebPlotResult wpRes, PlotResultOverlay res) {
    JsArrayInteger jsAry = res.getIntArrayResult(key);
    if (jsAry != null) {
        int ary[] = new int[jsAry.length()];
        for (int i = 0; (i < ary.length); i++)
            ary[i] = jsAry.get(i);/*from  w w  w . ja  v  a2 s .  c  o  m*/
        wpRes.putResult(key, new DataEntry.IntArray(ary));
    }

}