Exemplo n.º 1
0
 private List<Element> getSubElements(Element parent) {
   List<Element> subElements = new ArrayList<>();
   NodeList childNodes = parent.getChildNodes();
   for (int i = 0; i < childNodes.getLength(); i++) {
     Node childNode = childNodes.item(i);
     if (childNode.getNodeType() == Node.ELEMENT_NODE) {
       subElements.add((Element) childNode);
     }
   }
   return subElements;
 }
Exemplo n.º 2
0
 /**
  * @param ce
  * @return
  */
 private SortedMap<Integer, ComponentDef> buildFixedComponents(Element ce) {
   List<Element> fields = getSubElements(ce);
   SortedMap<Integer, ComponentDef> fieldDefs;
   if (fields.size() > 0) {
     fieldDefs = new TreeMap<>();
     int index = 1;
     for (Element e : fields) {
       ComponentDef def = buildComponent(e, true);
       fieldDefs.put(index++, def);
     }
   } else {
     throw new ConfigException("Composite components should have at least 1 sub field");
   }
   return fieldDefs;
 }
Exemplo n.º 3
0
    /**
     * @param ce
     * @return
     */
    private SortedMap<Integer, ComponentDef> buildTlvComponents(Element ce) {
      List<Element> fields = getSubElements(ce);
      SortedMap<Integer, ComponentDef> fieldDefs;
      if (fields.size() > 0) {
        fieldDefs = new TreeMap<>();
        for (Element e : fields) {
          Integer tag = Integer.valueOf(getMandatoryAttribute(e, ATTR_TAG));
          ComponentDef def = buildTlvComponent(e, getOrdinality(e));
          if (fieldDefs.containsKey(tag)) {
            throw new ConfigException(format("Duplicate component tag: %d", tag));
          }
          fieldDefs.put(tag, def);
        }
      } else {
        throw new ConfigException("Composite components should have at least 1 sub field");
      }

      return fieldDefs;
    }