B
BogusException
Consider that you want to do a regex match on the contents of an
attribute of that object. Say, for example, the contents of:
SomeObjectInstance.x
All is well unless you don't know ahead of time that "x" is the
attribute that the user will search against. Suppose that the object
can have any attribute name, and even all those possibilities aren't
known at compile time. The user can/will select this attribute, as well
as the regex pattern.
So the trick is how to apply the match against "x" in this case with
only "x" as a string passed to the method?
// this doesn't work!
public boolean isRegexMatch(String p, String m, SomeObject o, String
attribute){
Pattern pat = Pattern.compile(p);
Matcher mat = pat.matcher(o."attribute"); <--- doesn't work, obviously
return (mat.find());
}
The above would be nice, but as expected-it doesn't work.
So the question is, how to make the method functional without knowing
what it will be passed for "attribute"?
TIA!
BogusException
attribute of that object. Say, for example, the contents of:
SomeObjectInstance.x
All is well unless you don't know ahead of time that "x" is the
attribute that the user will search against. Suppose that the object
can have any attribute name, and even all those possibilities aren't
known at compile time. The user can/will select this attribute, as well
as the regex pattern.
So the trick is how to apply the match against "x" in this case with
only "x" as a string passed to the method?
// this doesn't work!
public boolean isRegexMatch(String p, String m, SomeObject o, String
attribute){
Pattern pat = Pattern.compile(p);
Matcher mat = pat.matcher(o."attribute"); <--- doesn't work, obviously
return (mat.find());
}
The above would be nice, but as expected-it doesn't work.
So the question is, how to make the method functional without knowing
what it will be passed for "attribute"?
TIA!
BogusException