public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer)
      throws UnableToCompleteException {
    // Generate instantiation (Vertical MenuBars require a ctor param).
    if (elem.hasAttribute("vertical")) {
      String vertical = elem.consumeBooleanAttribute("vertical");
      writer.setFieldInitializerAsConstructor(
          fieldName, writer.getOracle().findType(MenuBar.class.getName()), vertical);
    }

    // Parse children.
    for (XMLElement child : elem.consumeChildElements()) {
      // MenuBar can only contain MenuItem elements.
      {
        String ns = child.getNamespaceUri();
        String tagName = child.getLocalName();

        if (!elem.getNamespaceUri().equals(ns) || !tagName.equals(TAG_MENUITEM)) {
          writer.die(
              "In %s, only <%s:%s> are valid children", elem, elem.getPrefix(), TAG_MENUITEM);
        }
      }

      String itemFieldName = writer.parseElementToField(child);

      writer.addStatement("%1$s.addItem(%2$s);", fieldName, itemFieldName);
    }
  }
 private boolean hasTimeZone(XMLElement elem) {
   return elem.hasAttribute("timezone") || elem.hasAttribute("timezoneOffset");
 }