DlgpParser extends AbstractCloseableIterator<Object> implements Parser<Object> { public static NegativeConstraint parseNegativeConstraint(String s) throws ParseException { try { return (NegativeConstraint) parse(s); } catch (ClassCastException e) { throw new DlgpParseException("Wrong object type.", e); } } DlgpParser(Reader reader);  DlgpParser();  DlgpParser(File file);  DlgpParser(String s);  DlgpParser(InputStream in); @Override boolean hasNext(); @Override Object next(); @Override void close(); static EffectiveConjunctiveQuery parseEffectiveQuery(String s); static ConjunctiveQuery parseQuery(String s); static Atom parseAtom(String s); static Rule parseRule(String s); static NegativeConstraint parseNegativeConstraint(String s); static CloseableIterator<Atom> parseAtomSet(String s);  }
@Test public void parseNegativeConstraint() throws ParseException { NegativeConstraint r = DlgpParser.parseNegativeConstraint("[N1]!:-p(X,Y), q(X,Y)."); CloseableIteratorWithoutException<Atom> it = r.getBody().iterator(); Atom body = it.next(); Assert.assertTrue(body.getTerm(0).isVariable()); Assert.assertTrue(body.getTerm(1).isVariable()); body = it.next(); Assert.assertTrue(body.getTerm(0).isVariable()); Assert.assertTrue(body.getTerm(1).isVariable()); Assert.assertEquals("N1", r.getLabel()); }
@Test(expected = ParseException.class) public void parseNegativeConstraintWrongObject() throws ParseException { DlgpParser.parseNegativeConstraint("p(a)."); }