Changeset 10006


Ignore:
Timestamp:
2005-06-03T14:36:41+12:00 (19 years ago)
Author:
mdewsnip
Message:

Moved Utility.parse to XMLTools.parseXMLFile, as part of tidying up the Utility class.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
16 edited

Legend:

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

    r9869 r10006  
    159159    // Create a new config from the default configuration file from our xml library
    160160    if (general_config == null) {
    161         general_config = Utility.parse(TEMPLATE_CONFIG_XML, true);
     161        general_config = XMLTools.parseXMLFile(TEMPLATE_CONFIG_XML, true);
    162162        just_updated_config_xml_file = true;
    163163    }
     
    205205    {
    206206    // Check if the configuration file actually needs updating by looking at the version numbers
    207     Document new_document = Utility.parse(TEMPLATE_CONFIG_XML, true);
     207    Document new_document = XMLTools.parseXMLFile(TEMPLATE_CONFIG_XML, true);
    208208    Document old_document = XMLTools.parseXMLFile(config_xml_file);
    209209
  • trunk/gli/src/org/greenstone/gatherer/ServletConfiguration.java

    r9828 r10006  
    8787   
    8888    this.mappings = new HashMap();
    89     Document web_config = Utility.parse(web_xml.getAbsolutePath(), false);
     89    Document web_config = XMLTools.parseXMLFile(web_xml.getAbsolutePath(), false);
    9090       
    9191    NodeList servlet_mappings = web_config.getElementsByTagName("servlet-mapping");
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java

    r9908 r10006  
    326326    String collect_config_name = collect_config_file.getName();
    327327    if(collect_config_name.equals(COLLECTCONFIGURATION_XML)) {
    328         // Parse with Utility but don't use class loader
    329328        document = XMLTools.parseXMLFile(collect_config_file);
    330329    }
    331330    // Otherwise if this is a legacy collect.cfg file then read in the template and send to magic parser
    332331    else if(collect_config_name.equals(COLLECT_CFG)) {
    333         document = Utility.parse(PSEUDO_COLLECTCONFIGURATION_XML, true);
     332        document = XMLTools.parseXMLFile("xml/CollectionConfig.xml", true);
    334333        parse(collect_config_file);
    335334    }
  • trunk/gli/src/org/greenstone/gatherer/cdm/LanguageManager.java

    r9564 r10006  
    4444import org.greenstone.gatherer.gui.GLIButton;
    4545import org.greenstone.gatherer.util.Utility;
     46import org.greenstone.gatherer.util.XMLTools;
    4647import org.w3c.dom.*;
    4748
     
    5354    extends DOMProxyListModel {
    5455
    55     static public Document LANGUAGES_DOCUMENT = Utility.parse("xml/languages.xml", true);
     56    static public Document LANGUAGES_DOCUMENT = XMLTools.parseXMLFile("xml/languages.xml", true);
    5657
    5758    static final private Dimension COMPONENT_SIZE = new Dimension(125,25);
  • trunk/gli/src/org/greenstone/gatherer/collection/Collection.java

    r9166 r10006  
    9696    // If that fails load the default settings for a collection.
    9797    if(document == null) {
    98         document = Utility.parse(COLLECTION_XML_TEMPLATE, true);
     98        document = XMLTools.parseXMLFile(COLLECTION_XML_TEMPLATE, true);
    9999    }
    100100    if (document == null) {
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r9864 r10006  
    452452    {
    453453    try {
    454         Document default_lockfile = Utility.parse("xml/" + LOCK_FILE, true);
     454        Document default_lockfile = XMLTools.parseXMLFile("xml/" + LOCK_FILE, true);
    455455        String user_name = System.getProperty("user.name");
    456456        Element person_element = (Element) XMLTools.getNodeFromNamed(default_lockfile.getDocumentElement(), "User");
  • trunk/gli/src/org/greenstone/gatherer/collection/ScriptOptions.java

    r9135 r10006  
    5757        // replace .pl with .xml to get the template name
    5858        String template_name = script_name.replaceAll("\\.pl$", "\\.xml");
    59         Document document = Utility.parse("xml/"+template_name, true);
     59        Document document = XMLTools.parseXMLFile("xml/" + template_name, true);
    6060        if (document != null) {
    6161            arguments_element = document.getDocumentElement();
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java

    r9943 r10006  
    6666import org.greenstone.gatherer.util.Codec;
    6767import org.greenstone.gatherer.util.Utility;
     68import org.greenstone.gatherer.util.XMLTools;
    6869import org.w3c.dom.*;
    6970
     
    716717    private Vector attributeLists = null;     
    717718
    718     org.w3c.dom.Document lang = Utility.parse(Configuration.gsdl_path + File.separator + "gli" + File.separator + "classes" + File.separator + "xml" + File.separator + "languages.xml", false);
     719    org.w3c.dom.Document lang = XMLTools.parseXMLFile(Configuration.gsdl_path + File.separator + "gli" + File.separator + "classes" + File.separator + "xml" + File.separator + "languages.xml", false);
    719720   
    720721    /** Constructor. */
  • trunk/gli/src/org/greenstone/gatherer/gems/MetadataSet.java

    r9855 r10006  
    8383   
    8484    this.file = new File(metadata_template);
    85     this.document = Utility.parse(metadata_template, true);
     85    this.document = XMLTools.parseXMLFile(metadata_template, true);
    8686
    8787    init(true); // use class loader
  • trunk/gli/src/org/greenstone/gatherer/gui/HelpFrame.java

    r8579 r10006  
    4848import org.greenstone.gatherer.util.StaticStrings;
    4949import org.greenstone.gatherer.util.Utility;
     50import org.greenstone.gatherer.util.XMLTools;
    5051import org.w3c.dom.*;
    5152
     
    162163        try {
    163164        String help_index = Utility.getHelpFolder() + StaticStrings.HELP_INDEX_FILENAME;
    164         Document document = Utility.parse(help_index,true);
     165        Document document = XMLTools.parseXMLFile(help_index, true);
    165166
    166167        // Traverse the document hierarchy, building a tree representing its structure
  • trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java

    r9887 r10006  
    4848import org.greenstone.gatherer.util.CheckListEntry;
    4949import org.greenstone.gatherer.util.StaticStrings;
    50 import org.greenstone.gatherer.util.Utility;
     50import org.greenstone.gatherer.util.XMLTools;
    5151import org.w3c.dom.*;
    5252
     
    503503
    504504    // Read all the warnings from the general xml/config.xml file, and their values from the user config.xml file
    505     Document general_config_xml_file_document = Utility.parse("xml/config.xml", true);
     505    Document general_config_xml_file_document = XMLTools.parseXMLFile("xml/config.xml", true);
    506506    NodeList argument_elements_nodelist = general_config_xml_file_document.getDocumentElement().getElementsByTagName("Argument");
    507507    for (int i = 0; i < argument_elements_nodelist.getLength(); i++) {
     
    528528    // Read in the predefined configurations file
    529529    Vector predefined = new Vector();
    530     Document predefined_document = Utility.parse("xml/workflows.xml", true);
     530    Document predefined_document = XMLTools.parseXMLFile("xml/workflows.xml", true);
    531531    Element predefined_element = predefined_document.getDocumentElement();
    532532    NodeList workflow_elements = predefined_element.getElementsByTagName("Workflow");
  • trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java

    r9856 r10006  
    3232import org.greenstone.gatherer.DebugStream;
    3333import org.greenstone.gatherer.collection.CollectionTreeNode;
    34 import org.greenstone.gatherer.util.Utility;
    3534import org.greenstone.gatherer.util.XMLTools;
    3635
     
    7675        // Create a new (empty) metadata.xml file in the file's directory...
    7776        File new_metadata_xml_file_file = new File(current_file_directory, "metadata.xml");
    78         XMLTools.writeXMLFile(new_metadata_xml_file_file, Utility.parse("xml/metadata.xml", true));
     77        XMLTools.writeXMLFile(new_metadata_xml_file_file, XMLTools.parseXMLFile("xml/metadata.xml", true));
    7978
    8079        // ...load it...
  • trunk/gli/src/org/greenstone/gatherer/metadata/ProfileXMLFileManager.java

    r8164 r10006  
    3030import java.io.*;
    3131import java.util.*;
    32 import org.greenstone.gatherer.util.Utility;
    3332import org.greenstone.gatherer.util.XMLTools;
    3433
     
    5655    if (!profile_xml_file_file.exists()) {
    5756        // Create a new (empty) profile.xml file in this directory...
    58         XMLTools.writeXMLFile(profile_xml_file_file, Utility.parse("xml/profile.xml", true));
     57        XMLTools.writeXMLFile(profile_xml_file_file, XMLTools.parseXMLFile("xml/profile.xml", true));
    5958    }
    6059
  • trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java

    r9906 r10006  
    191191    static final public String PLUGIN_STR                                 = "plugin";
    192192    static final public String PROPERTIES_FILE_EXTENSION                  = ".properties";
    193     static final public String PSEUDO_COLLECTCONFIGURATION_XML            = "xml/CollectionConfig.xml";
    194193    static final public String RANGE_ELEMENT                              = "Range";
    195194    static final public String RBRACKET_CHARACTER                         = "]";
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r9981 r10006  
    10371037
    10381038
    1039     /** Parse in a xml document from a given filename. Note that this filename may need to be resolved by the class loader, especially for template files within a jar. */
    1040     static public Document parse(String filename, boolean use_classloader)
    1041     {
    1042     // Try the class loader if desired (for the applet JAR file)
    1043     if (use_classloader) {
    1044         InputStream is = base.getResourceAsStream("/" + filename);
    1045         if (is != null) {
    1046         return XMLTools.parseXML(is);
    1047         }
    1048     }
    1049 
    1050     // Try the file outside the classes directory
    1051     return XMLTools.parseXMLFile(new File(filename));
    1052     }
    1053 
    1054 
    10551039    static public StringBuffer readXMLStream(InputStream input_stream)
    10561040    {
  • trunk/gli/src/org/greenstone/gatherer/util/XMLTools.java

    r9856 r10006  
    9696    }
    9797    return child;
     98    }
     99
     100
     101    /** Parse an XML document from a given file path */
     102    static public Document parseXMLFile(String xml_file_path, boolean use_class_loader)
     103    {
     104    if (use_class_loader == true) {
     105        InputStream is = Utility.base.getResourceAsStream("/" + xml_file_path);  // !!
     106        if (is != null) {
     107        return parseXML(is);
     108        }
     109    }
     110
     111    // Try the file outside the classes directory
     112    return parseXMLFile(new File(xml_file_path));
    98113    }
    99114
Note: See TracChangeset for help on using the changeset viewer.