/** * @param f : field * @param parent : parent */ private void process(Field f, MessageElement parent) { Location loc = f.location(); Req req = f.req(); Range card = Util.getOption(req.cardinality()); String rep = f.toString(); MessageElementData data = new MessageElementData( loc.uidPath(), loc.desc(), req.usage().toString(), card.min(), card.max(), loc.line(), loc.column(), -1, f.position(), f.instance(), null, FIELD); MessageElement el = new MessageElement(NODE_FIELD, data, parent); if (f instanceof SimpleField) { SimpleField s = (SimpleField) f; MessageElementData value = new MessageElementData( loc.uidPath(), loc.desc(), req.usage().toString(), card.min(), card.max(), loc.line(), loc.column(), -1, f.position(), f.instance(), s.value().raw(), FIELD); new MessageElement("value", value, el); } else { ComplexField c = (ComplexField) f; List<Component> children = c.children(); if (children != null && !children.isEmpty()) { Iterator<Component> it = children.iterator(); while (it.hasNext()) { process(it.next(), el); } } } }
/** * @param e * @param parentName * @param parent */ private void process(SegOrGroup e, String parentName, MessageElement parent) { if (e == null) { return; } if (e instanceof Segment) { Segment s = (Segment) e; Location loc = s.location(); Req req = s.req(); Range card = Util.getOption(req.cardinality()); MessageElementData data = new MessageElementData( loc.uidPath(), loc.desc(), req.usage().toString(), card.min(), card.max(), loc.line(), loc.column(), -1, s.position(), s.instance(), null, SEGMENT); MessageElement el = new MessageElement(NODE_SEGMENT, data, parent); List<Field> children = s.children(); if (children != null && !children.isEmpty()) { Iterator<Field> it = children.iterator(); while (it.hasNext()) { process(it.next(), el); } } } else if (e instanceof Group) { Group g = (Group) e; List<SegOrGroup> children = g.children(); if (children != null && !children.isEmpty()) { scala.collection.Iterator<SegOrGroup> it = children.iterator(); while (it.hasNext()) { process(it.next(), "", parent); } } } }