/** * * Process the {@link org.milyn.edisax.model.internal.SegmentGroup} in List and insert info into the {@link org.milyn.ejc.ClassModel}. * @param segmentGroup the {@link org.milyn.edisax.model.internal.SegmentGroup} to process. * @param parent the JClass 'owning' the {@link org.milyn.edisax.model.internal.SegmentGroup}. * @throws IllegalNameException when name found in a xmltag-attribute is a java keyword. */ private BindingConfig processSegmentGroup(SegmentGroup segmentGroup, BindingConfig parent) throws IllegalNameException { LOG.debug("Parsing SegmentGroup " + segmentGroup.getXmltag()); if(segmentGroup.getJavaName() == null) { throw new EJCException("The <segmentGroup> element can optionally omit the 'xmltag' attribute. However, this attribute must be present for EJC to work properly. It is omitted from one of the <segmentGroup> elements in this configuration."); } pushNode(segmentGroup); BindingConfig segGroupBinding = createChildAndConnectWithParent(parent, segmentGroup, segmentGroup.getMaxOccurs(), null); if (segmentGroup instanceof Segment) { Segment segment = (Segment) segmentGroup; processFields(segment.getFields(), segGroupBinding); } processSegmentGroups(segmentGroup.getSegments(), segGroupBinding); popNode(); return segGroupBinding; }
public ClassModel compile(Edimap edimap, String classPackage) throws IllegalNameException { model = new ClassModel(); model.setEdimap(edimap); SegmentGroup segmentGroup = edimap.getSegments(); pushNode(segmentGroup); JClass rootClass = new JClass(classPackage, EDIUtils.encodeClassName(segmentGroup.getJavaName()), getCurrentClassId()).setSerializable(); BindingConfig rootBeanConfig = new BindingConfig(getCurrentClassId(), getCurrentNodePath(), rootClass, null, null); //Insert root class into classModel and its' corresponding xmltag-value. model.addCreatedClass(rootClass); model.setRootBeanConfig(rootBeanConfig); LOG.debug("Added root class [" + rootClass + "] to ClassModel."); addWriteMethod(rootBeanConfig); processSegmentGroups(segmentGroup.getSegments(), rootBeanConfig); LOG.debug("Finished parsing edi-configuration. All segments are added to ClassModel."); LOG.debug("ClassModel contains " + model.getCreatedClasses().size() + " classes."); // Attach the createdClassesByNode map... so we can use them if they // are common classes in a model set... model.setClassesByNode(createdClassesByNode); model.setReferencedClasses(injectedCommonTypes.values()); popNode(); if(addEDIMessageAnnotation) { model.getRootBeanConfig().getBeanClass().getAnnotationTypes().add(new JType(EDIMessage.class)); } return model; }