Пример #1
0
 public void readFromXml(Element config) throws FacetConfigurationFormatException {
   List<ModelRootDescriptor> descriptors = new ArrayList<ModelRootDescriptor>();
   for (Element ch : XmlUtil.children(config, "option")) {
     String optionName = ch.getAttributeValue("name");
     if ("UUID".equals(optionName)) {
       this.UUID = ch.getAttributeValue(OPT_VALUE);
     } else if ("generatorOutputPath".equals(optionName)) {
       this.generatorOutputPath = ch.getAttributeValue(OPT_VALUE);
     } else if ("modelRoots".equals(optionName)) {
       ModelRootDescriptor[] cache = new ModelRootDescriptor[2];
       for (ModelRoot root : SetSequence.fromSet(readModelRoots(XmlUtil.first(ch, "set")))) {
         Memento m = new MementoImpl();
         root.save(m);
         ModelRootDescriptor descr =
             ModuleDescriptorPersistence.createDescriptor(null, m, null, cache);
         if (descr != null) {
           descriptors.add(descr);
         }
       }
     } else if ("usedLanguages".equals(optionName)) {
       this.usedLanguages = readArray(XmlUtil.first(ch, "array"));
     } else if ("useModuleSourceFolder".equals(optionName)) {
       this.useModuleSourceFolder = "true".equals(ch.getAttributeValue(OPT_VALUE));
     } else if ("useTransientOutputFolder".equals(optionName)) {
       this.useTransientOutputFolder = "true".equals(ch.getAttributeValue(OPT_VALUE));
     }
   }
   for (Element modelRoot : XmlUtil.children(XmlUtil.first(config, "modelRoots"), "modelRoot")) {
     Element settings = XmlUtil.first(modelRoot, "settings");
     Memento m = new MementoImpl();
     if (settings != null) {
       MementoUtil.readMemento(m, settings);
     }
     descriptors.add(new ModelRootDescriptor(modelRoot.getAttributeValue("type"), m));
   }
   rootDescriptors = descriptors.toArray(new ModelRootDescriptor[descriptors.size()]);
 }