List of usage examples for com.google.gwt.core.client JsArrayInteger set
public final native void set(int index, int value) ;
From source file:com.ait.toolkit.sencha.touch.client.ui.Slider.java
License:Open Source License
/** * Sets the value of value.//from w ww. j av a 2 s. c o m * * @param value */ public void setSliderValues(int[] value) { JsArrayInteger values = JavaScriptObject.createArray().cast(); for (int i = 0; i < value.length; i++) { values.set(i, value[i]); } setSliderValues(values); }
From source file:com.googlecode.gwt.charts.client.ajaxloader.ArrayHelper.java
License:Apache License
/** * Converts Java integer array to JavaScript integer array. * /*ww w . jav a 2 s .co m*/ * @param integers array of integers to convert. */ public static JsArrayInteger toJsArrayInteger(int... integers) { JsArrayInteger result = JsArrayInteger.createArray().cast(); for (int i = 0; i < integers.length; i++) { result.set(i, integers[i]); } nativePatchConstructorForSafari(result); return result; }
From source file:java.util.BitSet.java
License:Apache License
private static void flip(JsArrayInteger array, int bitIndex) { // calculate index and offset int index = wordIndex(bitIndex); int offset = bitOffset(bitIndex); // figure out if the bit is on or off int word = getWord(array, index); if (((word >>> offset) & 1) == 1) { // if on, turn it off setWord(array, index, word & ~(1 << offset)); } else {/*from ww w . ja v a 2 s. co m*/ // if off, turn it on array.set(index, word | (1 << offset)); } }
From source file:java.util.BitSet.java
License:Apache License
private static void set(JsArrayInteger array, int bitIndex) { int index = wordIndex(bitIndex); array.set(index, getWord(array, index) | (1 << (bitOffset(bitIndex)))); }
From source file:java.util.BitSet.java
License:Apache License
private static void set(JsArrayInteger array, int fromIndex, int toIndex) { int first = wordIndex(fromIndex); int last = wordIndex(toIndex); int startBit = bitOffset(fromIndex); int endBit = bitOffset(toIndex); if (first == last) { // set the bits in between first and last maskInWord(array, first, startBit, endBit); } else {//from w w w.ja v a 2 s. com // set the bits from fromIndex to the next 32 bit boundary if (startBit != 0) { maskInWord(array, first++, startBit, 32); } // set the bits from the last 32 bit boundary to the toIndex if (endBit != 0) { maskInWord(array, last, 0, endBit); } // // set everything in between // for (int i = first; i < last; i++) { array.set(i, 0xffffffff); } } }
From source file:java.util.BitSet.java
License:Apache License
private static void flipWord(JsArrayInteger array, int index) { int word = getWord(array, index); if (word == 0) { array.set(index, 0xffffffff); } else {/*from ww w. j a v a 2 s . c o m*/ word = ~word; setWord(array, index, word); } }
From source file:java.util.BitSet.java
License:Apache License
private static void maskInWord(JsArrayInteger array, int index, int from, int to) { // shifting by 32 is the same as shifting by 0, this check prevents that // from happening in addition to the obvious avoidance of extra work if (from != to) { // adjust "to" so it will shift out those bits to = 32 - to;/*from w ww .j a va 2s. c om*/ // create a mask and OR it in int value = getWord(array, index); value |= ((0xffffffff >>> from) << (from + to)) >>> to; array.set(index, value); } }
From source file:java.util.BitSet.java
License:Apache License
private static void setWord(JsArrayInteger array, int index, int value) { // keep 0s out of the array if (value == 0) { deleteWord(array, index);/* w w w. j a v a 2s . c o m*/ } else { array.set(index, value); } }
From source file:java.util.BitSet.java
License:Apache License
public BitSet get(int fromIndex, int toIndex) { checkRange(fromIndex, toIndex);/*from ww w .j av a 2s. c om*/ // no need to go past our length toIndex = Math.min(toIndex, length()); // this is the bit shift offset for each group of bits int rightShift = bitOffset(fromIndex); if (rightShift == 0) { int subFrom = wordIndex(fromIndex); int subTo = wordIndex(toIndex + 31); JsArrayInteger subSet = slice(array, subFrom, subTo); int leftOvers = bitOffset(toIndex); if (leftOvers != 0) { maskOutWord(subSet, subTo - subFrom - 1, leftOvers, 32); } return new BitSet(subSet); } BitSet subSet = new BitSet(); int first = wordIndex(fromIndex); int last = wordIndex(toIndex); if (first == last) { // number of bits to cut from the end int end = 32 - (bitOffset(toIndex)); // raw bits int word = getWord(array, first); // shift out those bits word = ((word << end) >>> end) >>> rightShift; // set it if (word != 0) { subSet.set(0, word); } } else { // this will hold the newly packed bits int current = 0; // this is the raw index into the sub set int subIndex = 0; // fence post, carry over initial bits int word = getWord(array, first++); current = word >>> rightShift; // a left shift will be used to shift our bits to the top of "current" int leftShift = 32 - rightShift; // loop through everything in the middle for (int i = first; i <= last; i++) { word = getWord(array, i); // shift out the bits from the top, OR them into current bits current |= word << leftShift; // flush it out if (current != 0) { subSet.array.set(subIndex, current); } // keep track of our index subIndex++; // carry over the unused bits current = word >>> rightShift; } // fence post, flush out the extra bits, but don't go past the "end" int end = 32 - (bitOffset(toIndex)); current = (current << (rightShift + end)) >>> (rightShift + end); if (current != 0) { subSet.array.set(subIndex, current); } } return subSet; }
From source file:org.cruxframework.crux.core.client.encoder.MD5.java
License:Apache License
/** * Calculate the HMAC-MD5, of a key and some data (raw strings) *//*w ww .j a v a2 s.c o m*/ public static String rawHmacMD5(String key, String data) { JsArrayInteger bkey = rstr2binl(key); if (bkey.length() > 16) bkey = binl2md5(bkey, key.length() * 8); JsArrayInteger ipad = JsArrayInteger.createArray().cast(); JsArrayInteger opad = JsArrayInteger.createArray().cast(); ipad.setLength(16); opad.setLength(16); for (int i = 0; i < 16; i++) { ipad.set(i, bkey.get(i) ^ 0x36363636); opad.set(i, bkey.get(i) ^ 0x5C5C5C5C); } JsArrayInteger hash = binl2md5(concat(ipad, rstr2binl(data)), 512 + data.length() * 8); return binl2rstr(binl2md5(concat(opad, hash), 512 + 128)); }