ConnectionFieldParser implements SdpParser<ConnectionField> { @Override public boolean canParse(String sdp) { if (sdp == null || sdp.isEmpty()) { return false; } return PATTERN.matcher(sdp.trim()).matches(); }  @Override boolean canParse(String sdp); @Override ConnectionField parse(String sdp); @Override void parse(ConnectionField field, String sdp);  }
@Test public void testCanParse() { String validLine = "c=IN IP6 0.0.0.0\n\r"; String invalidLine1 = "c=IN 127.0.0.1\n\r"; String invalidLine2 = "x=IN IP6 0.0.0.0\n\r"; boolean canParseValidLine = parser.canParse(validLine); boolean canParseInvalidLine1 = parser.canParse(invalidLine1); boolean canParseInvalidLine2 = parser.canParse(invalidLine2); Assert.assertTrue(canParseValidLine); Assert.assertFalse(canParseInvalidLine1); Assert.assertFalse(canParseInvalidLine2); }