List of usage examples for com.google.gwt.coreext.client DataBag getJSObjectProperty
public static final native <T extends JavaScriptObject> T getJSObjectProperty(JavaScriptObject obj, String prop) ;
From source file:com.google.speedtracer.breaky.client.DumpValidator.java
License:Apache License
public final JsonSchema getSchema(String name) { return DataBag.getJSObjectProperty(schemas, name).cast(); }
From source file:com.google.speedtracer.breaky.client.DumpValidator.java
License:Apache License
/** * Validate a Speedtracer dump object.//from w ww . j a v a2 s. c o m * * @param obj a speedtracer dump object to be validated * @return {@link JsonSchemaResults} object indicating that the entire object * is valid or containing the error that caused it to be invalid. */ public JsonSchemaResults validate(JavaScriptObject obj) { JsonSchema concreteSchema = getSchema(obj); if (concreteSchema == null) { return JsonSchemaResults.create("", "No schema found for " + obj.toString()); } JsonSchemaResults results = JsonSchemaValidator.validate(obj, concreteSchema); if (!results.isValid()) { return results; } if (DataBag.hasOwnProperty(obj, "children")) { JsArray<JavaScriptObject> children = DataBag.getJSObjectProperty(obj, "children"); for (int i = 0; i < children.length() && results.isValid(); i++) { // TODO(conroy): make child validation incremental? results = this.validate(children.get(i)); } } return results; }
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. *///w ww . ja v a2 s .co m 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); } } } }