public Element createElement(org.w3c.dom.Element element, Element parent) throws
      InvalidInputException {
    String tag = element.getNodeName();

    if (Header.isHeaderElement(tag)) {
      return new Header(parent, tag);
    }

    switch (tag) {
      case Chime.MESSAGEML_TAG:
        validateFormat(tag);
        return new Chime(parent, FormatEnum.MESSAGEML);

      case Chime.PRESENTATIONML_TAG:
        return new Chime(parent, FormatEnum.PRESENTATIONML);

      case Paragraph.MESSAGEML_TAG:
        return new Paragraph(parent);

      case LineBreak.MESSAGEML_TAG:
        return new LineBreak(parent);

      case HorizontalRule.MESSAGEML_TAG:
        return new HorizontalRule(parent);

      case Span.MESSAGEML_TAG:
        switch (element.getAttribute(CLASS_ATTR)) {
          case Entity.PRESENTATIONML_CLASS:
            return createEntity(element, parent);
          default:
            return new Span(parent);
        }

      case Div.MESSAGEML_TAG:
        switch (element.getAttribute(CLASS_ATTR)) {
          case Entity.PRESENTATIONML_CLASS:
            return createEntity(element, parent);
          case Card.PRESENTATIONML_CLASS:
            element.removeAttribute(CLASS_ATTR);
            return new Card(parent, FormatEnum.PRESENTATIONML);
          case CardBody.PRESENTATIONML_CLASS:
            element.removeAttribute(CLASS_ATTR);
            return new CardBody(parent, FormatEnum.PRESENTATIONML);
          case CardHeader.PRESENTATIONML_CLASS:
            element.removeAttribute(CLASS_ATTR);
            return new CardHeader(parent, FormatEnum.PRESENTATIONML);
          default:
            return new Div(parent);
        }

      case Bold.MESSAGEML_TAG:
        return new Bold(parent);

      case Italic.MESSAGEML_TAG:
        return new Italic(parent);

      case Preformatted.MESSAGEML_TAG:
        return new Preformatted(parent);

      case HashTag.MESSAGEML_TAG:
        validateFormat(tag);
        return new HashTag(parent, ++index);

      case CashTag.MESSAGEML_TAG:
        validateFormat(tag);
        return new CashTag(parent, ++index);

      case Mention.MESSAGEML_TAG:
        validateFormat(tag);
        return new Mention(parent, ++index, dataProvider);

      case Link.MESSAGEML_TAG:
        return new Link(parent, dataProvider);

      case Image.MESSAGEML_TAG:
        return new Image(parent);

      case BulletList.MESSAGEML_TAG:
        return new BulletList(parent);

      case OrderedList.MESSAGEML_TAG:
        return new OrderedList(parent);

      case ListItem.MESSAGEML_TAG:
        return new ListItem(parent);

      case Table.MESSAGEML_TAG:
        return new Table(parent);

      case TableHeader.MESSAGEML_TAG:
        return new TableHeader(parent);

      case TableBody.MESSAGEML_TAG:
        return new TableBody(parent);

      case TableFooter.MESSAGEML_TAG:
        return new TableFooter(parent);

      case TableRow.MESSAGEML_TAG:
        return new TableRow(parent);

      case TableHeaderCell.MESSAGEML_TAG:
        return new TableHeaderCell(parent);

      case TableCell.MESSAGEML_TAG:
        return new TableCell(parent);

      case Card.MESSAGEML_TAG:
        validateFormat(tag);
        return new Card(parent, FormatEnum.MESSAGEML);

      case Code.MESSAGEML_TAG:
        return new Code(parent);

      case CardHeader.MESSAGEML_TAG:
        validateFormat(tag);
        return new CardHeader(parent, FormatEnum.MESSAGEML);

      case CardBody.MESSAGEML_TAG:
        validateFormat(tag);
        return new CardBody(parent, FormatEnum.MESSAGEML);

      case Emoji.MESSAGEML_TAG:
        return new Emoji(parent, ++index);

      case Form.MESSAGEML_TAG:
        return new Form(parent);

      case Button.MESSAGEML_TAG:
        return new Button(parent);

      default:
        throw new InvalidInputException("Invalid MessageML content at element \"" + tag + "\"");
    }
  }
