private Widget createWidget(JSONObject elem,View view) throws ScreenConfigException {
  if (!elem.has("id")) {
    throw new CruxGeneratorException("The id attribute is required for CRUX Widgets. " + "On view [" + view.getId() + "], there is an widget of type ["+ elem.optString("_type")+ "] without id.");
  }
  String widgetId;
  try {
    widgetId=elem.getString("id");
  }
 catch (  JSONException e) {
    throw new CruxGeneratorException("The id attribute is required for CRUX Widgets. " + "On view [" + view.getId() + "], there is an widget of type ["+ elem.optString("_type")+ "] without a valid id.");
  }
  Widget widget=view.getWidget(widgetId);
  if (widget != null) {
    throw new ScreenConfigException("Error creating widget. Duplicated identifier [" + widgetId + "].");
  }
  widget=newWidget(elem,widgetId);
  if (widget == null) {
    throw new ScreenConfigException("Can not create widget [" + widgetId + "]. Verify the widget type.");
  }
  view.addWidget(widget);
  createWidgetChildren(elem,view,widgetId,widget);
  return widget;
}

private Widget createWidget ( JSONObject elem , View view ) throws ScreenConfigException { if ( ! elem . has ( "id" ) ) { throw new CruxGeneratorException ( "The id attribute is required for CRUX Widgets. " + "On view [" + view . getId ( ) + "], there is an widget of type [" + elem . optString ( "_type" ) + "] without id." ) ; } String widgetId ; try { widgetId = elem . getString ( "id" ) ; } catch ( JSONException e ) { throw new CruxGeneratorException ( "The id attribute is required for CRUX Widgets. " + "On view [" + view . getId ( ) + "], there is an widget of type [" + elem . optString ( "_type" ) + "] without a valid id." ) ; } Widget widget = view . getWidget ( widgetId ) ; if ( widget != null ) { throw new ScreenConfigException ( "Error creating widget. Duplicated identifier [" + widgetId + "]." ) ; } widget = newWidget ( elem , widgetId ) ; if ( widget == null ) { throw new ScreenConfigException ( "Can not create widget [" + widgetId + "]. Verify the widget type." ) ; } view . addWidget ( widget ) ; createWidgetChildren ( elem , view , widgetId , widget ) ; return widget ; }
creates a widget based in its metadata information .
