Advertisement
X39

.x39 settings usage example 1

X39
Apr 27th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1.     public static void ExampleUsage1()
  2.     {
  3.         File file = new File("settings.x39");
  4.         ISettingsFileHandler handler = new SettingsFileHandler_1_0(file);
  5.         SettingsDocument doc = null;
  6.         try {
  7.             doc = handler.load();
  8.         } catch (ExceptionSettingsParsing e) {
  9.             e.printStackTrace();
  10.         } catch (Exception e) {
  11.             e.printStackTrace();
  12.         }
  13.         if(doc == null)
  14.             return;
  15.         SettingsNode rootNode = doc.getRootNode();
  16.         for(SettingsNode node : rootNode.getChilds())
  17.         {
  18.             System.out.println(node.getName() + "[" + node.getChilds().length + "]:");
  19.             for(SettingsOption opt : node.boundOptions)
  20.             {
  21.                 System.out.println("\t" + opt.getName() + " " + opt.getValue());
  22.             }
  23.         }
  24.  
  25.         SettingsNode node1_1 = new SettingsNode("Node1.2");
  26.         node1_1.boundOptions.add(new SettingsOption("Option1", "value1"));
  27.         node1_1.boundOptions.add(new SettingsOption("Option2", "value2"));
  28.         SettingsNode node1_2 = new SettingsNode("Node1.1");
  29.         node1_2.boundOptions.add(new SettingsOption("Option1", "value1"));
  30.         node1_2.boundOptions.add(new SettingsOption("Option2", "value2"));
  31.        
  32.         SettingsNode node = new SettingsNode("Node1");
  33.         node.addChild(node1_1, node1_2);
  34.         node.boundOptions.add(new SettingsOption("Option1", "value1"));
  35.         node.boundOptions.add(new SettingsOption("Option2", "value2"));
  36.        
  37.         rootNode.addChild(node);
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement