예제 #1
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);
    }
  }
예제 #2
0
  @DSGenerator(
      tool_name = "Doppelganger",
      tool_version = "2.0",
      generated_on = "2013-12-30 12:55:51.655 -0500",
      hash_original_method = "2B8F776DAFC357EFC899FF251A427EF6",
      hash_generated_method = "FED05485A0974D95153CC926E74EE894")
  protected NameValue nameValue(char separator) throws ParseException {
    if (debug) dbg_enter("nameValue");
    try {

      lexer.match(LexerCore.ID);
      Token name = lexer.getNextToken();
      // eat white space.
      lexer.SPorHT();
      try {

        boolean quoted = false;

        char la = lexer.lookAhead(0);

        if (la == separator) {
          lexer.consume(1);
          lexer.SPorHT();
          String str = null;
          boolean isFlag = false;
          if (lexer.lookAhead(0) == '\"') {
            str = lexer.quotedString();
            quoted = true;
          } else {
            lexer.match(LexerCore.ID);
            Token value = lexer.getNextToken();
            str = value.tokenValue;

            // JvB: flag parameters must be empty string!
            if (str == null) {
              str = "";
              isFlag = true;
            }
          }
          NameValue nv = new NameValue(name.tokenValue, str, isFlag);
          if (quoted) nv.setQuotedValue();
          return nv;
        } else {
          // JvB: flag parameters must be empty string!
          return new NameValue(name.tokenValue, "", true);
        }
      } catch (ParseException ex) {
        return new NameValue(name.tokenValue, null, false);
      }

    } finally {
      if (debug) dbg_leave("nameValue");
    }
  }
예제 #3
0
 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);
   }
 }
예제 #4
0
 /**
  * Sets the specified parameter.
  *
  * @param nv parameter's name/value pair
  */
 public void setParameter(NameValue nv) {
   Object val = nv.getValue();
   setParameter(nv.getName(), (val == null) ? null : val.toString());
 }
예제 #5
0
 public void setCredential(NameValue nameValue) {
   if (nameValue.getName().compareToIgnoreCase(URI) == 0) nameValue.setQuotedValue();
   else if (nameValue.getName().compareToIgnoreCase(NONCE) == 0) nameValue.setQuotedValue();
   else if (nameValue.getName().compareToIgnoreCase(REALM) == 0) nameValue.setQuotedValue();
   else if (nameValue.getName().compareToIgnoreCase(CNONCE) == 0) nameValue.setQuotedValue();
   else if (nameValue.getName().compareToIgnoreCase(RESPONSE) == 0) nameValue.setQuotedValue();
   else if (nameValue.getName().compareToIgnoreCase(OPAQUE) == 0) nameValue.setQuotedValue();
   else if (nameValue.getName().compareToIgnoreCase(USERNAME) == 0) nameValue.setQuotedValue();
   else if (nameValue.getName().compareToIgnoreCase(DOMAIN) == 0) nameValue.setQuotedValue();
   parameters.set(nameValue);
 }
예제 #6
0
 public Object clone() {
   NameValue retval = (NameValue) super.clone();
   if (value != null) retval.value = makeClone(value);
   return retval;
 }