TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: JARI LAAKSONEN
date: 1997-03-28 21:58:00
subject: 04/11 Comment utilities for Java

========== CSplit: Version 2.0 ==========
========== CSplit: Begin part 4/11 ==========
        try
        {
            InFile = new FileInputStream (file);
        }
        catch (FileNotFoundException e)
        {
            System.err.println (e.toString());
            return false;
        }
        lines = 1;
        return true;
    }
    //==================================================================
    //
    // C++ version of this class uses unInit method for closing
    // open files. This Java version does nothing.
    //
    public void unInit() { }
    //==================================================================
    /**
     * Loop that reads the input file and calls the action processor
     * and the state processor.
     */
    public int run()
    {
        int theEvent;
        while (readChar() != EOF)
        {
            theEvent = getEvent();
            processActions (theEvent);
            processState (theEvent);
        }
        // Some action processors may need to do some extra processing
        // based on the state of the FSM after the file is processed.
        processActions (CPEvent.END_OF_FILE);
        return 0;
    }
    //==================================================================
    /**
     * @return the number of read lines.
     */
    public long getLines()
    {
        return lines;
    }
    //==================================================================
    /**
     * @return the value of last state.
     */
    public int getLastState()
    {
        return itsState;
    }
    //==================================================================
    /**
     * @return the value of last state as string.
     */
    public String getLastStateStr()
    {
        CPState st = new CPState (itsState);
        return st.toString();
    }
    //==================================================================
    /**
     * Print a string to output file.
     */
    public void print (String str)
    {
        int len = str.length();
        byte b[] = new byte[len];
        str.getBytes (0, len, b, 0);
        try
        {
            OutFile.write (b);
        }
        catch (IOException e)
        {
            System.err.println (e.toString());
        }
    }
    //==================================================================
    /**
     * Abstract method. This must be overridden in subclasses.
     */
    abstract protected void processActions (int theEvent);
    //==================================================================
    /**
     *  @return read character.
     */
    protected int getReadChar()
    {
        return ReadCh;
    }
    //==================================================================
    /**
     * Change current character to another.
     * @see CommentParser#PrintChar
     */
    protected void changeChar (int ch)
    {
        ReadCh = ch;
    }
    //==================================================================
    /**
     * Print a character to output file.
     */
    protected void print (int ch)
    {
        try
        {
            OutFile.write (ch);
        }
        catch (IOException e)
        {
            System.err.println (e.toString());
        }
    }
    //==================================================================
    /**
     * Print current character which can be the last read from the
     * input file or changed by the action processor.
     */
    protected void printChar()
    {
        if (ReadCh != EOF)
        {
            // emulate text mode output.
            // TODO: check runtime environment to distinguish
            //       DOS and UNIX style output.
========== CSplit: End part 4/11 crc: 4672 ==========
        // Albert                      email: jla@to.icl.fi
--- GoldED/2 2.50+
---------------
* Origin: Albert's Point/2 in Finland, Europe (2:221/360.20)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.