This class models this representation and adds helper functions for replacement and reverse matching.
229230231232233234235236237238239
{ throw new MalformedUriTemplateException("Expression close brace was found at position " + position + " yet there was no start brace."); } expressionCaptureOn = false; components.add(new Expression(buffer.toString(), startPosition)); buffer = null; } else { throw new IllegalStateException("Cannot end an expression without beginning the template");
228229230231232233234235236237238
{ throw new MalformedUriTemplateException("Expression close brace was found at position " + position + " yet there was no start brace.", position); } expressionCaptureOn = false; components.add(new Expression(buffer.toString(), this.startPosition)); buffer = null; } else { throw new IllegalStateException("Cannot end an expression without beginning the template");
3233343536373839
{ @Test public void testExpressionFromString() throws Exception { Expression e = new Expression("{test:1}", 0); Assert.assertEquals("\\Q{test:1}\\E", e.getReplacementPattern()); }
3940414243444546
} @Test public void testSimple() throws Exception { Expression e = Expression.simple(var("var")).build(); Assert.assertEquals("{var}", e.toString()); }
4647484950515253
} @Test public void testReserved() throws Exception { Expression e = Expression.reserved(var("var")).build(); Assert.assertEquals("{+var}", e.toString()); }
5354555657585960
} @Test public void testFragment() throws Exception { Expression e = Expression.fragment(var("var")).build(); Assert.assertEquals("{#var}", e.toString()); }
6061626364656667
} @Test public void testLabel() throws Exception { Expression e = Expression.label(var("var")).build(); Assert.assertEquals("{.var}", e.toString()); }
6768697071727374
} @Test public void testPath() throws Exception { Expression e = Expression.path(var("var")).build(); Assert.assertEquals("{/var}", e.toString()); }
7475767778798081
} @Test public void testMatrix() throws Exception { Expression e = Expression.matrix(var("var")).build(); Assert.assertEquals("{;var}", e.toString()); }
8182838485868788
} @Test public void testQuery() throws Exception { Expression e = Expression.query(var("var")).build(); Assert.assertEquals("{?var}", e.toString()); }