FormatParameterAttributeParser implements SdpParser<FormatParameterAttribute> { @Override public FormatParameterAttribute parse(String sdp) throws SdpException { try { int separator = sdp.indexOf(AttributeField.ATTRIBUTE_SEPARATOR); if(separator == -1) { throw new IllegalArgumentException("No value found"); } String[] values = sdp.trim().substring(separator + 1).split(" "); int format = Integer.parseInt(values[0]); String params = values[1]; return new FormatParameterAttribute(format, params); } catch (Exception e) { throw new SdpException(PARSE_ERROR + sdp, e); } }  @Override boolean canParse(String sdp); @Override FormatParameterAttribute parse(String sdp); @Override void parse(FormatParameterAttribute field, String sdp);  }
@Test public void testParse() throws SdpException { String sdp1 = "a=fmtp:18 annexb=no\n\r"; FormatParameterAttribute obj = parser.parse(sdp1); Assert.assertEquals(18, obj.getFormat()); Assert.assertEquals("annexb=no", obj.getParams()); }
@Test public void testParseOverwrite() throws SdpException { String sdp1 = "a=fmtp:18 annexb=no\n\r"; String sdp2 = "a=fmtp:101 0-15\n\r"; FormatParameterAttribute obj = parser.parse(sdp1); parser.parse(obj, sdp2); Assert.assertEquals(101, obj.getFormat()); Assert.assertEquals("0-15", obj.getParams()); }