Ignore:
Timestamp:
2004-08-20T13:59:02+12:00 (20 years ago)
Author:
mdewsnip
Message:

Moved clear() and setValue() functions from MSMUtils into XMLTools. Moved NS_SEP string from MSMUtils into StaticStrings.

Location:
trunk/gli/src/org/greenstone/gatherer/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java

    r7545 r8015  
    3737    static final public char   FORWARDSLASH_CHAR                          = '/';
    3838    static final public char   NEW_LINE_CHAR                              = '\n';
     39    static final public char   NS_SEP                                     = '.';
    3940    static final public char   OPENBRACKET_CHAR                           = '[';
    4041    static final public char   PIPE_CHAR                                  = '|';
  • trunk/gli/src/org/greenstone/gatherer/util/XMLTools.java

    r8014 r8015  
    1313public class XMLTools
    1414{
     15    /** Remove all of the child nodes from a certain node. */
     16    static final public void clear(Node node)
     17    {
     18    while (node.hasChildNodes()) {
     19        node.removeChild(node.getFirstChild());
     20    }
     21    }
     22
     23
    1524    static public ArrayList getChildElementsByTagName(Element parent_element, String element_name)
    1625    {
     
    8897
    8998
     99    /** Set the #text node value of some element.
     100     * @param element the Element whose value we wish to set
     101     * @param value the new value for the element as a String
     102     * Soon to be deprecated!
     103     */
     104    static final public void setValue(Element element, String value) {
     105    // Remove any existing child node(s)
     106    clear(element);
     107    // Add new text node.
     108    if (value != null) {
     109        element.appendChild(element.getOwnerDocument().createTextNode(value));
     110    }
     111    }
     112
     113
    90114    /** Parse an XML document from a given file */
    91115    static public Document parseXMLFile(File xml_file)
Note: See TracChangeset for help on using the changeset viewer.