//============================================================================== // tribble/io/CharDfl.java //------------------------------------------------------------------------------ package tribble.io; // System imports import java.lang.String; // Local imports import tribble.io.CharI; /******************************************************************************* * Default generic source character. * *
* This is a default implementation of a character class that is capable of
* representing a single character. Such a class can be used to hold a single
* text character read from a source file, containing information in addition to
* the character code itself such as the source line, column number, and filename
* from which the character was read.
*
* @version $Revision: 1.1 $ $Date: 2001/05/30 16:27:08 $
* @since 2001-05-30
* @author
* David R. Tribble,
* david@tribble.com.
*
* Copyright ©2001 by David R. Tribble,
* all rights reserved.
*
* Permission is granted to freely use and distribute this source code
* provided that the original copyright and authorship notices remain
* intact.
*
* @see CharInputStreamI
*/
public class CharDfl
implements CharI
{
// Identification
/** Revision information. */
static final String REV =
"@(#)tribble/io/CharDfl.java $Revision: 1.1 $ $Date: 2001/05/30 16:27:08 $\n";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Protected variables
/** Character code. */
protected int m_char;
/** Source line number. */
protected int m_lineNo;
/** Source column number. */
protected int m_colNo;
/** Source filename. */
protected String m_fName;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Public constructor methods
/***************************************************************************
* Constructor.
*
* @since 1.1, 2001-05-30
*/
public CharDfl()
{
// Do nothing
}
/***************************************************************************
* Constructor.
* Establishes the character code of this character.
*
* @param ch
* The character code for this character.
*
* @since 1.1, 2001-05-30
*/
public CharDfl(char ch)
{
m_char = ch;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Public methods
/***************************************************************************
* Establishes the character code of this character.
*
* @param ch
* The character code for this character.
*
* @since 1.1, 2001-05-30
*/
public void setChar(char ch)
//implements tribble.io.CharI
{
m_char = ch;
}
/***************************************************************************
* Retrieves the character code of this character.
*
* @return
* The character code for this character.
*
* @since 1.1, 2001-05-30
*/
public char getChar()
//implements tribble.io.CharI
{
return ((char) m_char);
}
/***************************************************************************
* Establishes the source line number and column number of this character.
*
* @param ln
* The source line number for this character.
*
* @param col
* The source column number for this token.
*
* @since 1.1, 2001-05-30
*/
public void setLineNo(int ln, int col)
//implements tribble.io.CharI
{
m_lineNo = ln;
m_colNo = col;
}
/***************************************************************************
* Retrieves the source line number of this character.
*
* @return
* The source line number for this character.
*
* @since 1.1, 2001-05-30
*/
public int getLineNo()
//implements tribble.io.CharI
{
return (m_lineNo);
}
/***************************************************************************
* Retrieves the source column number of this character.
*
* @return
* The source column number for this character.
*
* @since 1.1, 2001-05-30
*/
public int getColNo()
//implements tribble.io.CharI
{
return (m_colNo);
}
/***************************************************************************
* Establishes the source filename of this character.
*
* @param fname
* The source filename for this character.
*
* @since 1.1, 2001-05-30
*/
public void setFileName(String fname)
//implements tribble.io.CharI
{
m_fName = fname;
}
/***************************************************************************
* Retrieves the source filename of this character.
*
* @return
* The source filename for this character.
*
* @since 1.1, 2001-05-30
*/
public String getFileName()
//implements tribble.io.CharI
{
return (m_fName);
}
}
// End CharDfl.java