use of com.google.gwt.core.client.JsArrayInteger in project playn by threerings.
the class ArrayUtils method toJsArrayUnsigned.
public static JsArrayInteger toJsArrayUnsigned(byte[] data) {
JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray();
int len = data.length;
for (int i = len - 1; i >= 0; i--) {
jsan.set(i, data[i] & 255);
}
return jsan;
}
use of com.google.gwt.core.client.JsArrayInteger in project playn by threerings.
the class ArrayUtils method toJsArray.
// TODO(jgw): Get rid of these conversions in web mode.
public static JsArrayInteger toJsArray(byte[] data) {
JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray();
int len = data.length;
for (int i = len - 1; i >= 0; i--) {
jsan.set(i, data[i]);
}
return jsan;
}
use of com.google.gwt.core.client.JsArrayInteger in project playn by threerings.
the class ArrayUtils method toJsArray.
public static JsArrayInteger toJsArray(short[] data) {
JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray();
int len = data.length;
for (int i = len - 1; i >= 0; i--) {
jsan.set(i, data[i]);
}
return jsan;
}
use of com.google.gwt.core.client.JsArrayInteger in project playn by threerings.
the class ArrayUtils method toJsArrayUnsigned.
public static JsArrayInteger toJsArrayUnsigned(short[] data) {
JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray();
int len = data.length;
for (int i = len - 1; i >= 0; i--) {
jsan.set(i, data[i] & 65535);
}
return jsan;
}
use of com.google.gwt.core.client.JsArrayInteger in project rstudio by rstudio.
the class SpellingService method checkSpelling.
public void checkSpelling(List<String> words, final ServerRequestCallback<SpellCheckerResult> callback) {
// results to return
final SpellCheckerResult spellCheckerResult = new SpellCheckerResult();
// only send words to the server that aren't in the cache
final ArrayList<String> wordsToCheck = new ArrayList<String>();
for (int i = 0; i < words.size(); i++) {
String word = words.get(i);
Boolean isCorrect = previousResults_.get(word);
if (isCorrect != null) {
if (isCorrect)
spellCheckerResult.getCorrect().add(word);
else
spellCheckerResult.getIncorrect().add(word);
} else {
wordsToCheck.add(word);
}
}
// if there are no words to check then return
if (wordsToCheck.size() == 0) {
callback.onResponseReceived(spellCheckerResult);
return;
}
// hit the server
server_.checkSpelling(JsUtil.toJsArrayString(wordsToCheck), new ServerRequestCallback<JsArrayInteger>() {
@Override
public void onResponseReceived(JsArrayInteger result) {
// get misspelled indexes
ArrayList<Integer> misspelledIndexes = new ArrayList<Integer>();
for (int i = 0; i < result.length(); i++) misspelledIndexes.add(result.get(i));
// determine correct/incorrect status and populate result & cache
for (int i = 0; i < wordsToCheck.size(); i++) {
String word = wordsToCheck.get(i);
if (misspelledIndexes.contains(i)) {
spellCheckerResult.getIncorrect().add(word);
previousResults_.put(word, false);
} else {
spellCheckerResult.getCorrect().add(word);
previousResults_.put(word, true);
}
}
// return result
callback.onResponseReceived(spellCheckerResult);
}
@Override
public void onError(ServerError error) {
callback.onError(error);
}
});
}
Aggregations