- Timestamp:
- 2007-01-23T14:48:57+13:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/ScriptOptions.java
r13748 r13752 2 2 3 3 import java.io.*; 4 import java.lang.ref.*;5 import java.net.*;6 4 import java.util.*; 7 import org.apache.xerces.parsers.DOMParser;8 5 import org.greenstone.gatherer.Configuration; 9 6 import org.greenstone.gatherer.DebugStream; … … 14 11 import org.greenstone.gatherer.util.ArrayTools; 15 12 import org.greenstone.gatherer.util.Codec; 16 import org.greenstone.gatherer.util.StaticStrings;17 13 import org.greenstone.gatherer.util.Utility; 18 14 import org.greenstone.gatherer.util.XMLTools; 19 15 import org.w3c.dom.*; 20 import org.xml.sax.InputSource; 16 21 17 22 18 /** Build options uses the argument list found in config.xml and the current settings from the loaded collection configuration to represent the options the user wants to use during import and build. If there are no arguments stored in config.xml, or if the user indicates the argument are out of date, this class tries to parse new ones. */ … … 26 22 /** The root element of the values tree. */ 27 23 private Element values_element; 28 /** A cache of previously created arguments. */29 private Hashtable arguments_cache = new Hashtable();30 /** whether the values should be saved or not */31 24 /** The name of an argument element. */ 32 25 static final private String ARGUMENT = "Argument"; … … 52 45 53 46 /** Retrieve the indexth argument */ 54 public Argument getArgument(int index) { 47 public Argument getArgument(int index) 48 { 55 49 Argument argument = null; 56 // Try to find the argument in the cache. 57 SoftReference reference = (SoftReference) arguments_cache.get(new Integer(index)); 58 if(reference != null) { 59 argument = (Argument) reference.get(); 60 } 61 // Otherwise generate a new argument. 62 if(argument == null) { 63 NodeList option_list = arguments_element.getElementsByTagName(OPTION); 64 if(0 <= index && index < option_list.getLength()) { 65 argument = new Argument(); 66 argument.parseXML((Element) option_list.item(index)); 67 } 68 } 50 51 NodeList option_list = arguments_element.getElementsByTagName(OPTION); 52 if (index >= 0 && index < option_list.getLength()) { 53 argument = new Argument(); 54 argument.parseXML((Element) option_list.item(index)); 55 } 56 69 57 return argument; 70 58 } … … 79 67 } 80 68 81 /** Retrieve all the argument names and values */82 public String[] getArguments() {83 String arguments[] = null;84 NodeList argument_list = null;85 argument_list = values_element.getElementsByTagName(ARGUMENT);86 for(int i = 0; i < argument_list.getLength(); i++) {87 Element argument = (Element) argument_list.item(i);88 ArrayTools.add(arguments, argument.getAttribute(NAME));89 String value = XMLTools.getValue(argument);90 if(value != null && value.length() > 0) {91 ArrayTools.add(arguments, value);92 }93 }94 return arguments;95 }96 69 97 70 /** Retrieve the value of a certain argument. */
Note:
See TracChangeset
for help on using the changeset viewer.