/** * Copy string builder content to parameter name and reset the builder. * * @throws SyntaxException if parameter name is empty. * @throws UnsupportedEncodingException if name is not properly encoded UTF-8. */ public void commitName() throws UnsupportedEncodingException { if (builder.length() == 0) { throw new SyntaxException("Invalid query string. Empty parameter name."); } name = URLDecoder.decode(builder.toString(), "UTF-8"); builder.setLength(0); }
/** * Decode string builder content and copy result to parameter value. * * @return true if parameter value was decoded. * @throws SyntaxException if parameter name is null, most probably because of missing '=' separator. * @throws UnsupportedEncodingException if value is not properly encoded UTF-8. */ public boolean commitValue() throws UnsupportedEncodingException { // name is null only if commit name was not invoked // if builder has some data but name is null then '=' separator was not found // this condition can occur only if query string ends before separator found // do not test for empty name since is already tested on commit name if (builder.length() > 0 && name == null) { throw new SyntaxException("Invalid query string parameter |%s|. Missing name/value separator.", builder.toString()); } if (builder.length() == 0) { return false; } value = URLDecoder.decode(builder.toString(), "UTF-8"); return true; }
throw new SyntaxException("Invalid content type parameters |%s|. Value is empty.", expression); throw new SyntaxException("Invalid content type parameters |%s|. Name override |%s|.", expression, name); throw new SyntaxException("Invalid content type parameters |%s|. Missing name/value separator.", expression);
throw new SyntaxException("Invalid pairs expression |%s|. First value is empty.", expression); throw new SyntaxException("Duplicated pairs in expression |%s|.", expression); throw new SyntaxException("Invalid pairs expression |%s|. Missing pair separator |%s|.", expression, separator);
throw new SyntaxException("Invalid content type value |%s|. Missing subtype separator.", value);
throw new SyntaxException("Invalid query string. Empty parameter name."); } else { throw new SyntaxException("Invalid query string parameter |%s|. Missing name/value separator.", parameter.getBuilder()); throw new SyntaxException("Invalid query string parameter |%s|. Unescaped '=' character.", parameter.getBuilder());