public Element createElement ( org . w3c . dom . Element element , Element parent ) throws InvalidInputException { String tag = element . getNodeName ( ) ; if ( Header . isHeaderElement ( tag ) ) { return new Header ( parent , tag ) ; } switch ( tag ) { case Chime . MESSAGEML_TAG : validateFormat ( tag ) ; return new Chime ( parent , FormatEnum . MESSAGEML ) ; case Chime . PRESENTATIONML_TAG : return new Chime ( parent , FormatEnum . PRESENTATIONML ) ; case Paragraph . MESSAGEML_TAG : return new Paragraph ( parent ) ; case LineBreak . MESSAGEML_TAG : return new LineBreak ( parent ) ; case HorizontalRule . MESSAGEML_TAG : return new HorizontalRule ( parent ) ; case Span . MESSAGEML_TAG : switch ( element . getAttribute ( CLASS_ATTR ) ) { case Entity . PRESENTATIONML_CLASS : return createEntity ( element , parent ) ; default : return new Span ( parent ) ; } case Div . MESSAGEML_TAG : switch ( element . getAttribute ( CLASS_ATTR ) ) { case Entity . PRESENTATIONML_CLASS : return createEntity ( element , parent ) ; case Card . PRESENTATIONML_CLASS : element . removeAttribute ( CLASS_ATTR ) ; return new Card ( parent , FormatEnum . PRESENTATIONML ) ; case CardBody . PRESENTATIONML_CLASS : element . removeAttribute ( CLASS_ATTR ) ; return new CardBody ( parent , FormatEnum . PRESENTATIONML ) ; case CardHeader . PRESENTATIONML_CLASS : element . removeAttribute ( CLASS_ATTR ) ; return new CardHeader ( parent , FormatEnum . PRESENTATIONML ) ; default : return new Div ( parent ) ; } case Bold . MESSAGEML_TAG : return new Bold ( parent ) ; case Italic . MESSAGEML_TAG : return new Italic ( parent ) ; case Preformatted . MESSAGEML_TAG : return new Preformatted ( parent ) ; case HashTag . MESSAGEML_TAG : validateFormat ( tag ) ; return new HashTag ( parent , ++ index ) ; case CashTag . MESSAGEML_TAG : validateFormat ( tag ) ; return new CashTag ( parent , ++ index ) ; case Mention . MESSAGEML_TAG : validateFormat ( tag ) ; return new Mention ( parent , ++ index , dataProvider ) ; case Link . MESSAGEML_TAG : return new Link ( parent , dataProvider ) ; case Image . MESSAGEML_TAG : return new Image ( parent ) ; case BulletList . MESSAGEML_TAG : return new BulletList ( parent ) ; case OrderedList . MESSAGEML_TAG : return new OrderedList ( parent ) ; case ListItem . MESSAGEML_TAG : return new ListItem ( parent ) ; case Table . MESSAGEML_TAG : return new Table ( parent ) ; case TableHeader . MESSAGEML_TAG : return new TableHeader ( parent ) ; case TableBody . MESSAGEML_TAG : return new TableBody ( parent ) ; case TableFooter . MESSAGEML_TAG : return new TableFooter ( parent ) ; case TableRow . MESSAGEML_TAG : return new TableRow ( parent ) ; case TableHeaderCell . MESSAGEML_TAG : return new TableHeaderCell ( parent ) ; case TableCell . MESSAGEML_TAG : return new TableCell ( parent ) ; case Card . MESSAGEML_TAG : validateFormat ( tag ) ; return new Card ( parent , FormatEnum . MESSAGEML ) ; case Code . MESSAGEML_TAG : return new Code ( parent ) ; case CardHeader . MESSAGEML_TAG : validateFormat ( tag ) ; return new CardHeader ( parent , FormatEnum . MESSAGEML ) ; case CardBody . MESSAGEML_TAG : validateFormat ( tag ) ; return new CardBody ( parent , FormatEnum . MESSAGEML ) ; case Emoji . MESSAGEML_TAG : return new Emoji ( parent , ++ index ) ; case Form . MESSAGEML_TAG : return new Form ( parent ) ; case Button . MESSAGEML_TAG : return new Button ( parent ) ; default : throw new InvalidInputException ( "Invalid MessageML content at element \"" + tag + "\"" ) ; } }
Create a MessageML element based on the DOM element's name and attributes.