pls find code in the recent post with proper format, below.
Aadhi
Aadhi
Aadhi
Charles.<br />(SCJD2)
Originally posted by Charles Dupin:
What about a delimiter like "=';" for your tokenizer.
Aadhi
Aadhi
Aadhi
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by HS Thomas:
Are there any books/resources you'd recommend ?
regards
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
You have already learnt many patterns, and probably invented a few. Many you just have to learn to recogniseOriginally posted by HS Thomas:
How early would you recommend learning Patterns. I know they are in the API but making the connection between language and pattern can be difficult without some effort.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by HS Thomas:
...selecting those that have the set of query values(candidateSet), but regardless of the column they are in...
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
quoted from Peter den Haan's post:
Between them, Design Patterns and Refactoring taught me what little I know about software design.
Originally posted by HS Thomas:
How is synchronisation achieved around this block of code ?
I am assuming that the Collection Sets are synchronized sets.
You have implemented criteriaFind in the Data class and the methods are synchronized.
If you have implemented the LockManager then I can't see a problem that there is no sync in your implementation of criteriaFind.
Does the LockManager lock for reads and writes ?
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
any fool(myself) can write a code that a computer understands . but only a
good programmer can write a code that the other prorammers can uderstand.
', is treated to be the criteria filter
=' is treated to be the field value splitter
the only way i can think of is have one more constructor for
MyStringTokenizer ( the last param will delimit the last token
in order) means if parser is ', and if the last token has '
then it will be removed. if the delimiter is ';, then
the last token will be removed if contains '; . will this
be reasonable. adding comma will be one way with all the search
criteria but i will be relying on the client to supply this![]()
please help me what to choose.
every time, i'm impressed with your posts, a star falls!
so if i look above and find the sky empty, it's not your falt.
i am greatful to the 3 amigos of yourself,Mark and Eugene.
i like it here!!!![]()
![]()
Aadhi
It's brilliantOriginally posted by Lasse Koskela:
Once we're at it, I figured I should ask some opinions about my Map-based approach for criteriaFind()...
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
1)currently it is not working for widlcard "ANY". i am assuming that
i will do a searchString.indexOf("'ANY'") != -1 in the Controller
and if it is yes the pass null to the Model
just a thougt, what if the user gives
origin='ANY''' means the value is ANY'' then will it also be "'ANY'"
Aadhi
Don't let me make you insecure. I'm a pedantic perfectionist and proud of it; take on board the things you agree with, and simply ignore the restOriginally posted by aadhi agathi:
[...] i don't know whether it is up to the mark!!
You don't expect your users to enter quotes, do you? I'd simply suggest something based on simple equality, along the lines ofOr something more elegant as appropriate.1)currently it is not working for widlcard "ANY". i am assuming that i will do a searchString.indexOf("'ANY'") != -1 in the Controller and if it is yes the pass null to the Model
I used a StringTokenizer(criteria, ",='", true). The bit that handled the criterion value, including the quotes, wasWould I do it again in exactly the same way? Probably not. It looks a bit too much like C(++). Besides, today you can use regular expressions; the expression matches a criteria expression and captures fields and values in its groups (see Matcher.group()); what more can you want?... if you're comfortable with regexps, that isconsider the search string
a='aaa',b='bbbb',c='cccc' then
then the last criteria token will be taken split as
field = c and value is cccc' (note quotes at end).
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
You don't expect your users to enter quotes,i doesnt do you?
my only assumptions are ', will be the criteria terminator &
=' will be the field termiantor.
// if in Data
1) single criteria and multiple criteria
criteria.endsWith("='"+WILDCARD"'") || criteria.indexOf("='"+WILDCARD+"',") !=-1
// if in Controller/facade
2) single criteria and multiple criteria
if (criteria.endsWith("'ANY'") || criteria.indexOf("='ANY',") !=-1){
pass null for search
I used a StringTokenizer(criteria, ",='", true). The bit that handled the criterion value,
including the quotes
=' will be the field value separator and
=. will be the criteria delimeter as i support quotes
Besides, today you can use regular expressions; the expression
That quote makes me suspicious. What's it doing in here? I expected the highest-level tokenizer to tokenize on commas only.
You're initializing this variable, but the first thing you do next is assign another value to it?
This "='" string should never occur because "'" is a delimiter.
I personally never use "else" after throwing an exception. To a reader, the "else"
signals merely an alternative code path where two or more different paths can
legitimately be taken.Can you feel the difference?
In checkValidFields ..A small method that starts with no fewer than six local variables
ome of your temporary variables were simple optimisations, like fields and fieldNames[].
Don't; remember the first rule of optimization. currentField which is used only inside
the loop. Don't, always choose the narrowest scope possible...
For the very same reason, you should be able to eliminate getAllRecords().
A final word. In a process like this, I like to have a top-level method that outlines the algorithm on a high level. Eg, in your case:
see what I mean? I'm not saying that this is the best possible implementation
(heck, I'm not even saying that it compiles)
Aadhi
Message for you sir! I think it is a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|