skn73
asked on
Request Validations
getTest1( String tNo, String tn, String state) //all three required as input
getTest2(String tn, String State) // both data values required
for both of these input needs to be validated to see if it is null and is in the right format ..
I have this fn to test this
public void validateReq(String qualTrackNo, String tn, String state) throws ServicesApplicationExcepti on
{
String fctStr = "ServiceRequestBean::check Req()";
PatternMatcher re = new Perl5Matcher();
if (!reInit)
setupRePatterns();
try
{
// EDIT THE TELEPHONE NUMBER
if ( (tn == null) || (!re.matches(tn, reTn)) )
throw exception;...
// EDIT THE QUALIFICATION TRACKING NUMBER
if ( TrackNo == null ||
(!re.matches(TrackNo, reQualTrackNum)) )
throw exception...
// EDIT THE STATE
if ( state == null || (!re.matches(state, reState)) )
throw exception...
}
private synchronized void setupRePatterns() throws ServicesApplicationExcepti on
{
try
{
TraceLog.write(TraceLog.DE BUG, "Initializing regular patterns...");
if (reInit)
return;
reTn = new Perl5Compiler().compile(pr ops.getVal ue(Service sConstants .REGEXP_TN _10DIGIT), Perl5Compiler.READ_ONLY_MA SK);
reQualTrackNum = new Perl5Compiler().compile(pr ops.getVal ue(Service sConstants .REGEXP_QU AL_TRACK_N O), Perl5Compiler.READ_ONLY_MA SK);
reState = new Perl5Compiler().compile(pr ops.getVal ue(Service sConstants .REGEXP_ST ATE_2CHAR) , Perl5Compiler.READ_ONLY_MA SK);
reInit = true;
return;
}
catch(Throwable t)
{
ServicesError.throwProcess ingExcepti on(t, "ServiceRequestBean::setup RePatterns ()", props);
}
return;
}
How do I retain the same fns and test for both getTest1 and getTest2? other than polymorphism?
getTest2(String tn, String State) // both data values required
for both of these input needs to be validated to see if it is null and is in the right format ..
I have this fn to test this
public void validateReq(String qualTrackNo, String tn, String state) throws ServicesApplicationExcepti
{
String fctStr = "ServiceRequestBean::check
PatternMatcher re = new Perl5Matcher();
if (!reInit)
setupRePatterns();
try
{
// EDIT THE TELEPHONE NUMBER
if ( (tn == null) || (!re.matches(tn, reTn)) )
throw exception;...
// EDIT THE QUALIFICATION TRACKING NUMBER
if ( TrackNo == null ||
(!re.matches(TrackNo, reQualTrackNum)) )
throw exception...
// EDIT THE STATE
if ( state == null || (!re.matches(state, reState)) )
throw exception...
}
private synchronized void setupRePatterns() throws ServicesApplicationExcepti
{
try
{
TraceLog.write(TraceLog.DE
if (reInit)
return;
reTn = new Perl5Compiler().compile(pr
reQualTrackNum = new Perl5Compiler().compile(pr
reState = new Perl5Compiler().compile(pr
reInit = true;
return;
}
catch(Throwable t)
{
ServicesError.throwProcess
}
return;
}
How do I retain the same fns and test for both getTest1 and getTest2? other than polymorphism?
ASKER
getTest1(tno, Tn, state) & getTest2(tn, state) needs to call validateReq() to validate the input
I dont want to change getTest1 or getTest2.
as it is written currently ..
if getTest2() calls validateReq("",tn,state) because there is no tracknum ...
it will error out saying tracknum is null or is in iinvalid format..
How can I use validateReq fn to do validations for both getTest1 and getTest2
I dont want to change getTest1 or getTest2.
as it is written currently ..
if getTest2() calls validateReq("",tn,state) because there is no tracknum ...
it will error out saying tracknum is null or is in iinvalid format..
How can I use validateReq fn to do validations for both getTest1 and getTest2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks .. this is exactly what I did ...
where "xxx" is a valid value for tNo
these way it can be used with 2 or 3 parameters