Ejemplo n.º 1
0
 private void setAllBuildModules() {
   File modulsoption = new File(this.modulePath + File.separator + "build.json");
   if (modulsoption.exists()) {
     try {
       Jsonx x = Jsonx.create(modulsoption);
       x.each(
           new JsonEach(this) {
             @Override
             public boolean each(String key, Jsonx json) {
               try {
                 JmoduleContainer ths = (JmoduleContainer) this.arguments[0];
                 ths.map.put(key, json.toHashMap());
               } catch (Exception ex) {
                 ex.printStackTrace();
               }
               return false;
             }
           });
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
Ejemplo n.º 2
0
 public void save() throws Exception {
   HashMap<String, Object> map = new HashMap<String, Object>();
   if (this.map.size() > 0) {
     for (Entry<String, HashMap<String, Object>> x : this.map.entrySet()) {
       if (x.getValue() != null) {
         HashMap<String, Object> mapx = new HashMap<String, Object>();
         for (Entry<String, Object> n : x.getValue().entrySet()) {
           mapx.put(n.getKey(), n.getValue().toString());
         }
         map.put(x.getKey(), mapx);
       }
     }
   }
   Jsonx.create(map).toFile(this.modulePath + File.separator + "build.json");
 }
Ejemplo n.º 3
0
    public String getOptionString() {
      try {
        return Jsonx.create(option)
            .each(
                new JsonEachArray(this.optionMapping) {
                  @Override
                  public boolean each(int index, Jsonx json) {
                    HashMap<String, Object> xt = (HashMap<String, Object>) this.arguments[0];
                    try {
                      String key = json.get("name").toString();
                      json.set("value", xt.get(key));

                    } catch (Exception ex) {
                      ex.printStackTrace();
                    }
                    return false;
                  }
                })
            .toString();
      } catch (Exception ex) {
        ex.printStackTrace();
        return null;
      }
    }
Ejemplo n.º 4
0
 private void setAllModules() {
   File dir = new File(this.modulePath);
   File file[] = dir.listFiles();
   for (File file1 : file) {
     if (file1.isDirectory()) {
       String moduleName = file1.getName();
       String moduleOptionPath =
           modulePath + File.separator + moduleName + File.separator + moduleName + ".json";
       File optionFile = new File(moduleOptionPath);
       if (optionFile.exists()) {
         try {
           Jsonx json = Jsonx.create(new File(moduleOptionPath));
           JpageModule module = new JpageModule(json.get("name").toString());
           module.desc = json.get("desc").toString();
           module.img = json.get("img").toString();
           module.name = json.get("name").toString();
           module.title = json.get("title").toString();
           module.type = json.get("type").toString();
           module.version = json.get("version").toString();
           module.option = json.get("option").toString();
           module.single = json.hasKey("single") ? json.get("single").toBoolean() : false;
           module.editable = json.hasKey("editable") ? json.get("editable").toBoolean() : true;
           module.fixed = json.hasKey("fixed") ? json.get("fixed").toBoolean() : false;
           final HashMap<String, Object> map = new HashMap<String, Object>();
           json.get("option")
               .each(
                   new JsonEachArray() {
                     @Override
                     public boolean each(int index, Jsonx json) {
                       try {
                         map.put(json.get("name").toString(), json.get("value"));
                       } catch (Exception ex) {
                         ex.printStackTrace();
                       }
                       return false;
                     }
                   });
           module.optionMapping = map;
           this.defaultMap.put(moduleName, module);
         } catch (Exception ex) {
           ex.printStackTrace();
         }
       }
     }
   }
 }