View Javadoc
1   /* Generated By:JavaCC: Do not edit this line. CharStream.java Version 0.7pre6 */
2   
3   /**
4    * Redistribution and use of this software and associated documentation
5    * ("Software"), with or without modification, are permitted provided
6    * that the following conditions are met:
7    *
8    * 1. Redistributions of source code must retain copyright
9    *    statements and notices.  Redistributions must also contain a
10   *    copy of this document.
11   *
12   * 2. Redistributions in binary form must reproduce the
13   *    above copyright notice, this list of conditions and the
14   *    following disclaimer in the documentation and/or other
15   *    materials provided with the distribution.
16   *
17   * 3. The name "Exolab" must not be used to endorse or promote
18   *    products derived from this Software without prior written
19   *    permission of Intalio, Inc.  For written permission,
20   *    please contact info@exolab.org.
21   *
22   * 4. Products derived from this Software may not be called "Exolab"
23   *    nor may "Exolab" appear in their names without prior written
24   *    permission of Intalio, Inc. Exolab is a registered
25   *    trademark of Intalio, Inc.
26   *
27   * 5. Due credit should be given to the Exolab Project
28   *    (http://www.exolab.org/).
29   *
30   * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS
31   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
32   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
33   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
34   * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
35   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
37   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
41   * OF THE POSSIBILITY OF SUCH DAMAGE.
42   *
43   * Copyright 2000 (C) Intalio Inc. All Rights Reserved.
44   *
45   * $Id$
46   */
47  
48  package org.exolab.castor.xml.dtd.parser;
49  
50  /**
51   * This interface describes a character stream that maintains line and
52   * column number positions of the characters.  It also has the capability
53   * to backup the stream to some extent.  An implementation of this
54   * interface is used in the TokenManager implementation generated by
55   * JavaCCParser.
56   * <p>
57   * All the methods except backup can be implemented in any fashion. backup
58   * needs to be implemented correctly for the correct operation of the lexer.
59   * Rest of the methods are all used to get information like line number,
60   * column number and the String that constitutes a token and are not used
61   * by the lexer. Hence their implementation won't affect the generated lexer's
62   * operation.
63   *
64   * @author Generated automatically by <b>JavaCC</b>
65   * @version Version 0.7pre6
66   */
67  abstract public interface CharStream {
68  
69    /**
70     * Returns the next character from the selected input.  The method
71     * of selecting the input is the responsibility of the class
72     * implementing this interface.  Can throw any java.io.IOException.
73     */
74    abstract public char readChar() throws java.io.IOException;
75  
76    /**
77     * Returns the column position of the character last read.
78     * @deprecated
79     * @see #getEndColumn
80     */
81    abstract public int getColumn();
82  
83    /**
84     * Returns the line number of the character last read.
85     * @deprecated
86     * @see #getEndLine
87     */
88    abstract public int getLine();
89  
90    /**
91     * Returns the column number of the last character for current token (being
92     * matched after the last call to BeginTOken).
93     */
94    abstract public int getEndColumn();
95  
96    /**
97     * Returns the line number of the last character for current token (being
98     * matched after the last call to BeginTOken).
99     */
100   abstract public int getEndLine();
101 
102   /**
103    * Returns the column number of the first character for current token (being
104    * matched after the last call to BeginTOken).
105    */
106   abstract public int getBeginColumn();
107 
108   /**
109    * Returns the line number of the first character for current token (being
110    * matched after the last call to BeginTOken).
111    */
112   abstract public int getBeginLine();
113 
114   /**
115    * Backs up the input stream by amount steps. Lexer calls this method if it
116    * had already read some characters, but could not use them to match a
117    * (longer) token. So, they will be used again as the prefix of the next
118    * token and it is the implemetation's responsibility to do this right.
119    */
120   abstract public void backup(int amount);
121 
122   /**
123    * Returns the next character that marks the beginning of the next token.
124    * All characters must remain in the buffer between two successive calls
125    * to this method to implement backup correctly.
126    */
127   abstract public char BeginToken() throws java.io.IOException;
128 
129   /**
130    * Returns a string made up of characters from the marked token beginning
131    * to the current buffer position. Implementations have the choice of returning
132    * anything that they want to. For example, for efficiency, one might decide
133    * to just return null, which is a valid implementation.
134    */
135   abstract public String GetImage();
136 
137   /**
138    * Returns an array of characters that make up the suffix of length 'len' for
139    * the currently matched token. This is used to build up the matched string
140    * for use in actions in the case of MORE. A simple and inefficient
141    * implementation of this is as follows :
142    * <pre>
143    *   {
144    *      String t = GetImage();
145    *      return t.substring(t.length() - len, t.length()).toCharArray();
146    *   }
147    * </pre>
148    */
149   abstract public char[] GetSuffix(int len);
150 
151   /**
152    * The lexer calls this function to indicate that it is done with the stream
153    * and hence implementations can free any resources held by this class.
154    * Again, the body of this function can be just empty and it will not
155    * affect the lexer's operation.
156    */
157   abstract public void Done();
158 
159 }