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

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

Introduction

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

Prototype

public final native String get(int index) ;

Source Link

Document

Gets the value at a given index.

Usage

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

License:Apache License

/**
 * Get comments by trip and trip item id.
 *//*from w ww.  jav  a2  s.c  o  m*/
public ArrayList<Comment> getComments(final String tripId, final String tripItemId) {
    final JsArrayString tripItemKeys = getIndexKeys(
            KEY_LOCAL_STORE_COMMENTS_PREFIX + tripId + "_" + tripItemId);
    final ArrayList<Comment> comments = new ArrayList<Comment>();
    for (int i = 0; i < tripItemKeys.length(); ++i) {
        final Comment comment = getCommentFromKey(tripItemKeys.get(i));
        if (comment != null && comment.getStatus().equals(Status.ACTIVE)) {
            comments.add(comment);
        }
    }
    return comments;
}

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

License:Apache License

public ArrayList<String> getCommentIds(final String tripId, final String tripItemId) {
    final JsArrayString keys = getIndexKeys(KEY_LOCAL_STORE_COMMENTS_PREFIX + tripId + "_" + tripItemId);
    final ArrayList<String> ids = new ArrayList<String>();
    for (int i = 0; i < keys.length(); ++i) {
        final String key = keys.get(i);
        final String id = key.replace(KEY_LOCAL_STORE_COMMENT_PREFIX, "");
        ids.add(id);/*from w  ww .  jav  a 2  s .com*/
    }
    return ids;
}

From source file:com.google.speedtracer.breaky.client.DumpValidator.java

License:Apache License

/**
 * In our schema set, if a schema has a fully constrained type property, then
 * it is a concrete rather than an abstract type. The ID Map let's us quickly
 * validate based on the concrete type as objects come in.
 *//*from ww w. jav  a  2  s  . c  om*/
