예제 #1
0
 public static int parseValue(int def, XMLHelper node) {
   try {
     return Integer.parseInt(node.getValue());
   } catch (Exception e) {
     node.setValue(def);
     return def;
   }
 }
예제 #2
0
 public static Color parseValue(Color def, XMLHelper node) {
   try {
     return Color.decode(node.getValue());
   } catch (Exception e) {
     node.setValue(def);
     return def;
   }
 }
예제 #3
0
 public static float parseValue(float def, XMLHelper node) {
   try {
     return Float.parseFloat(node.getValue());
   } catch (Exception e) {
     node.setValue(def);
     return def;
   }
 }
예제 #4
0
 public XMLHelper createSubNode(String subnode) {
   int pos = subnode.lastIndexOf(DELIM);
   if (pos >= 0) {
     XMLHelper helper = getSubNode(subnode.substring(0, pos));
     return helper.createSubNode(subnode.substring(pos + 1));
   } else {
     return new XMLHelper(
         (Element) element.appendChild(element.getOwnerDocument().createElement(subnode)), true);
   }
 }
예제 #5
0
 public static boolean parseValue(boolean def, XMLHelper node) {
   String value = node.getValue().toUpperCase();
   if ("TRUE".compareTo(value) == 0) {
     return true;
   } else if ("FALSE".compareTo(value) == 0) {
     return false;
   } else {
     node.setValue(def);
     return def;
   }
 }
예제 #6
0
 public String getValue(String subnode, String def) {
   XMLHelper helper = getSubNode(subnode);
   // To account for the case where the default is not a blank string, but we may want to
   // eventually set the setting to one
   // We don't do this if we are doing getValue() on this node, because we should know if its new
   // or not
   if (helper.getIsNewNode()) {
     helper.setValue(def);
     return def;
   } else {
     return helper.getValue();
   }
 }
예제 #7
0
 public XMLHelper getSubNodeByName(String subnode, String name, String namenode) {
   XMLHelper[] list = getSubNodeList(subnode);
   if (list.length != 0) {
     for (int i = 0; i < list.length; i++) {
       if (list[i].getSubNode(namenode).getValue().compareTo(name) == 0) {
         return list[i];
       }
     }
   }
   XMLHelper node = createSubNode(subnode);
   node.createSubNode(namenode).setValue(name);
   return node;
 }
예제 #8
0
 public void deleteSubNode(String subnode) {
   int pos = subnode.lastIndexOf(DELIM);
   if (pos >= 0) {
     XMLHelper helper = getSubNode(subnode.substring(0, pos));
     helper.deleteSubNode(subnode.substring(pos + 1));
   } else {
     NodeList list = getImediateElementsByTagName(subnode);
     try {
       element.removeChild(list.item(0));
     } catch (Exception e) {
     }
   }
 }
예제 #9
0
 public XMLHelper[] getSubNodeList(String subnode) {
   int pos = subnode.lastIndexOf(DELIM);
   if (pos >= 0) {
     XMLHelper helper = getSubNode(subnode.substring(0, pos));
     return helper.getSubNodeList(subnode.substring(pos + 1));
   } else {
     NodeList list = getImediateElementsByTagName(subnode);
     XMLHelper[] results = new XMLHelper[list.getLength()];
     int length = list.getLength();
     for (int i = 0; i < length; i++) {
       results[i] = new XMLHelper((Element) list.item(i));
     }
     return results;
   }
 }
예제 #10
0
 public void deleteSubNodes(String subnode) {
   int pos = subnode.lastIndexOf(DELIM);
   if (pos >= 0) {
     XMLHelper helper = getSubNode(subnode.substring(0, pos));
     helper.deleteSubNodes(subnode.substring(pos + 1));
   } else {
     NodeList list = getImediateElementsByTagName(subnode);
     int length = list.getLength();
     for (int i = 0; i < length; i++) {
       try {
         element.removeChild(list.item(i));
       } catch (Exception e) {
       }
     }
   }
 }