OriginFieldParser implements SdpParser<OriginField> { @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 OriginField parse(String sdp); @Override void parse(OriginField field, String sdp);  }
@Test public void testCanParse() { String validLine = "o=- 30 1 IN IP4 127.0.0.1\n\r"; String invalidLine1 = "o=- 30 1 IN 127.0.0.1\n\r"; String invalidLine2 = "o=- xyz 1 IN 127.0.0.1\n\r"; String invalidLine3 = "a=- 30 1 IN 127.0.0.1\n\r"; boolean canParseValidLine = parser.canParse(validLine); boolean canParseInvalidLine1 = parser.canParse(invalidLine1); boolean canParseInvalidLine2 = parser.canParse(invalidLine2); boolean canParseInvalidLine3 = parser.canParse(invalidLine3); Assert.assertTrue(canParseValidLine); Assert.assertFalse(canParseInvalidLine1); Assert.assertFalse(canParseInvalidLine2); Assert.assertFalse(canParseInvalidLine3); }