Grammar extends AbstractSrgsNode implements VoiceXmlNode { public Collection<Rule> getPublicRules() { final Collection<Rule> publicRules = new java.util.ArrayList<Rule>(); final Collection<Rule> rules = getChildNodes(Rule.class); for (Rule rule : rules) { if (rule.isPublic()) { publicRules.add(rule); } } return publicRules; } Grammar();   Grammar(final Node node); private  Grammar(final Node n,
            final XmlNodeFactory<? extends XmlNode> factory); @Override String getTagName(); @Override XmlNode newInstance(final Node n,
            final XmlNodeFactory<? extends XmlNode> factory); String getVersion(); void setVersion(final String version); String getModename(); ModeType getMode(); void setMode(final String mode); void setMode(final ModeType mode); String getRoot(); void setRoot(final String root); void setRoot(final Rule rule); Rule getRootRule(); Collection<Rule> getRules(); Collection<Rule> getPublicRules(); Rule getRule(final String name); String getTagFormat(); void setTagFormat(final String tagFormat); String getXmlLang(); Locale getXmlLangObject(); void setXmlLang(final String xmlLang); void setXmlLang(final Locale locale); String getXmlBase(); void setXmlBase(final String xmlBase); String getSrc(); URL getSrcUrl(); URI getSrcUri(); void setSrc(final String src); void setSrc(final URL url); void setSrc(final URI uri); String getScope(); void setScope(final String scope); String getTypename(); GrammarType getType(); void setType(final String type); void setType(final GrammarType type); String getWeight(); void setWeight(final String weight); String getFetchhint(); void setFetchhint(final String fetchhint); String getFetchtimeout(); long getFetchTimeoutAsMsec(); void setFetchtimeout(final String fetchtimeout); String getMaxage(); long getMaxageAsMsec(); void setMaxage(final String maxage); String getMaxstale(); long getMaxstaleAsMsec(); void setMaxstale(final String maxstale); String getSrcexpr(); void setSrcexpr(final String srcexpr); Text addText(final String text); CDATASection addCData(final String data); @Override Collection<String> getAttributeNames(); boolean isExternalGrammar(); static final String TAG_NAME; static final String DEFAULT_XMLNS; static final String ATTRIBUTE_XMLNS; static final String ATTRIBUTE_VERSION; static final String DEFAULT_VERSION; static final String ATTRIBUTE_XML_LANG; static final String ATTRIBUTE_MODE; static final String ATTRIBUTE_ROOT; static final String ATTRIBUTE_TAG_FORMAT; static final String ATTRIBUTE_XML_BASE; static final String ATTRIBUTE_SRC; static final String ATTRIBUTE_SCOPE; static final String SCOPE_DOCUMENT; static final String SCOPE_DIALOG; static final String ATTRIBUTE_TYPE; static final String ATTRIBUTE_WEIGHT; static final String ATTRIBUTE_FETCHHINT; static final String ATTRIBUTE_FETCHTIMEOUT; static final String ATTRIBUTE_MAXAGE; static final String ATTRIBUTE_MAXSTALE; static final String ATTRIBUTE_SRCEXPR; }
@Test public void testGetPublicRules() throws Exception { final SrgsXmlDocument document = new SrgsXmlDocument(); final Grammar grammar = document.getGrammar(); final Rule rule1 = grammar.appendChild(Rule.class); grammar.setRoot(rule1); rule1.makePublic(); rule1.setId("test1"); final Rule rule2 = grammar.appendChild(Rule.class); rule2.setId("test2"); final Rule rule3 = grammar.appendChild(Rule.class); rule3.setId("test3"); rule3.makePublic(); final Collection<Rule> rules = grammar.getPublicRules(); Assert.assertEquals(2, rules.size()); }
@Test public void testGetPublicRulesEmpty() throws Exception { final SrgsXmlDocument document = new SrgsXmlDocument(); final Grammar grammar = document.getGrammar(); final Collection<Rule> rules = grammar.getPublicRules(); Assert.assertEquals(0, rules.size()); }
@Test public void testGetPublicRulesOnlyPrivate() throws Exception { final SrgsXmlDocument document = new SrgsXmlDocument(); final Grammar grammar = document.getGrammar(); final Rule rule1 = grammar.appendChild(Rule.class); rule1.setId("test1"); final Rule rule2 = grammar.appendChild(Rule.class); rule2.setId("test2"); final Rule rule3 = grammar.appendChild(Rule.class); rule3.setId("test3"); final Collection<Rule> rules = grammar.getPublicRules(); Assert.assertEquals(0, rules.size()); }