import java.io.StringWriter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

class KeyCombo
{
	public String _keyname = "a^"; // unmatchable regular expression
	private String _uscript = "";
	
	// Default constructor.
	public KeyCombo()
	{
	}
	
	// 
	public KeyCombo(String keyname, String uscript)
	{
		this._keyname = "^" + keyname + "$";
		this._uscript = uscript;
	}
	
	public KeyCombo(Node keycomboNode)
	{
		String uscript = "";
		NodeList nodes = keycomboNode.getChildNodes();
		for(int i = 0; i < nodes.getLength(); i++)
		{
			uscript = uscript + nodeToString(nodes.item(i)).trim() + "\n";
		}
		
		this._keyname = "^" + ((Element)keycomboNode).getAttribute("match").trim() + "$";
		this._uscript = uscript.trim();
	}
	
	public String checkKey(String key)
	{
		Pattern p = Pattern.compile(this._keyname);
		Matcher m = p.matcher(key);
		if(m.find())
		{
			try
			{
				if(!m.group(1).equals(""))
				{
					return this._uscript.replace("{COMMAND PARAMETER}", m.group(1));
				}
			}
			catch(Exception e)
			{
				// Deliberately empty.
			}
			return this._uscript;
		}
		else
		{
			return "";
		}
	}
	
	private String nodeToString(Node node)
	{
		StringWriter sw = new StringWriter();
		try
		{
			Transformer t = TransformerFactory.newInstance().newTransformer();
			t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
			t.transform(new DOMSource(node), new StreamResult(sw));
		}
		catch
		(TransformerException te)
		{
			System.out.println("nodeToString Transformer Exception");
		}
		return sw.toString();
	}
}
@@ -557,22 +557,24 @@
 private 
-String
+NodeList
  _uscrip
@@ -574,21 +574,16 @@
 _uscript
- = %22%22
 ;%0A%09%0A%09// 
@@ -668,22 +668,24 @@
 eyname, 
-String
+NodeList
  uscript
@@ -777,20 +777,23 @@
 eyCombo(
-Node
+Element
  keycomb
@@ -1024,18 +1024,8 @@
 %22 + 
-((Element)
 keyc
@@ -1032,17 +1032,16 @@
 omboNode
-)
 .getAttr
@@ -1075,36 +1075,239 @@
 ;%0A%09%09
-this._uscript = uscript.trim
+// TODO: Make sure that _uscript actually has a list of nodes in it, and make sure that all of them are either %3Cjavascript%3E or %3Cutopiascript%3E nodes. Throw a GameLoadException otherwise. %0A%09%09this._uscript = keycomboNode.getChildNodes
 ();%0A
@@ -1319,22 +1319,24 @@
 %09public 
-String
+NodeList
  checkKe
@@ -1521,16 +1521,19 @@
 _uscript
+;//
 .replace
@@ -1686,17 +1686,89 @@
 %0A%09%09%09
-return %22%22
+// TODO: This seems REALLY hacky.%0A%09%09%09return this._uscript.item(0).getChildNodes()
 ;%0A%09%09

Change KeyCombo::_uscript to NodeList