Exemplo n.º 1
0
 private void save() {
   try {
     Document doc = XmlUtil.getDocument();
     Element root = doc.createElement("profiles");
     doc.appendChild(root);
     Enumeration<String> keys = table.keys();
     while (keys.hasMoreElements()) {
       table.get(keys.nextElement()).appendTo(root);
     }
     FileUtil.setText(new File(filename), FileUtil.utf8, XmlUtil.toString(doc));
   } catch (Exception ignore) {
   }
 }
Exemplo n.º 2
0
 private void load() {
   File file = new File(filename);
   if (file.exists()) {
     try {
       Document doc = XmlUtil.getDocument(file);
       Element root = doc.getDocumentElement();
       Node child = root.getFirstChild();
       while (child != null) {
         if (child.getNodeType() == Node.ELEMENT_NODE) {
           Profile p = new Profile((Element) child);
           table.put(p.name, p);
         }
         child = child.getNextSibling();
       }
     } catch (Exception ignore) {
     }
   }
 }
Exemplo n.º 3
0
 public void delete(String name) {
   table.remove(name);
   save();
 }
Exemplo n.º 4
0
 public void add(Profile profile) {
   table.put(profile.name, profile);
   save();
 }
Exemplo n.º 5
0
 public int size() {
   return table.size();
 }
Exemplo n.º 6
0
 public Profile getProfile(String name) {
   Profile p = table.get(name);
   if (p == null) p = new Profile(name);
   return p;
 }
Exemplo n.º 7
0
 public String[] getNames() {
   String[] names = new String[table.size()];
   names = table.keySet().toArray(names);
   Arrays.sort(names);
   return names;
 }