报春使者是什么鸟:一个JAVA的问题,请高手指点一下。

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/28 15:12:11
public PasswdLevel4()
{
inuser = new String[22];
totno = 0;
countConn = null;
countData = null;
inURL = null;
txtlogin = new TextField();
label1 = new Label();
label2 = new Label();
label3 = new Label();
txtpass = new TextField();
lblstatus = new Label();
ButOk = new Button();
ButReset = new Button();
lbltitle = new Label();
}
void ButOk_ActionPerformed(ActionEvent actionevent)
{
boolean flag = false;
for(int i = 1; i <= totno / 2; i++)
if(txtlogin.getText().trim().toUpperCase().intern() == inuser[2 * (i - 1) + 2].trim().toUpperCase().intern() && txtpass.getText().trim().toUpperCase().intern() == inuser[2 * (i - 1) + 3].trim().toUpperCase().intern())
{
lblstatus.setText("Login Success, Loading..");
flag = true;
String s = inuser[1].trim().intern();
String s1 = getParameter("targetframe");
if(s1 == null)
s1 = "_self";
try
{
finalurl = new URL(getCodeBase(), s);
}
catch(MalformedURLException _ex)
{
lblstatus.setText("Bad URL");
}
getAppletContext().showDocument(finalurl, s1);

这是一个JAVA程序的片断,请问
for(int i = 1; i <= totno / 2; i++)
if(txtlogin.getText().trim().toUpperCase().intern() == inuser[2 * (i - 1) + 2].trim().toUpperCase().intern() && txtpass.getText().trim().toUpperCase().intern() == inuser[2 * (i - 1) + 3].trim().toUpperCase().intern())这个语句是什么意思?如何满足他?

应该是一个密码验证的if判断
系统的用户名和密码都放在inuser数组里
inuser数组结构为inuser[0] 未知
inuser[1] 登陆成功后跳转的url,其余的以两个为一组保存用户名和密码

在if判断返回true时
得到url = inuser[1] ,target = s1
target:表示为类似<a href=inuser[1] target=s1 >xxx</a>

我的理解是inuser 是一个存放了用户名和对应密码的一个String数组,如果ButOk事件发生,则循环遍历该inuser数组,并判断是否该次登陆有效
trim()简单的说就是去首尾空白
toUpperCase()转成大写
intern()JVM内部“拘留”也就是放入String常量池,这样通过==比较可以得到期望的结果

inuser[0]不知道存的是什么;
inuser[1]连接地址1;
inuser[2]用户名1;
inuser[3]密码1;
inuser[4]连接地址2;
inuser[5]用户名2;
inuser[6]密码2;
.
.
.
*txtlogin为用户名输入框,txtpass为密码输入框
那一段的意思是循环totno(总数),如果用户和密码同时满足则提取连接地址并进行连接,