@Test public void bracketedPrimeSpecialCase1() { Element word = new GroupingEl(WORD_EL); Element bracket = new GroupingEl(BRACKET_EL); word.addChild(bracket); Element substituent = new GroupingEl(SUBSTITUENT_EL); bracket.addChild(substituent); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4")); assertEquals("4", StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4'")); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4''")); bracket.addAttribute(new Attribute(TYPE_ATR, IMPLICIT_TYPE_VAL)); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4")); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4'")); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4''")); }
static String checkForBracketedPrimedLocantSpecialCase(Element subBracketOrRoot, String locantString) { int terminalPrimes = StringTools.countTerminalPrimes(locantString); if (terminalPrimes > 0){ int brackettingDepth = 0; Element parent = subBracketOrRoot.getParent(); while (parent != null && parent.getName().equals(BRACKET_EL)){ if (!IMPLICIT_TYPE_VAL.equals(parent.getAttributeValue(TYPE_ATR))){ brackettingDepth++; } parent = parent.getParent(); } if (terminalPrimes == brackettingDepth){ return locantString.substring(0, locantString.length() - terminalPrimes); } } return null; }
StructureBuildingMethods { static String checkForBracketedPrimedLocantSpecialCase(Element subBracketOrRoot, String locantString) { int terminalPrimes = StringTools.countTerminalPrimes(locantString); if (terminalPrimes > 0){ int brackettingDepth = 0; Element parent = subBracketOrRoot.getParent(); while (parent != null && parent.getName().equals(BRACKET_EL)){ if (!IMPLICIT_TYPE_VAL.equals(parent.getAttributeValue(TYPE_ATR))){ brackettingDepth++; } parent = parent.getParent(); } if (terminalPrimes == brackettingDepth){ return locantString.substring(0, locantString.length() - terminalPrimes); } } return null; } }
StructureBuildingMethods { static String checkForBracketedPrimedLocantSpecialCase(Element subBracketOrRoot, String locantString) { int terminalPrimes = StringTools.countTerminalPrimes(locantString); if (terminalPrimes > 0){ int brackettingDepth = 0; Element parent = subBracketOrRoot.getParent(); while (parent != null && parent.getName().equals(BRACKET_EL)){ if (!IMPLICIT_TYPE_VAL.equals(parent.getAttributeValue(TYPE_ATR))){ brackettingDepth++; } parent = parent.getParent(); } if (terminalPrimes == brackettingDepth){ return locantString.substring(0, locantString.length() - terminalPrimes); } } return null; } private  StructureBuildingMethods(); }
StructureBuildingMethods { static String checkForBracketedPrimedLocantSpecialCase(Element subBracketOrRoot, String locantString) { int terminalPrimes = StringTools.countTerminalPrimes(locantString); if (terminalPrimes > 0){ int brackettingDepth = 0; Element parent = subBracketOrRoot.getParent(); while (parent != null && parent.getName().equals(BRACKET_EL)){ if (!IMPLICIT_TYPE_VAL.equals(parent.getAttributeValue(TYPE_ATR))){ brackettingDepth++; } parent = parent.getParent(); } if (terminalPrimes == brackettingDepth){ return locantString.substring(0, locantString.length() - terminalPrimes); } } return null; } private  StructureBuildingMethods();  }
StructureBuildingMethods { static String checkForBracketedPrimedLocantSpecialCase(Element subBracketOrRoot, String locantString) { int terminalPrimes = StringTools.countTerminalPrimes(locantString); if (terminalPrimes > 0){ int brackettingDepth = 0; Element parent = subBracketOrRoot.getParent(); while (parent != null && parent.getName().equals(BRACKET_EL)){ if (!IMPLICIT_TYPE_VAL.equals(parent.getAttributeValue(TYPE_ATR))){ brackettingDepth++; } parent = parent.getParent(); } if (terminalPrimes == brackettingDepth){ return locantString.substring(0, locantString.length() - terminalPrimes); } } return null; } private  StructureBuildingMethods();   }