code: private void endExpression(int position) throws MalformedUriTemplateException
      {
  
          // an expression close brace is found without a start
          if (startedTemplate)
          {
              if (!expressionCaptureOn)
  
              {
                  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");
          }
      }
docs: Called when the end of an expression has been encountered.