Пример #1
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);
  }
Пример #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 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);
  }