コード例 #1
0
 /**
  * This reads the subtype from the MIME type. This will fill the subtype <code>ParseBuffer</code>.
  * This will read all chars upto but not including the first instance of a ';'. The subtype of a
  * media-type as defined by RFC 2616 is <code>type/subtype;param=val;param2=val</code>.
  */
 private void secondary() {
   while (off < count) {
     if (buf[off] == ';') {
       break;
     }
     type.append(buf[off]);
     secondary.append(buf[off]);
     off++;
   }
 }
コード例 #2
0
 /**
  * This reads the type from the MIME type. This will fill the type <code>ParseBuffer</code>. This
  * will read all chars upto but not including the first instance of a '/'. The type of a
  * media-type as defined by RFC 2616 is <code>type/subtype;param=val;param2=val</code>.
  */
 private void primary() {
   while (off < count) {
     if (buf[off] == '/') {
       type.append('/');
       break;
     }
     type.append(buf[off]);
     primary.append(buf[off]);
     off++;
   }
 }
コード例 #3
0
 /**
  * This will simply read all characters from the buffer before the first '=' character. This
  * represents a parameter name (see RFC 2616 for token). The parameter name is not buffered it is
  * simply read from the buffer. This will not cause an <code>IndexOutOfBoundsException</code> as
  * each offset is checked before it is acccessed.
  */
 private void name() {
   while (off < count) {
     if (buf[off] == '=') {
       break;
     }
     name.append(buf[off]);
     off++;
   }
 }
コード例 #4
0
 /**
  * This is used to read the value from the <code>charset</code> param. This will fill the <code>
  * charset</code> <code>ParseBuffer</code> and with the <code>charset</code> value. This will read
  * a literal or a token as the <code>charset</code> value. If the <code>charset</code> is a
  * literal then the quotes will be read as part of the charset.
  */
 private void charset() {
   if (buf[off] == '"') {
     charset.append('"');
     for (off++; off < count; ) {
       charset.append(buf[off]);
       if (buf[off++] == '"')
         if (buf[off - 2] != '\\') {
           break;
         }
     }
   } else {
     while (off < count) {
       if (buf[off] == ';') {
         break;
       }
       charset.append(buf[off]);
       off++;
     }
   }
 }
コード例 #5
0
 /**
  * This is used to read a parameters value from the buf. This will read all <code>char</code>'s
  * upto but excluding the first terminal <code>char</code> encountered from the off within the
  * buf, or if the value is a literal it will read a literal from the buffer (literal is any data
  * between quotes except if the quote is prefixed with a backward slash character).
  */
 private void value() {
   if (quote(buf[off])) {
     for (off++; off < count; ) {
       if (quote(buf[off])) {
         if (buf[++off - 2] != '\\') {
           break;
         }
       }
       value.append(buf[off++]);
     }
   } else {
     while (off < count) {
       if (buf[off] == ';') {
         break;
       }
       value.append(buf[off]);
       off++;
     }
   }
 }
コード例 #6
0
 /**
  * This sets the secondary type to whatever value is in the string provided is. If the string is
  * null then this will contain a null string for the secondary type of the parameter, which is
  * likely invalid in most cases.
  *
  * @param value the type to set for the primary type of this
  */
 public void setSecondary(String value) {
   type.reset(primary);
   type.append('/');
   type.append(value);
   secondary.reset(value);
 }