    001    /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
    002    package org.apache.commons.jxpath.ri.parser;
    003
    004    /**
    005     * Describes the input token stream.
    006     */
    007
    008    public class Token {
    009
    010      /**
    011       * An integer that describes the kind of this token.  This numbering
    012       * system is determined by JavaCCParser, and a table of these numbers is
    013       * stored in the file ...Constants.java.
    014       */
    015      public int kind;
    016
    017      /**
    018       * beginLine and beginColumn describe the position of the first character
    019       * of this token; endLine and endColumn describe the position of the
    020       * last character of this token.
    021       */
    022      public int beginLine, beginColumn, endLine, endColumn;
    023
    024      /**
    025       * The string image of the token.
    026       */
    027      public String image;
    028
    029      /**
    030       * A reference to the next regular (non-special) token from the input
    031       * stream.  If this is the last token from the input stream, or if the
    032       * token manager has not read tokens beyond this one, this field is
    033       * set to null.  This is true only if this token is also a regular
    034       * token.  Otherwise, see below for a description of the contents of
    035       * this field.
    036       */
    037      public Token next;
    038
    039      /**
    040       * This field is used to access special tokens that occur prior to this
    041       * token, but after the immediately preceding regular (non-special) token.
    042       * If there are no such special tokens, this field is set to null.
    043       * When there are more than one such special token, this field refers
    044       * to the last of these special tokens, which in turn refers to the next
    045       * previous special token through its specialToken field, and so on
    046       * until the first special token (whose specialToken field is null).
    047       * The next fields of special tokens refer to other special tokens that
    048       * immediately follow it (without an intervening regular token).  If there
    049       * is no such token, this field is null.
    050       */
    051      public Token specialToken;
    052
    053      /**
    054       * Returns the image.
    055       */
    056      public String toString()
    057      {
    058         return image;
    059      }
    060
    061      /**
    062       * Returns a new Token object, by default. However, if you want, you
    063       * can create and return subclass objects based on the value of ofKind.
    064       * Simply add the cases to the switch for all those special cases.
    065       * For example, if you have a subclass of Token called IDToken that
    066       * you want to create if ofKind is ID, simlpy add something like :
    067       *
    068       *    case MyParserConstants.ID : return new IDToken();
    069       *
    070       * to the following switch statement. Then you can cast matchedToken
    071       * variable to the appropriate type and use it in your lexical actions.
    072       */
    073      public static final Token newToken(int ofKind)
    074      {
    075         switch(ofKind)
    076         {
    077           default : return new Token();
    078         }
    079      }
    080
    081    }