private Element getElement(Document d, InputNode node) throws DOMException, Exception { Element e = d.createElementNS(node.getReference(), node.getName()); for (String attrName : node.getAttributes()) { if (!attrName.equals("xmlns")) e.setAttribute(attrName, node.getAttribute(attrName).getValue()); } InputNode nextNode = node.getNext(); while (nextNode != null) { e.appendChild(getElement(d, nextNode)); nextNode = node.getNext(); } return e; }
public Party read(InputNode node) throws Exception { Person contact = serializer.read(Person.class, node); InputNode typeAttribute = node.getAttribute("type"); if (typeAttribute != null) { contact.setType(typeAttribute.getValue()); } if (contact.getType().equals("Company")) { Company company = new Company(); company.setName(contact.getName()); company.setAvatarUrl(contact.getAvatarUrl()); company.setBackground(contact.getBackground()); company.setContactData(contact.getContactData()); company.setType(contact.getType()); return company; } else { return contact; } }