Example usage for com.google.gwt.core.client JsArrayString push

List of usage examples for com.google.gwt.core.client JsArrayString push

Introduction

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

Prototype

public final native void push(String value) ;

Source Link

Document

Pushes the given value onto the end of the array.

Usage

From source file:com.google.mobile.trippy.web.client.db.JsoTrip.java

License:Apache License

public final void setContributorIds(HashSet<String> contributorIds) {
    JsArrayString stringArr = (JsArrayString) JavaScriptObject.createArray();
    for (String s : contributorIds) {
        stringArr.push(s);
    }//from  w  w w  .  ja  v  a  2s .  c  o  m
    setContributorIds(stringArr);
}

From source file:com.google.mobile.trippy.web.client.db.JsoTrip.java

License:Apache License

public final void setViewerIds(HashSet<String> viewerIds) {
    JsArrayString stringArr = (JsArrayString) JavaScriptObject.createArray();
    for (String s : viewerIds) {
        stringArr.push(s);
    }//from   w ww  .ja v a2  s.c  om
    setViewerIds(stringArr);
}

From source file:com.google.mobile.trippy.web.client.db.JsoTripItem.java

License:Apache License

public final void setPhoneNumbers(ArrayList<String> phoneNumbers) {
    JsArrayString jarr = (JsArrayString) JavaScriptObject.createArray();
    for (String ph : phoneNumbers) {
        jarr.push(ph);
    }//from  ww w  .j a  va  2s.c  o  m
    setPhoneNumbers_(jarr);
}

From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java

License:Apache License

public void addTrip(final Trip trip) {
    JsoTrip jsoTrip = (JsoTrip) JavaScriptObject.createObject();
    jsoTrip.setTrip(trip);//from  ww w .j av a 2  s .  c o  m
    final String tripKey = KEY_LOCAL_STORE_TRIP_PREFIX + trip.getKey();
    LocalDbService.makePersistent(tripKey, new JSONObject(jsoTrip).toString());
    final JsArrayString tripKeys = getIndexKeys(KEY_LOCAL_STORE_TRIPS);
    for (int i = 0; i < tripKeys.length(); ++i) {
        if (tripKeys.get(i).equals(tripKey)) {
            return;
        }
    }
    tripKeys.push(tripKey);
    setIndexKeys(KEY_LOCAL_STORE_TRIPS, tripKeys);
    eventBus.fireEvent(new TripAddedEvent(trip));
}

From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java

License:Apache License

public void deleteTrip(final Trip trip) {
    final String tripKey = KEY_LOCAL_STORE_TRIP_PREFIX + trip.getKey();
    LocalDbService.deletePersistent(tripKey);
    final JsArrayString tripKeys = getIndexKeys(KEY_LOCAL_STORE_TRIPS);
    final JsArrayString newTripKeys = (JsArrayString) JavaScriptObject.createArray();
    for (int i = 0; i < tripKeys.length(); ++i) {
        if (!tripKeys.get(i).equals(tripKey)) {
            newTripKeys.push(tripKeys.get(i));
        }// w w w. j  a v  a2  s . co  m
    }
    setIndexKeys(KEY_LOCAL_STORE_TRIPS, newTripKeys);
    eventBus.fireEvent(new TripDeletedEvent(trip));
}

From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java

License:Apache License

public void addTripItem(final TripItem tripItem) {
    JsoTripItem jsoTripItem = (JsoTripItem) JavaScriptObject.createObject();
    jsoTripItem.setTripItem(tripItem);/* w  ww. jav a2 s.  c o  m*/
    final String tripItemKey = KEY_LOCAL_STORE_TI_PREFIX + tripItem.getKey();
    LocalDbService.makePersistent(tripItemKey, new JSONObject(jsoTripItem).toString());
    final JsArrayString tripItemKeys = getIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripItem.getTripId());
    for (int i = 0; i < tripItemKeys.length(); ++i) {
        if (tripItemKeys.get(i).equals(tripItemKey)) {
            return;
        }
    }
    tripItemKeys.push(tripItemKey);
    setIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripItem.getTripId(), tripItemKeys);
    eventBus.fireEvent(new TripItemAddedEvent(tripItem));
    final Trip trip = getTrip(tripItem.getTripId());
    final String tripItemStartDate = "Day " + tripItem.getStartDay();
    final String latlng = tripItem.getLatitude() + "," + tripItem.getLongitude();
    utils.addTripItem(tripItemStartDate, tripItem.getTripId(), tripItem.getKey(), tripItem.getName(),
            tripItem.getAddress() + ", " + trip.getLocation(), latlng,
            utils.getTripItemPosition(tripItem.getTripId(), tripItem.getKey(), tripItem.getStartDay()));
}

