Closed david-melendez closed 7 years ago
I need to update the documentation in the code and on the wiki.
Really you should be using the the constants from ModifiersTG and ModifiersUnits.
If you're checking against a symbolCode that starts with 'G' or 'W', you'd use ModifiersTG.
Everything else you'd use ModifiersUnits. ModifiersTG does not have 'M' Higher Formation. So you shouldn't run into the issue you're describing above. However, that could come up with 'N' and 'AN'.
I'll add some checks so you don't get anymore false positives.
Thank you for the clarification.
David Melendez
mailto:david.melendez@nova-tech-solutions.com david.melendez@nova-tech-solutions.com
Software Engineer
Nova Tech Solutions
From: Michael Spinelli [mailto:notifications@github.com] Sent: Tuesday, October 18, 2016 2:58 PM To: missioncommand/mil-sym-java mil-sym-java@noreply.github.com Cc: david-melendez david.melendez@nova-tech-solutions.com; Author author@noreply.github.com Subject: Re: [missioncommand/mil-sym-java] hasModifier/canSymbolHaveModifier Failure - Part 2 (#29)
I need to update the documentation in the code and on the wiki. Really you should be using the the constants from ModifiersTG and ModifiersUnits. If you're checking against a symbolCode that starts with 'G' or 'W', you'd use ModifiersTG. Everything else you'd use ModifiersUnits. ModifiersTG does not have 'M' Higher Formation. So you shouldn't run into the issue you're describing above. However, that could come up with 'N' and 'AN'.
I'll add some checks so you don't get anymore false positives.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/missioncommand/mil-sym-java/issues/29#issuecomment-254621125 , or mute the thread https://github.com/notifications/unsubscribe-auth/AVkzUyD0lDEH1at2d7JvaIGtCSzo30gTks5q1SSwgaJpZM4KaHgL .
No virus found in this message. Checked by AVG - www.avg.com http://www.avg.com Version: 2016.0.7859 / Virus Database: 4664/13232 - Release Date: 10/18/16
No virus found in this message. Checked by AVG - www.avg.com http://www.avg.com Version: 2016.0.7797 / Virus Database: 4664/13229 - Release Date: 10/17/16
NOTE: hasModifier calls canSymbolHaveModifier
A canSymbolHaveModifier call can fail if the specified symbol supports the "AM" modifier but not the "M" modifier. For example, the following code will return true instead of false.
boolean result = SymbolUtilities.canHaveSymbolModifier("G*F*ATC---****X", "M", 1);
Note that the XML for this symbol (below) shows that this symbol does NOT support the "M" modifier but it does support the "AM" modifier.
The problem is that the canSymbolHaveModifier checks to see if the MODIFIERS element has the specified modifier followed by a period. This means that "M" returns true because the code finds the string "M." in the string (i.e., T.AM.). This occurs in two places in the code (see =====>).