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;
  }
Ejemplo n.º 2
0
  /**
   * This method is used to read the key value from the node. The value read from the node is
   * resolved using the template filter. If the key value can not be found according to the
   * annotation attributes then null is assumed and the node is valid.
   *
   * @param node this is the node to read the key value from
   * @param key this is the name of the key wrapper XML element
   * @return this returns the value deserialized from the node
   */
  private boolean validate(InputNode node, String key) throws Exception {
    String name = style.getElement(key);
    InputNode next = node.getNext(name);
    Class expect = type.getType();

    if (next == null) {
      return true;
    }
    if (next.isEmpty()) {
      return true;
    }
    return root.validate(next, expect);
  }
Ejemplo n.º 3
0
  /**
   * This method is used to read the key value from the node. The value read from the node is
   * resolved using the template filter. If the key value can not be found according to the
   * annotation attributes then null is assumed and returned.
   *
   * @param node this is the node to read the key value from
   * @param key this is the name of the key wrapper XML element
   * @return this returns the value deserialized from the node
   */
  private Object read(InputNode node, String key) throws Exception {
    String name = style.getElement(key);
    Class expect = type.getType();

    if (name != null) {
      node = node.getNext(name);
    }
    if (node == null) {
      return null;
    }
    if (node.isEmpty()) {
      return null;
    }
    return root.read(node, expect);
  }
 public Person read(InputNode node) throws Exception {
   return serializer.read(PersonDelegate.class, node.getNext());
 }