示例#1
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;
 }
示例#2
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;
    }