From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java

License:Apache License

public void deleteTripItem(final String tripId, final String tripItemId) {
    final TripItem tripItem = getTripItem(tripItemId);
    final String tripItemKey = KEY_LOCAL_STORE_TI_PREFIX + tripItemId;
    LocalDbService.deletePersistent(tripItemKey);
    final JsArrayString tripItemKeys = getIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripId);
    final JsArrayString newTripItemKeys = (JsArrayString) JavaScriptObject.createArray();
    for (int i = 0; i < tripItemKeys.length(); ++i) {
        if (!tripItemKeys.get(i).equals(tripItemKey)) {
            newTripItemKeys.push(tripItemKeys.get(i));
        }// w w w  .java2  s.  c o m
    }
    setIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripId, newTripItemKeys);
    eventBus.fireEvent(new TripItemDeletedEvent(tripItem));
    utils.remTripItem(tripItemId);
}

From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java

License:Apache License

public void addComment(final Comment comment) {
    final JsoComment jsoComment = (JsoComment) JavaScriptObject.createObject();
    jsoComment.setComment(comment);//from www. ja  v  a2s . c  o  m
    final String commentKey = KEY_LOCAL_STORE_COMMENT_PREFIX + comment.getKey();
    LocalDbService.makePersistent(commentKey, new JSONObject(jsoComment).toString());
    final JsArrayString commentKeys = getIndexKeys(
            KEY_LOCAL_STORE_COMMENTS_PREFIX + comment.getTripId() + "_" + comment.getTripItemId());
    for (int i = 0; i < commentKeys.length(); ++i) {
        if (commentKeys.get(i).equals(commentKey)) {
            return;
        }
    }
    commentKeys.push(commentKey);
    setIndexKeys(KEY_LOCAL_STORE_COMMENTS_PREFIX + comment.getTripId() + "_" + comment.getTripItemId(),
            commentKeys);
    eventBus.fireEvent(new CommentAddedEvent(comment));
}

From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java

License:Apache License

public void deleteComment(final String tripId, final String tripItemId, final String commentId) {
    final Comment comment = getComment(commentId);
    final String commentKey = KEY_LOCAL_STORE_COMMENT_PREFIX + commentId;
    LocalDbService.deletePersistent(commentKey);
    final JsArrayString commentKeys = getIndexKeys(KEY_LOCAL_STORE_COMMENTS_PREFIX + tripId + "_" + tripItemId);
    final JsArrayString newCommentKeys = (JsArrayString) JavaScriptObject.createArray();
    for (int i = 0; i < commentKeys.length(); ++i) {
        if (!commentKeys.get(i).equals(commentKey)) {
            newCommentKeys.push(commentKeys.get(i));
        }//from   w  ww  .  j  a  v  a  2  s  . co  m
    }
    setIndexKeys(KEY_LOCAL_STORE_COMMENTS_PREFIX + tripId + "_" + tripItemId, newCommentKeys);
    eventBus.fireEvent(new CommentDeletedEvent(comment));
}

From source file:com.google.speedtracer.client.util.Csv.java

License:Apache License

/**
 * Split a comma separated value log line while ignoring escaped strings.
 *///  w w w.  j a  v  a  2s.c  o  m
public static JsArrayString split(String csvString) {
    // Implemented as a little state machine
    int state;
    JsArrayString results = JsArrayString.createArray().cast();
    int index = 0;
    StringBuilder field = new StringBuilder();

    state = SPLIT_LOOKING_FOR_COMMA;
    while (index < csvString.length()) {
        char nextCharacter = csvString.charAt(index);
        switch (state) {
        case SPLIT_LOOKING_FOR_COMMA:
            switch (nextCharacter) {
            case ',':
                results.push(field.toString());
                field = new StringBuilder();
                break;
            case '"':
                state = SPLIT_IN_STRING;
                break;
            default:
                field.append(nextCharacter);
            }
            break;
        case SPLIT_IN_STRING:
            switch (nextCharacter) {
            case '"':
                state = SPLIT_LOOKING_FOR_COMMA;
                break;
            case '\\':
                state = SPLIT_IN_ESCAPE;
                field.append(nextCharacter);
                break;
            default:
                field.append(nextCharacter);
            }
            break;
        case SPLIT_IN_ESCAPE:
            state = SPLIT_IN_STRING;
            field.append(nextCharacter);
            break;
        default:
            field.append(nextCharacter);
        }
        index++;
    }

    // save the last field.
    results.push(field.toString());

    return results;
}