protected void parseNameValueList(ParametersHeader parametersHeader) throws ParseException {
   parametersHeader.removeParameters();
   while (true) {
     this.lexer.SPorHT();
     NameValue nv = nameValue();
     parametersHeader.setParameter(nv.getName(), (String) nv.getValue());
     // eat white space
     this.lexer.SPorHT();
     if (lexer.lookAhead(0) != ';') break;
     else lexer.consume(1);
   }
 }
Beispiel #2
0
  /**
   * Sets the specified parameter.
   *
   * @param name name of the parameter
   * @param value value of the parameter.
   */
  public void setParameter(String name, String value) throws IllegalArgumentException {
    NameValue nv = super.parameters.getNameValue(name.toLowerCase());

    if (value == null) {
      throw new NullPointerException("null value");
    }

    boolean quoteStart = value.startsWith(Separators.DOUBLE_QUOTE);
    boolean quoteEnd = value.endsWith(Separators.DOUBLE_QUOTE);

    if ((quoteStart && !quoteEnd) || (!quoteStart && quoteEnd)) {
      throw new IllegalArgumentException(value + " : Unexpected DOUBLE_QUOTE");
    }

    if (quoteStart) { // quoteEnd is true in this case
      value = value.substring(1, value.length() - 1);
    }

    if (nv == null) {
      nv = new NameValue(name.toLowerCase(), value);

      nv.setQuotedValue();
      super.setParameter(nv);

    } else {
      nv.setValue(value);
    }
  }
 protected void parse(ParametersHeader parametersHeader) throws ParseException {
   this.lexer.SPorHT();
   while (lexer.lookAhead(0) == ';') {
     this.lexer.consume(1);
     // eat white space
     this.lexer.SPorHT();
     NameValue nv = nameValue();
     parametersHeader.setParameter(nv);
     // eat white space
     this.lexer.SPorHT();
   }
 }