BubikolRamios
01-05-2008, 03:12 PM
this is a bit of java script code:
functions like checkNick .. all return "" if it is all OK or otherwise some kind of message for user
result = checkNick(nick) || checkMail(email) || checkPwd(pwd1,pwd2);
if (result)
{
alert(result);
return;
}
// go forvard ..
This is attempt to do the same in java, knowing that HashSet does not allow duplicates. It works as wanted, first occurance that does not satisfy , jumps out.
java.util.HashSet hs = new java.util.HashSet();
boolean f;
f = hs.add("");
result = hs.add(checkNick(nick)) ||
hs.add(checkPwd(pwd1, pwd2)) ||
hs.add(checkMail(email)) ||
hs.add(checkCaptcha(clientCaptcha, serverCaptcha));
if (!result)
{
//ALL OK
else
{
String[] a = (String[])hs.toArray(new String[0]);
// output to user about error
return a[a.length-1].toString();
}
Comments welcome.
functions like checkNick .. all return "" if it is all OK or otherwise some kind of message for user
result = checkNick(nick) || checkMail(email) || checkPwd(pwd1,pwd2);
if (result)
{
alert(result);
return;
}
// go forvard ..
This is attempt to do the same in java, knowing that HashSet does not allow duplicates. It works as wanted, first occurance that does not satisfy , jumps out.
java.util.HashSet hs = new java.util.HashSet();
boolean f;
f = hs.add("");
result = hs.add(checkNick(nick)) ||
hs.add(checkPwd(pwd1, pwd2)) ||
hs.add(checkMail(email)) ||
hs.add(checkCaptcha(clientCaptcha, serverCaptcha));
if (!result)
{
//ALL OK
else
{
String[] a = (String[])hs.toArray(new String[0]);
// output to user about error
return a[a.length-1].toString();
}
Comments welcome.