{"action":"created","issue":{"url":"https://api.github.com/repos/missioncommand/mil-sym-java/issues/29","repository_url":"https://api.github.com/repos/missioncommand/mil-sym-java","labels_url":"https://api.github.com/repos/missioncommand/mil-sym-java/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/missioncommand/mil-sym-java/issues/29/comments","events_url":"https://api.github.com/repos/missioncommand/mil-sym-java/issues/29/events","html_url":"https://github.com/missioncommand/mil-sym-java/issues/29","id":183762779,"number":29,"title":"hasModifier/canSymbolHaveModifier Failure - Part 2","user":{"login":"david-melendez","id":22623059,"avatar_url":"https://avatars.githubusercontent.com/u/22623059?v=3","gravatar_id":"","url":"https://api.github.com/users/david-melendez","html_url":"https://github.com/david-melendez","followers_url":"https://api.github.com/users/david-melendez/followers","following_url":"https://api.github.com/users/david-melendez/following{/other_user}","gists_url":"https://api.github.com/users/david-melendez/gists{/gist_id}","starred_url":"https://api.github.com/users/david-melendez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-melendez/subscriptions","organizations_url":"https://api.github.com/users/david-melendez/orgs","repos_url":"https://api.github.com/users/david-melendez/repos","events_url":"https://api.github.com/users/david-melendez/events{/privacy}","received_events_url":"https://api.github.com/users/david-melendez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-18T18:13:35Z","updated_at":"2016-10-18T19:57:35Z","closed_at":null,"body":"NOTE: _hasModifier_ calls _canSymbolHaveModifier_\r\n\r\nA _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.\r\n\r\n`boolean result = SymbolUtilities.canHaveSymbolModifier(\"G*F*ATC---****X\", \"M\", 1);`\r\n\r\nNote that the XML for this symbol (below) shows that this symbol does NOT support the \"M\" modifier but it does support the \"AM\" modifier.\r\n\r\n```\r\n  <SYMBOL>\r\n    <SYMBOLID>G*F*ATC---****X</SYMBOLID>\r\n    <GEOMETRY>area</GEOMETRY>\r\n    <DRAWCATEGORY>16</DRAWCATEGORY>\r\n    <MAXPOINTS>1</MAXPOINTS>\r\n    <MINPOINTS>1</MINPOINTS>\r\n    <MODIFIERS>T.AM.</MODIFIERS>\r\n    <DESCRIPTION>Circular Target</DESCRIPTION>\r\n    <HIERARCHY>2.X.4.3.1.2</HIERARCHY>\r\n    <ALPHAHIERARCHY>TACGRP.FSUPP.ARS.ARATGT.CIRTGT</ALPHAHIERARCHY>\r\n    <PATH>Tactical Graphics/Fire Support/Areas/Area Target</PATH>\r\n  </SYMBOL>\r\n```\r\n\r\nThe 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.A**M.**).  This occurs in two places in the code (see =====>).\r\n\r\n```\r\npublic static boolean canSymbolHaveModifier(String symbolID, String tgModifier, int symStd)\r\n       {\r\n           String basic = null;\r\n           SymbolDef sd = null;\r\n           boolean returnVal = false;\r\n\r\n            try\r\n            {\r\n\r\n                basic = SymbolUtilities.getBasicSymbolID(symbolID);\r\n                sd = SymbolDefTable.getInstance().getSymbolDef(basic, symStd);\r\n                if(sd != null)\r\n                {\r\n                    int dc = sd.getDrawCategory();\r\n                    if(tgModifier.equals(ModifiersTG.AM_DISTANCE))\r\n                    {\r\n                        switch(dc)\r\n                        {\r\n                            case SymbolDef.DRAW_CATEGORY_RECTANGULAR_PARAMETERED_AUTOSHAPE:\r\n                            case SymbolDef.DRAW_CATEGORY_SECTOR_PARAMETERED_AUTOSHAPE:\r\n                            case SymbolDef.DRAW_CATEGORY_TWO_POINT_RECT_PARAMETERED_AUTOSHAPE: \r\n                                returnVal = true;\r\n                                break;\r\n                            case SymbolDef.DRAW_CATEGORY_CIRCULAR_PARAMETERED_AUTOSHAPE:\r\n                            case SymbolDef.DRAW_CATEGORY_CIRCULAR_RANGEFAN_AUTOSHAPE:\r\n                                returnVal = true;\r\n                                break;\r\n                            case SymbolDef.DRAW_CATEGORY_LINE:\r\n   ======>             if(sd.getModifiers().indexOf(tgModifier + \".\")>-1)\r\n                                    returnVal = true;\r\n                                break;\r\n                            default:\r\n                                returnVal = false;\r\n                        }\r\n                    }\r\n                    else if(tgModifier.equals(ModifiersTG.AN_AZIMUTH))\r\n                    {\r\n                        switch(dc)\r\n                        {\r\n                            case SymbolDef.DRAW_CATEGORY_RECTANGULAR_PARAMETERED_AUTOSHAPE:\r\n                            case SymbolDef.DRAW_CATEGORY_SECTOR_PARAMETERED_AUTOSHAPE:\r\n                                returnVal = true;\r\n                                break;\r\n                            default:\r\n                                returnVal = false;\r\n                        }\r\n                    }\r\n                    else\r\n                    {\r\n  ======>     sd.getModifiers().indexOf(tgModifier + \".\")>-1)\r\n                            returnVal = true;\r\n                    }\r\n                }\r\n\r\n                return returnVal;\r\n\r\n\r\n            }\r\n            catch(Exception exc)\r\n            {\r\n                ErrorLogger.LogException(\"SymbolUtilties\", \"canSymbolHaveModifier\", exc);\r\n            }\r\n            return returnVal;\r\n       }\r\n```"},"comment":{"url":"https://api.github.com/repos/missioncommand/mil-sym-java/issues/comments/254621125","html_url":"https://github.com/missioncommand/mil-sym-java/issues/29#issuecomment-254621125","issue_url":"https://api.github.com/repos/missioncommand/mil-sym-java/issues/29","id":254621125,"user":{"login":"michael-spinelli","id":5972575,"avatar_url":"https://avatars.githubusercontent.com/u/5972575?v=3","gravatar_id":"","url":"https://api.github.com/users/michael-spinelli","html_url":"https://github.com/michael-spinelli","followers_url":"https://api.github.com/users/michael-spinelli/followers","following_url":"https://api.github.com/users/michael-spinelli/following{/other_user}","gists_url":"https://api.github.com/users/michael-spinelli/gists{/gist_id}","starred_url":"https://api.github.com/users/michael-spinelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michael-spinelli/subscriptions","organizations_url":"https://api.github.com/users/michael-spinelli/orgs","repos_url":"https://api.github.com/users/michael-spinelli/repos","events_url":"https://api.github.com/users/michael-spinelli/events{/privacy}","received_events_url":"https://api.github.com/users/michael-spinelli/received_events","type":"User","site_admin":false},"created_at":"2016-10-18T19:57:35Z","updated_at":"2016-10-18T19:57:35Z","body":"I need to update the documentation in the code and on the wiki.\r\nReally you should be using the the constants from ModifiersTG and ModifiersUnits.\r\nIf you're checking against a symbolCode that starts with 'G' or 'W', you'd use ModifiersTG.\r\nEverything 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'.  \r\nI'll add some checks so you don't get anymore false positives."}}
{"actor":{"display_login":"michael-spinelli"}}