예제 #1
0
  /**
   * Return a child XPreferences object with the key name NODENAME the node will be created if it
   * doesn't exist
   *
   * @param nodeName
   * @return
   */
  public XPreferences getChildNode(String nodeName) {
    // Get the children nodes
    if (xelem == null) return null;
    List<XMLPreferences_XElement> children = xelem.getXElements();

    // Loop though
    for (XMLPreferences_XElement child : children) {
      // if the child has the right name grab it
      String nName = child.getAtt(XPREFERENCES_NODENAMEKEY);
      if (!nodeName.equals(nName)) continue;

      // Create a new XPreferences set and return it
      XPreferences childPrefs = new XPreferences();
      childPrefs.setElement(child);
      return childPrefs;
    }

    // The node doesn't exist so create it
    XMLPreferences_XElement child =
        new XMLPreferences_XElement(XMLPreferences_XElement.ELEMENTNAME);
    child.setAtt(XPREFERENCES_NODENAMEKEY, nodeName);

    // Add the new element
    xelem.addXElement(child);

    // Return the new XPreferences
    XPreferences childPrefs = new XPreferences();
    childPrefs.setElement(child);
    return childPrefs;
  }
예제 #2
0
 @Override
 public Object clone() throws CloneNotSupportedException {
   if (xelem == null) return null;
   XMLPreferences_XElement cloneElem = (XMLPreferences_XElement) xelem.clone();
   XPreferences clone = new XPreferences();
   clone.setElement(cloneElem);
   return clone;
 }
예제 #3
0
  /**
   * Return the XPrefences parent node
   *
   * @return
   */
  public XPreferences getParent() {
    // IF the element is null return null
    if (xelem == null) return null;

    // Get the xelement parent
    XMLPreferences_XElement parent = xelem.getXElementParent();
    if (parent == null) return null;

    // Create a new XPreferences set and return it
    XPreferences parentPrefs = new XPreferences();
    parentPrefs.setElement(parent);
    return parentPrefs;
  }
예제 #4
0
  /**
   * Return a list of the child nodes
   *
   * @return
   */
  public List<XPreferences> getChildNodes() {
    // Get the children nodes
    if (xelem == null) return null;
    List<XMLPreferences_XElement> children = xelem.getXElements();

    // Make the result list
    List<XPreferences> result = new ArrayList<XPreferences>();

    // Loop though
    for (XMLPreferences_XElement child : children) {
      // Create a new XPreferences set and return it
      XPreferences childPrefs = new XPreferences();
      childPrefs.setElement(child);

      // Add node name to result list
      result.add(childPrefs);
    }

    return result;
  }