private void fillIdMap() {
    JsArrayString schemaNames = listSchemas();
    for (int i = 0; i < schemaNames.length(); i++) {
        JsonSchema schema = (JsonSchema) DataBag.getJSObjectProperty(schemas, schemaNames.get(i));
        JavaScriptObject properties = schema.getProperties();

        if (DataBag.hasOwnProperty(properties, "type")) {
            JsonSchema dumpType = DataBag.getJSObjectProperty(properties, "type");

            if ((DataBag.hasOwnProperty(dumpType, "minimum") && DataBag.hasOwnProperty(dumpType, "maximum"))
                    && dumpType.getMinimum() == dumpType.getMaximum()) {
                idMap.put(dumpType.getMinimum(), schema);
            }
        }
    }
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Given an array of the fields in a single log line, execute the appropriate
 * action on that entry based on the first field.
 *//*w ww . j a v  a 2  s.  com*/
private void parseLogEntry(JsArrayString logEntries) {
    if (logEntries.length() == 0) {
        return;
    }
    String command = logEntries.get(0);
    if (command.length() == 0) {
        return;
    }
    LogAction cmdMethod = logActions.get(actionTypeMap.get(command));
    if (cmdMethod != null) {
        cmdMethod.doAction(logEntries);
    } else if (ClientConfig.isDebugMode()) {
        Logging.getLogger().logText("Unknown v8 profiler command: " + command);
    }
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Process an 'alias' command. Simply aliases a command to a different string.
 * The format of this log entry is://from  w  w  w  .  j a va 2 s . c  om
 * 
 * alias, aliasName, originalName
 */
private void parseV8AliasEntry(JsArrayString logEntries) {
    assert logEntries.length() == 3;

    String originalName = logEntries.get(2);
    String aliasName = logEntries.get(1);

    V8SymbolType symbol = symbolTypeMap.get(originalName);
    if (symbol != null) {
        symbolTypeMap.put(aliasName, symbol);
    } else {
        ActionType action = actionTypeMap.get(originalName);
        if (action != null) {
            actionTypeMap.put(aliasName, action);
        } else if (ClientConfig.isDebugMode()) {
            Logging.getLogger().logText(
                    "Unable to find command: '" + logEntries.get(2) + "' to match alias: " + logEntries.get(1));
        }
    }
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * New code was added to the virtual machine. The format of this log entry is:
 * /*from   w w w  .  j  av a  2  s  .c o m*/
 * code-creation, symbolType, offset, length, "symbolName"
 * 
 * e.g. code-creation,lic,-5910913e,179,"parentNode"
 * 
 */
private void parseV8CodeCreationEntry(JsArrayString logEntries) {
    assert logEntries.length() == 5;
    V8SymbolType symbolType = symbolTypeMap.get(logEntries.get(1));

    String name = logEntries.get(4);

    double address = parseAddress(logEntries.get(2), ADDRESS_TAG_CODE);
    int executableSize = Integer.parseInt(logEntries.get(3));

    // Keep some debugging stats around
    V8Symbol found = symbolTable.lookup(address);

    if (found != null) {
        debugStats.addCollisions++;
    }

    V8Symbol symbol = new V8Symbol(scrubStringForXSS(name), symbolType, address, executableSize);

    // We have a heuristic for finding the resource for a Code Creation for
    // functions. The symbol name and function length. It is just a guess, seems
    // to work, and its better than not knowing 100% of the time where a symbol
    // comes from.
    if (symbolType.getValue() == SYMBOL_TYPE_LAZY_COMPILE) {
        lazyCompiledSymbols.put(symbol.getJsSymbol().getSymbolName() + symbol.getAddressSpan().addressLength,
                symbol);
    }

    if (symbolType.getValue() == SYMBOL_TYPE_FUNCTION) {
        V8Symbol lazySymbol = lazyCompiledSymbols
                .get(symbol.getJsSymbol().getSymbolName() + symbol.getAddressSpan().addressLength);
        if (lazySymbol != null) {
            symbol.getJsSymbol().merge(lazySymbol.getJsSymbol());
        }
    }

    symbolTable.add(symbol);
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Process a code-delete entry in the log.
 * /*  ww w.  j  a  va  2  s  .  c  o m*/
 * The format of this entry is:
 * 
 * code-delete, address
 */
private void parseV8CodeDeleteEntry(JsArrayString logEntries) {
    assert logEntries.length() == 2;
    double address = parseAddress(logEntries.get(1), ADDRESS_TAG_CODE);
    V8Symbol symbol = symbolTable.lookup(address);
    if (symbol != null) {
        symbolTable.remove(symbol);
    } else {
        // update debugging stats
        debugStats.removeMisses++;
    }
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Process a code-move entry.//from  w ww  .  j  av  a2  s .c om
 * 
 * The format of this entry is:
 * 
 * code-move, fromAddress, toAddress
 */
private void parseV8CodeMoveEntry(JsArrayString logEntries) {
    assert logEntries.length() == 3;
    double fromAddress = parseAddress(logEntries.get(1), ADDRESS_TAG_CODE);
    double toAddress = parseAddress(logEntries.get(2), ADDRESS_TAG_CODE_MOVE);
    V8Symbol symbol = symbolTable.lookup(fromAddress);
    if (symbol != null) {
        symbolTable.remove(symbol);
        symbol.getAddressSpan().setAddress(toAddress);
        symbolTable.add(symbol);
    } else {
        // update debugging stats
        debugStats.moveMisses++;
    }
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Parse a profiler entry//w  w  w .j  a v  a2 s  . c o m
 * 
 * The format of this entry is:
 * 
 * profiler, "type", ...
 */
private void parseV8ProfilerEntry(JsArrayString logEntries) {
    final String arg = logEntries.get(1);
    if (arg.equals("compression")) {
        int windowSize = Integer.parseInt(logEntries.get(2));
        this.logDecompressor = new V8LogDecompressor(windowSize);
    } else if (arg.equals("begin")) {
        // TODO(zundel): make sure all state is reset
        populateAddressTags();
    } else if (arg.equals("pause") || arg.equals("resume")) {
        // ignore pause and resume entries.
    } else if (ClientConfig.isDebugMode()) {
        Logging.getLogger().logText("Ignoring profiler command: " + logEntries.join());
    }
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * A repeat entry is used to indicate that the command following is repeated
 * multiple times.//from  ww w .j av  a2 s .c om
 */
private void parseV8RepeatEntry(JsArrayString logEntries) {
    int numRepeats = Integer.parseInt(logEntries.get(1));
    // run the command after the first 2 arguments numRepeats times.
    logEntries.shift();
    logEntries.shift();
    for (int i = 0; i < numRepeats; ++i) {
        parseLogEntry(logEntries);
    }
}