[ 1845202 ] Bean shell Scriptlet generate invalid variable name

This commit is contained in:
Heng Sin Low 2007-12-05 23:28:10 +00:00
parent 56239fb0ae
commit da929b55d1
1 changed files with 21 additions and 7 deletions

View File

@ -45,6 +45,8 @@ public class Scriptlet
return scr.getResult(false); return scr.getResult(false);
} // run } // run
private int m_windowNo;
/** /**
* Constructor * Constructor
*/ */
@ -69,6 +71,7 @@ public class Scriptlet
*/ */
public Scriptlet (String variable, String script, Properties prop, int WindowNo) public Scriptlet (String variable, String script, Properties prop, int WindowNo)
{ {
m_windowNo = WindowNo;
setVariable(variable); setVariable(variable);
setScript(script); setScript(script);
setEnvironment(prop, WindowNo); setEnvironment(prop, WindowNo);
@ -110,7 +113,7 @@ public class Scriptlet
if (m_variable == null || m_variable.length() == 0 || m_script == null || m_script.length() == 0) if (m_variable == null || m_variable.length() == 0 || m_script == null || m_script.length() == 0)
{ {
IllegalArgumentException e = new IllegalArgumentException("No variable/script"); IllegalArgumentException e = new IllegalArgumentException("No variable/script");
log.config(e.toString()); log.warning(e.toString());
return e; return e;
} }
Interpreter i = new Interpreter(); Interpreter i = new Interpreter();
@ -122,7 +125,7 @@ public class Scriptlet
} }
catch (Exception e) catch (Exception e)
{ {
log.config(e.toString()); log.warning(e.toString());
return e; return e;
} }
try try
@ -132,7 +135,7 @@ public class Scriptlet
} }
catch (Exception e) catch (Exception e)
{ {
log.config("Result - " + e); log.warning("Result - " + e);
if (e instanceof NullPointerException) if (e instanceof NullPointerException)
e = new IllegalArgumentException("Result Variable not found - " + m_variable); e = new IllegalArgumentException("Result Variable not found - " + m_variable);
return e; return e;
@ -236,10 +239,11 @@ public class Scriptlet
if (key == null || key.length() == 0 if (key == null || key.length() == 0
|| key.startsWith("P") // Preferences || key.startsWith("P") // Preferences
|| (key.indexOf('|') != -1 && !key.startsWith(String.valueOf(WindowNo))) // other Window Settings || (key.indexOf('|') != -1 && !key.startsWith(String.valueOf(WindowNo))) // other Window Settings
|| (key.indexOf('|') != -1 && key.indexOf('|') != key.lastIndexOf('|')) //other tab
) )
continue; continue;
String value = prop.getProperty(key); Object value = prop.get(key);
setEnvironment (key, value); setEnvironment (key, value);
} }
@ -342,8 +346,18 @@ public class Scriptlet
*/ */
private String convertKey (String key) private String convertKey (String key)
{ {
String retValue = Util.replace(key, "#", "_"); String k = m_windowNo + "|";
return retValue; if (key.startsWith(k))
{
String retValue = "_" + key.substring(k.length());
retValue = Util.replace(retValue, "|", "_");
return retValue;
}
else
{
String retValue = Util.replace(key, "#", "__");
return retValue;
}
} // convertKey } // convertKey
/** /**
@ -375,7 +389,7 @@ public class Scriptlet
*/ */
public Object getResult (boolean runIt) public Object getResult (boolean runIt)
{ {
if (runIt) if (runIt)
execute(); execute();
return m_result; return m_result;
} // getResult } // getResult