コード例 #1
0
 /**
  * This is used to clear all previously collected tokens. This allows the parser to be reused when
  * there are multiple source strings to be parsed. Clearing of the tokens is performed when the
  * parser is initialized.
  */
 private void clear() {
   primary.clear();
   secondary.clear();
   charset.clear();
   name.clear();
   value.clear();
   type.clear();
   map.clear();
   off = 0;
 }
コード例 #2
0
  /**
   * This will return the value of the MIME type as a string. This will concatenate the primary and
   * secondary type values and add the <code>charset</code> parameter to the type which will
   * recreate the content type.
   *
   * @param text this is the buffer to encode the parameters to
   * @return this returns the string representation of the type
   */
  private String encode(StringBuilder text) {
    for (String name : map) {
      String value = map.get(name);

      text.append("; ");
      text.append(name);

      if (value != null) {
        text.append("=");
        text.append(value);
        ;
      }
    }
    return text.toString();
  }
コード例 #3
0
 /**
  * This will add the given name and value to the parameters map. If any previous value of the
  * given name has been inserted into the map then this will overwrite that value. This is used to
  * ensure that the string value is inserted to the map.
  *
  * @param name this is the name of the value to be inserted
  * @param value this is the value of a that is to be inserted
  */
 private void insert(ParseBuffer name, ParseBuffer value) {
   map.put(name.toString(), value.toString());
 }
コード例 #4
0
 /**
  * This will add a named parameter to the content type header. If a parameter of the specified
  * name has already been added to the header then that value will be replaced by the new value
  * given. Parameters such as the <code>boundary</code> as well as other common parameters can be
  * set with this method.
  *
  * @param name this is the name of the parameter to be added
  * @param value this is the value to associate with the name
  */
 public void setParameter(String name, String value) {
   map.put(name, value);
 }
コード例 #5
0
 /**
  * This is used to retrieve an arbitrary parameter from the MIME type header. This ensures that
  * values for <code>boundary</code> or other such parameters are not lost when the header is
  * parsed. This will return the value, unquoted if required, as a string.
  *
  * @param name this is the name of the parameter to be retrieved
  * @return this is the value for the parameter, or null if empty
  */
 public String getParameter(String name) {
   return map.get(name);
 }