Item extends AbstractSrgsNode implements VoiceXmlNode { public int getMaxRepeat() { final String repeat = getRepeat(); if (repeat == null) { return 1; } final int pos = repeat.indexOf('-'); if (pos < 0) { return Integer.parseInt(repeat); } else if (pos == repeat.length()) { return -1; } final String max = repeat.substring(pos + 1); if (max.trim().length() == 0) { return -1; } return Integer.parseInt(max); } Item();   Item(final Node node); private  Item(final Node n,
            final XmlNodeFactory<? extends XmlNode> factory); String getTagName(); XmlNode newInstance(final Node n,
            final XmlNodeFactory<? extends XmlNode> factory); String getRepeat(); int getMinRepeat(); int getMaxRepeat(); void setRepeat(final int repeat); void setRepeat(final int min, final int max); void setRepeat(final String repeat); void setOptional(); boolean isOptional(); String getRepeatProb(); void setRepeatProb(final String repeatProb); String getWeight(); void setWeight(final String weight); String getXmlLang(); Locale getXmlLangObject(); void setXmlLang(final String xmlLang); void setXmlLang(final Locale locale); Text addText(final String text); @Override Collection<String> getAttributeNames(); static final String TAG_NAME; static final String ATTRIBUTE_REPEAT; static final String ATTRIBUTE_REPEAT_PROB; static final String ATTRIBUTE_WEIGHT; static final String ATTRIBUTE_XML_LANG; }
@Test public void testGetMaxRepeat() throws Exception { final SrgsXmlDocument document = new SrgsXmlDocument(); final Grammar grammar = document.getGrammar(); grammar.setRoot("test"); final Rule rule = grammar.appendChild(Rule.class); rule.setId("test"); final OneOf politeOneOf = rule.appendChild(OneOf.class); final Item item = politeOneOf.appendChild(Item.class); Assert.assertEquals(1, item.getMaxRepeat()); item.setOptional(); Assert.assertEquals(1, item.getMaxRepeat()); final int repeat = 6; item.setRepeat(repeat); Assert.assertEquals(repeat, item.getMaxRepeat()); final int min = 4; final int max = 7; item.setRepeat(min, max); Assert.assertEquals(max, item.getMaxRepeat()); final int min2 = 4; final int max2 = -1; item.setRepeat(min2, max2); Assert.assertEquals(max2, item.getMaxRepeat()); }