FilterFactory { public Filter createFilter(final String expression) throws FilterParseException { final String expr = expression.toLowerCase(); if (!expr.startsWith("sip.")) { throw new FilterParseException(0, "Not a valid sip expression"); } final int index = expression.indexOf("=="); if (index == -1) { throw new FilterParseException(expression.length(), "Expected a value. Missing '=='"); } final String token = expression.substring(0, index).trim(); final String value = expression.substring(index + 2, expression.length()).trim(); if (token.equalsIgnoreCase("sip.call-id")) { return new SipCallIdFilter(value); } final String[] parts = token.split("\\."); if (parts.length == 1) { throw new FilterParseException(0, "Expected \"sip.\"<value> but didn't find a dot"); } else if (parts.length > 2) { throw new FilterParseException(0, "Expected \"sip.\"<value> but found multiple dots so now I'm not sure what to do"); } final String headername = parts[1]; return new SipHeaderFilter(headername, value); } private  FilterFactory(); static final FilterFactory getInstance(); Filter createFilter(final String expression);  }
@Test public void testCreateSimpleSipCallIdFilter() { assertThat(((SipCallIdFilter) this.factory.createFilter("sip.Call-ID == 1234")).getCallId(), is("1234")); assertThat(((SipCallIdFilter) this.factory.createFilter("sip.Call-ID ==1234")).getCallId(), is("1234")); assertThat(((SipCallIdFilter) this.factory.createFilter("sip.Call-ID == hello ")).getCallId(), is("hello")); }