FileDocCategorySizeDatePackage
ContentTypeParser.javaAPI DocAndroid 1.5 API7588Wed May 06 22:42:46 BST 2009org.apache.james.mime4j.field.contenttype.parser

ContentTypeParser

public class ContentTypeParser extends Object implements ContentTypeParserConstants

Fields Summary
private String
type
private String
subtype
private ArrayList
paramNames
private ArrayList
paramValues
public ContentTypeParserTokenManager
token_source
SimpleCharStream
jj_input_stream
public Token
token
public Token
jj_nt
private int
jj_ntk
private int
jj_gen
private final int[]
jj_la1
private static int[]
jj_la1_0
private Vector
jj_expentries
private int[]
jj_expentry
private int
jj_kind
Constructors Summary
public ContentTypeParser(InputStream stream)

     this(stream, null);
  
public ContentTypeParser(InputStream stream, String encoding)

    try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source = new ContentTypeParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 3; i++) jj_la1[i] = -1;
  
public ContentTypeParser(Reader stream)

    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new ContentTypeParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 3; i++) jj_la1[i] = -1;
  
public ContentTypeParser(ContentTypeParserTokenManager tm)

    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 3; i++) jj_la1[i] = -1;
  
Methods Summary
public voidReInit(java.io.InputStream stream)

     ReInit(stream, null);
  
public voidReInit(java.io.InputStream stream, java.lang.String encoding)

    try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 3; i++) jj_la1[i] = -1;
  
public voidReInit(java.io.Reader stream)

    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 3; i++) jj_la1[i] = -1;
  
public voidReInit(ContentTypeParserTokenManager tm)

    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 3; i++) jj_la1[i] = -1;
  
public final voiddisable_tracing()

  
public final voidenable_tracing()

  
public ParseExceptiongenerateParseException()


     
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[24];
    for (int i = 0; i < 24; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 3; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<<j)) != 0) {
            la1tokens[j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 24; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.addElement(jj_expentry);
      }
    }
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = (int[])jj_expentries.elementAt(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  
public final TokengetNextToken()

    if (token.next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    jj_gen++;
    return token;
  
public java.util.ArrayListgetParamNames()

 return paramNames; 
public java.util.ArrayListgetParamValues()

 return paramValues; 
public java.lang.StringgetSubType()

 return subtype; 
public final TokengetToken(int index)

    Token t = token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  
public java.lang.StringgetType()


            return type; 
private final Tokenjj_consume_token(int kind)

    Token oldToken;
    if ((oldToken = token).next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    if (token.kind == kind) {
      jj_gen++;
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  
private static voidjj_la1_0()

   
      jj_la1_0();
   
      jj_la1_0 = new int[] {0x2,0x10,0x280000,};
   
private final intjj_ntk()

    if ((jj_nt=token.next) == null)
      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
    else
      return (jj_ntk = jj_nt.kind);
  
public static voidmain(java.lang.String[] args)

        while (true) {
            try {
                ContentTypeParser parser = new ContentTypeParser(System.in);
                parser.parseLine();
            } catch (Exception x) {
                x.printStackTrace();
                return;
            }
        }
    
public final voidparameter()

        Token attrib;
        String val;
    attrib = jj_consume_token(ATOKEN);
    jj_consume_token(5);
    val = value();
                paramNames.add(attrib.image);
                paramValues.add(val);
  
public final voidparse()

        Token type;
        Token subtype;
    type = jj_consume_token(ATOKEN);
    jj_consume_token(3);
    subtype = jj_consume_token(ATOKEN);
                this.type = type.image;
                this.subtype = subtype.image;
    label_1:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case 4:
        ;
        break;
      default:
        jj_la1[1] = jj_gen;
        break label_1;
      }
      jj_consume_token(4);
      parameter();
    }
  
public final voidparseAll()

    parse();
    jj_consume_token(0);
  
public final voidparseLine()

    parse();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 1:
      jj_consume_token(1);
      break;
    default:
      jj_la1[0] = jj_gen;
      ;
    }
    jj_consume_token(2);
  
public final java.lang.Stringvalue()

 Token t;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case ATOKEN:
      t = jj_consume_token(ATOKEN);
      break;
    case QUOTEDSTRING:
      t = jj_consume_token(QUOTEDSTRING);
      break;
    default:
      jj_la1[2] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
          {if (true) return t.image;}
    throw new Error("Missing return statement in function");