This appendix is a reference guide for the Java Intranet Framework (JIF) classes that were developed in this book. Listed here are all the public and protected members of each JIF class.
In this appendix, you'll look at each package in JIF and then each class within each package. This appendix is meant as a reference for you to go back to instead of constantly looking at the source code.
The jif.awt package contains many classes that extend and enhance several of the stock Java awt classes. These include a calendar, a three-dimensional container, and a tabbed panel, just to mention a few.
This class is a JifPanel that adds calendar functionality. Each day in the calendar is a button. When pressed, the button sends an ACTION_EVENT event to its parent container. The selected date is passed in the argument.
public class CalendarPanel extends JifPanel
{
// Public constructors
public CalendarPanel();
public CalendarPanel( int style );
// Public Methods
public Date getSelectedDate();
public void hilightButton( Button button, boolean onOff );
}
This interface defines the constants that a class can use to provide three-dimensional effects. It contains no methods.
public interface Effects
{
// Public Text Styles
public final static int TEXT_NORMAL = 0;
public final static int TEXT_LOWERED = 1;
public final static int TEXT_RAISED = 2;
public final static int TEXT_SHADOW = 3;
// Public Text placements
public final static int CENTER = 0;
public final static int LEFT = 1;
public final static int RIGHT = 2;
// Public 3D Looks
public final static int NONE = 0;
public final static int FLAT = 1;
public final static int GROOVED = 2;
public final static int LOWERED = 4;
public final static int ROUNDED = 8;
public final static int RAISED = 16;
public final static int RIDGED = 32;
public final static int CAPTION = 64;
}
This class extends JifPanel to display a graphic image. You can specify the x and y offset with which the image is displayed within the rectangle.
public class ImagePanel extends JifPanel
{
// Protected class variables
protected Image myImage;
protected int offset;
// Public constructors
public ImagePanel( String imageToUse, int offset )
throws FileNotFoundException;
public ImagePanel( String imageToUse )
throws FileNotFoundException;
// Public methods
public void addNotify();
public void sizeSelf();
public void paint( Graphics g );
}
This class extends Java's Checkbox adding tab recognition and SQL code generation. The JifCheckbox produces a Y or N value in SQL. It is perfect for use with indicators.
public class JifCheckbox extends Checkbox implements SQLFactory
{
// Protected class variables
protected String columnName = "";
protected boolean dataChange = false;
protected boolean initialized = false;
protected boolean primaryKey = false;
protected boolean isNumericData = false;
// Public constructors
public JifCheckbox();
public JifCheckbox( String columnName );
public JifCheckbox( String columnName, boolean primaryKey );
// Public methods
public void setColumnName( String columnName );
public String getColumnName();
public void setNumeric( boolean onOff );
public void setPrimaryKey( boolean primaryKey );
public boolean isPrimaryKey();
public void setState( boolean state );
public boolean didDataChange();
public void reset();
public String generateUpdateSQL( boolean addSet );
public String generateInsertSQL( boolean addParen );
public String getSQL( boolean forWhere );
}
This class extends Java's Dialog class and adds the capability to center itself on the entire screen or within its parent's frame.
public class JifDialog extends Dialog
{
// Public constructors
public JifDialog( Frame parent, boolean modal );
public JifDialog( Frame parent, String title, boolean modal );
// Public methods
public void center( boolean onScreen );
}
This class extends JifPanel to implement a multiline label. The implementation is quite simple, thus the object has no added functionality.
public class JifLabel extends JifPanel
{
// Public constructor
public JifLabel( String s );
}
This class extends Java's Panel and adds many features-the coolest of which are some three-dimensional effects. These effects are defined by the Effects interface and implemented by this class. In addition, the JifPanel implements the JifMessage interface allowing it to send JifMesssage messages.
public class JifPanel extends Panel implements Effects, JifMessage
{
// Constants
public final static int TAB_KEY;
public final static int TEXT_OFFSET;
// Protected class variables
protected int textStyle = TEXT_NORMAL;
protected int textPlacement = CENTER;
protected int style = NONE;
protected int thickness = 2;
protected int myWidth;
protected int myHeight;
protected String text = null;
protected boolean skipLeft = false;
protected boolean skipTop = false;
protected boolean skipBottom = false;
protected boolean skipRight = false;
protected int currentPos = 0;
// Public constructors
public JifPanel();
public JifPanel( int style );
public JifPanel( String text );
public JifPanel( int style, String text );
public JifPanel( int style, int width, int height, String text );
public JifPanel( int style, int width, int height );
// Public methods
public void addNotify();
public void addWithConstraints( Component comp, String constraints );
protected String buildComponentList( JifPanel me, Vector valueList,
Vector columnList, String whereClause );
public void drawFrame( Graphics g );
public void drawtext( Graphics g );
protected Component findChild( JifPanel p, String name );
protected int findNextComponent( int startPos );
protected int findPreviousComponent( int startPos );
public synchronized void focusForward();
public synchronized void focusBackward();
public String generateInsertSQL( String tableName );
public String generateUpdateSQL( String tableName );
public void getMetrics();
public boolean isStyleSet( int check );
public Dimension minimumSize();
public void paint( Graphics g );
public Dimension preferredSize();
public void sendJifMessage( Event event, int msg );
public void setChildValue( String name, String value );
public void setChildValue( String name, int value );
public void setFocus( Component target );
public void setFont( Font f );
public void setSkip( String which, boolean onOff );
public void setStyle( int style );
public void setText( String newText, int textStyle, int placement );
public void setText( String newText );
public void setTextPlacement( int placement );
public void setTextStyle( int textStyle );
public void setThickness( int thick );
}
This class is used by the JifTabPanel to hold all of the panes. It contains a CardLayout to manage them.
public class JifPanePanel extends JifPanel
{
// Public constructors
public JifPanePanel();
// Public methods
public void addPane( String name, Component comp );
public void selectPane( String paneName );
}
This class implements a tabbed panel by extending the JifPanel and adding some pane management techniques. This class is the master class, and the two helper classes (JifPanePanel and JifTabSelector) implement the pane swapping and the tab selection.
public class JifTabPanel extends JifPanel
{
// Protected instance variables
protected JifPanePanel panePanel = new JifPanePanel();
protected JifTabSelector selector = new JifTabSelector( panePanel );
// Public constructor
public JifTabPanel();
// Public methods
public void addPane( String name, Component comp );
public void selectPane( String name );
}
This is a helper class for the JifTabPanel object implementing the actual tabs. It is responsible for drawing the tabs and communicating with the JifTabPanel about which tab has been clicked. This class extends Canvas so that it can draw custom tabs.
public class JifTabSelector extends Canvas
{
// Public instance variables
public boolean fullWidthTabs = false;
// Protected instance variables
protected Vector tabs = new Vector();
protected int currentTab = 0;
protected Font normalFont = null;
protected Font selFont = null;
protected int realWidth = 0, realHeight = 0;
protected JifPanePanel myPanePanel = null;
// Public constructors
public JifTabSelector( JifPanePanel jpp );
public void addPane( String paneName );
public Dimension minimumSize();
public void paint( Graphics g );
public Dimension preferredSize();
public void selectPane( String paneName );
public void selectPane( int which );
}
This class extends Java's TextArea, adding tab recognition and SQL code generation. JifTextAreas produce a string value in SQL. In addition, you can restrict the data that is entered in a JifTextArea by using the setStyle() method. The types of input restrictions are as follows:
public class JifTextArea extends TextArea implements SQLFactory
{
// Constants
public static final int ANY = 0;
public static final int LOWER = 1;
public static final int UPPER = 2;
public static final int NUMERIC = 3;
// Protected instance variables
protected String columnName = "";
protected boolean dataChange = false;
protected boolean initialized = false;
protected boolean primaryKey = false;
protected boolean isNumericData = false;
protected boolean isDateData = false;
protected int style = ANY;
// Public constructors
public JifTextArea( String s );
public JifTextArea( String s, String columnName );
public JifTextArea( String s, String columnName, boolean primaryKey );
public JifTextArea( int rows, int cols );
public JifTextArea( int rows, int cols, String columnName );
public JifTextArea( int rows, int cols, String columnName,
boolean primaryKey );
// Public methods
public boolean didDataChange();
public synchronized void disable();
public synchronized void enable();
public String generateInsertSQL( boolean addParen );
public String generateUpdateSQL( boolean addSet );
public String getColumnName();
public String getSQL( boolean forWhere );
public boolean isPrimaryKey();
public void reset();
public void setColumnName( String columnName );
public void setDate( boolean onOff );
public void setNumeric( boolean onOff );
public void setPrimaryKey( boolean primaryKey );
public void setStyle( int style );
public void setText( String text );
}
This class extends Java's TextField by adding tab recognition and SQL code generation. JifTextFields produce a string value in SQL. In addition, you can restrict the data that is entered in a JifTextField by using the setStyle() method. The types of input restrictions are as follows:
public class JifTextField extends TextField implements SQLFactory
{
// Constants
public static final int TAB_KEY = 9;
public static final int ANY = 0;
public static final int LOWER = 1;
public static final int UPPER = 2;
public static final int NUMERIC = 3;
// Protected instance variables
protected String columnName = "";
protected boolean dataChange = false;
protected boolean initialized = false;
protected boolean primaryKey = false;
protected boolean isNumericData = false;
protected boolean isDateData = false;
protected int style = ANY;
// Public Constructors
public JifTextField()
public JifTextField( String s )
public JifTextField( String s, String columnName )
public JifTextField( String s, String columnName, boolean primaryKey )
public JifTextField( int cols )
public JifTextField( int cols, String columnName )
public JifTextField( int cols, String columnName, boolean primaryKey )
// Public methods
public void setStyle( int style )
public void setColumnName( String columnName )
public String getColumnName()
public void setNumeric( boolean onOff )
public void setDate( boolean onOff )
public void setPrimaryKey( boolean primaryKey )
public boolean isPrimaryKey()
public boolean didDataChange()
public void reset()
public String generateUpdateSQL( boolean addSet )
public String generateInsertSQL( boolean addParen )
public String getSQL( boolean forWhere )
public void setText( String text )
public synchronized void enable()
public synchronized void disable()
}
This class extends the JifDialog class to provide a popup message box. The class can be used to display information to the user, such as warnings, errors, or other informational items. You can optionally display an image in front of the text. There are four built-in images to choose from:
public class MessageBox extends JifDialog
{
// Constants
public static final String INFO = "Information.gif";
public static final String EXCLAMATION = "Exclamation.gif";
public static final String STOP = "Stop.gif";
public static final String QUESTION = "Question.gif";
// Public constructors
public MessageBox( Frame parent, String title, String message,
String iconToUse );
public MessageBox( Frame parent, String title, String message,
String iconToUse, boolean addButtons );
public MessageBox( Frame parent, String title, String message );
}
This abstract class can be used to quickly build picklists of data. Simply supply an init() method that fills the List myList with data. You receive an ACTION_EVENT event notifying you of the user's selection.
public abstract class PickList extends JifDialog
{
// Protected instance variables
protected Button okButton = new Button( "Ok" );
protected Button cancelButton = new Button( "Cancel" );
protected List myList = new List( 10, false );
// Public constructor
public PickList( Frame daddy, String title )
// Public method
public abstract void init();
}
This class extends the MessageBox class to provide the same functionality with a configurable number of buttons. This allows you to produce "Yes, No, or Cancel?" type queries among others. Simply pass a string of button names separated by commas to the constructor.
public class ResponseDialog extends MessageBox
{
// Protected instance variables
protected Button[] buttonList;
protected int buttonCount;
// Public Constructor
public ResponseDialog( Frame parent, String title, String message,
String buttons );
}
This class implements functionality that can be used in simple database applications.
public abstract class SimpleDBUI extends JifPanel
{
// Public instance variables
public Button saveButton = new Button( "Save" );
public Button clearButton = new Button( "Clear" );
public Button newButton = new Button( "New" );
public Button deleteButton = new Button( "Delete" );
public Button chooseButton = new Button( "Choose" );
public Button closeButton = new Button( "Close" );
// Public constructor
public SimpleDBUI( SimpleDBJiflet jiflet );
// Public methods
public SimpleDBJiflet getJiflet();
public void setJiflet( SimpleDBJiflet jiflet );
public abstract void moveToScreen();
public abstract void clearScreen();
public abstract void moveFromScreen();
}
This class implements a single-line, sunken status bar that can be found in almost every microcomputer software package.
public class StatusBar extends JifPanel
{
// Public constructor
public StatusBar();
// Public Methods
public void clear();
public Dimension preferredSize();
}
The jif.jiflet package contains classes that pull together many of the other packages into one unit. This unit, the Jiflet, can be used as a base for almost any type of application. In addition, it provides many of the niceties of Java applets without the security restrictions.
This interface defines the methods that a Jiflet must provide.
public interface JifApplication
{
// Public methods
public void init();
public void run();
public void destroy();
}
This interface provides the standard JifMessage constants and the method needed to send them. Any class can implement this interface.
public interface JifMessage
{
// Constants
public static final int NEW = 0;
public static final int CLEAR = 1;
public static final int SAVE = 2;
public static final int DELETE = 3;
public static final int CUT = 4;
public static final int COPY = 5;
public static final int PASTE = 6;
public static final int HELP_WINDOW = 7;
public static final int HELP_CONTEXT = 8;
public static final int HELP_ABOUT = 9;
public static final int HELP_HELP = 10;
public static final int DATA_chANGE = 11;
public static final int chOOSE = 12;
public static final int CLOSE = 13;
// Public method
public void sendJifMessage( Event event, int msg );
}
This class is the applet-like class that implements the model intranet application shell as described in Chapter 7, "A Model Intranet Application."
public abstract class Jiflet extends Frame implements JifApplication, Log
{
// Protected instance variables
protected ConfigProperties configProperties;
protected String appName;
protected boolean appVerbosity = false;
protected DiskLog appLogFile;
protected ScreenLog defaultLog;
protected StatusBar myStatusBar = null;
protected boolean activeFlag = false;
// Public constructors
public Jiflet();
public Jiflet( String title );
public Jiflet( String title, String name, String args[] );
public Jiflet( String title, String name, String args[], boolean verbosity );
// Public methods
public void run();
public void destroy();
public void setVerboseMode( boolean whichWay );
public void verboseLog( char logLevel, String logEntry );
public void verboseLog( String logEntry );
public void errorLog( String logEntry );
public void log( char logLevel, String logEntry );
public void log( String logEntry );
protected boolean handleMenuEvent( Event event, Object arg );
public boolean shutDown( int level );
public boolean shutDown();
public void suicide( Exception e, String logLine, int level );
public void suicide( String logLine );
public void suicide( String logLine, int level );
public void suicide( Exception e );
public void suicide( Exception e, String logLine );
public void center();
public void enableStatusBar( String text );
public void enableStatusBar();
public void showStatus( String text );
public void clearStatus();
protected void setConnector( DBConnector aConnector );
public DBConnector getConnector();
public void startWait();
public void endWait();
public String getParameter( String key );
public String getParameter( String key, String defaultValue );
public boolean canClose();
public String getJifletInfo();
public boolean isActive();
}
This class, when used in conjunction with the SimpleDBUI class, provides a simple shell for database intranet applications.
public abstract class SimpleDBJiflet extends Jiflet
{
// Protected instance variables
protected Menu fileMenu;
protected Menu helpMenu;
// Public constructor
public SimpleDBJiflet( String title, String name, String args[] );
// Public methods
public void init();
public void initializeMenus();
public abstract void initializeUI();
public void connectToDatabase();
public void disconnectFromDatabase();
protected boolean handleMenuEvent( Event event, Object arg );
public boolean saveRecord();
public boolean deleteRecord();
protected void setCopyright( String cpr );
public boolean canClose();
public void setDBRecord( DBRecord theRecord );
public DBRecord getDBRecord();
public void setUIPanel( SimpleDBUI panel );
public SimpleDBUI getUIPanel();
}
The jif.log package contains classes that write entries in common format to either the screen or a disk file.
This class writes commonly formatted entries into a disk file.
public class DiskLog extends RandomAccessFile implements Log
{
// Protected instance variable
protected Log backupLog = null;
// Public constructor
public DiskLog( String name ) throws IOException;
public DiskLog( String logName, String name ) throws IOException;
public DiskLog( String logDir, String logName, String name )
throws IOException;
// Public methods
public void setBackupLog( Log sl );
static public String createLogFileName();
static public String constructFileName( String path, String name );
public void log( char logLevel, String logEntry );
}
This interface defines the constants and methods needed to implement a standard logging mechanism. Any class can implement this interface.
public interface Log
{
// Constants
public static final char DEBUG = 'D';
public static final char INFO = 'I';
public static final char WARNING = 'W';
public static final char ERROR = 'E';
public static final char FATAL = 'F';
// Public method
public void log( char logLevel, String logEntry ) throws IOException;
}
This class provides a common log output to the screen. You can optionally send this information to a window instead of to the standard output (stdout).
public class ScreenLog extends Frame implements Log
{
// Public constructors
public ScreenLog();
public ScreenLog( String name );
public ScreenLog( String windowTitle, boolean popup );
// Public method
public void log( char logLevel, String logEntry );
}
The jif.sql package contains classes that implement SQL or JDBC specific functionality. These classes are either new or extend Java's java.sql packaged classes.
This class allows you to quickly look up a code value from a table. A code value can be any column from a row that has a single key value as its primary key. For instance, if you have an employee table with the employee number as the primary key, you can use this class to retrieve the employee's name. Look in the Employee Benefits sample application for a usage example.
public class CodeLookerUpper
{
// Protected instance variables
protected DBConnector myConnection = null;
protected String mySQL = null;
// Public constructor
public CodeLookerUpper( DBConnector connector, String tableName,
String keyColumnName, String valueColumnName );
// Public method
public String lookupCode( int code_id );
}
This interface defines the methods required to become a JDBC/JIF database connector.
public interface Connector
{
// Public methods
public boolean connect( String user, String password, String server );
public boolean disconnect();
public boolean connected();
public String getConnectionURL();
}
This class implements the Connector interface and provides several of the methods. However, some remain abstract so that you can derive your own database connectors from them.
public abstract class DBConnector implements Connector
{
// Protected instance variables
protected Jiflet myJiflet;
protected Connection myConnection;
protected boolean isConnected = false;
protected Statement myStatement;
protected String lastError;
// Public constructors
public DBConnector( Jiflet jiflet );
public DBConnector();
// Public methods
public boolean connect( String user, String password, String server );
public boolean disconnect();
public boolean connected();
public Statement getStatement();
public void errorLog( String logEntry );
public void log( String logEntry );
public boolean commit();
public boolean rollback();
public boolean close();
public String getLastError();
}
This abstract class encapsulates a row of data from a table. It can be used as a base class for your own table data.
public abstract class DBRecord
{
// Protected instance variables
protected boolean dataChange = false;
protected boolean isNewRecord = false;
// Public constructors
public DBRecord();
public DBRecord( ResultSet rs );
// Public methods
public boolean parseResultSet( ResultSet rs );
public abstract boolean update( DBConnector theConnector, JifPanel ap );;
public abstract boolean deleteRow( DBConnector theConnector );;
public boolean setDataChange( boolean onOff );
public void clear();
public boolean canSave();
public boolean didDataChange();
public void setNewStatus( boolean how );
public boolean getNewStatus();
}
This class implements the remaining methods from DBConnector to provide access to an MSQL data source using JDBC.
public class MSQLConnector extends DBConnector
{
// Protected instance variable
protected String dbUrl;
// Public constructors
public MSQLConnector( Jiflet jiflet, String host, int port, String instance );
public MSQLConnector( String host, int port, String instance );
// Public method
public String getConnectionURL();
}
This class implements the remaining methods from DBConnector to provide access to a Microsoft SQL Server data source using JDBC.
public class MSSQLServerConnector extends DBConnector
{
// Public constructors
public MSSQLServerConnector( Jiflet jiflet );
public MSSQLServerConnector();
// Public method
public String getConnectionURL();
}
This class implements the remaining methods from DBConnector to provide access to an ODBC data source using JDBC.
public class ODBcconnector extends DBConnector
{
// Public constructors
public ODBcconnector( Jiflet jiflet, String dsInfo );
public ODBcconnector( String dsInfo );
// Public method
public String getConnectionURL();
}
This class implements the remaining methods from DBConnector to provide access to an Oracle data source using JDBC.
public class OracleConnector extends DBConnector
{
// Public constructors
public OracleConnector( Jiflet jiflet );
public OracleConnector();
// Public method
public String getConnectionURL();
}
This class encapsulates access to an Oracle sequence. A sequence is an automatic counter that is maintained by the database server. It can be used to generate employee IDs for instance.
public class OracleSequence
{
// Public constructor
public OracleSequence( OracleConnector connector, String sequenceName );
// Public method
public int getNextValue();
public int getCurrentValue();
protected synchronized int getDBSequenceValue( boolean currentVal );
}
This class implements a mock database counter for databases that do not provide native sequences.
public class SequenceGenerator
{
// Public constructors
public SequenceGenerator( DBConnector connector, String table,
String column );
public SequenceGenerator( DBConnector connector );
// Public method
public int getNextValue();
public int getCurrentValue();
protected synchronized void getDBSequenceValue();
}
This interface defines the methods required for a class to provide SQL generation capabilities.
public interface SQLFactory
{
// Public methods
public String generateUpdateSQL( boolean addSet );
public String generateInsertSQL( boolean addParen );
public String getColumnName();
public void setColumnName( String colName );
public boolean isPrimaryKey();
public String getSQL( boolean forWhere );
}
This class implements the remaining methods from DBConnector to provide access to a Sybase data source using JDBC.
public class SybaseConnector extends DBConnector
{
// Public constructors
public SybaseConnector( Jiflet jiflet );
public SybaseConnector();
// Public method
public String getConnectionURL();
}
The jif.util package contains classes that are simply utilitarian in nature. They provide functionality that can be used by almost any software project.
This class implements a timer that calls back the owner when the alarm goes off.
public class CallbackTimer extends Thread
{
// Public constructor
public CallbackTimer( TimeOut target, int interval )
// Public method
public void run()
}
This class extends the Java Properties class to do two things. First it reads the application configuration file. Second, it merges any properties passed in at construction with the read in properties.
public class ConfigProperties extends Properties
{
// Protected instance variable
protected Properties argProperties = new Properties();
// Public constructor
public ConfigProperties( String args[], String fileName );
// Public methods
public int parseArguments( String args[] );
public int parseConfigFile( String appdefaultConfigFile );
protected void setProperties( Properties prop );
}
This class implements a timer that generates an event to the owner when the alarm goes off.
public class EventTimer extends Thread
{
// Public constructor
public EventTimer( Component target, int msInterval )
// Public method
public void run()
}
This class is an all-purpose date formatting class. It allows you to convert the date into a variety of formats.
public class FileDate extends Date
{
// Constants
public final static int MDY = 0;
public final static int DMY = 1;
public final static int YMD = 2;
public final static int MMMDY = 3;
public final static int DMMMY = 4;
public final static int YMMMD = 5;
public final static int MDYYYY = 6;
public final static int DMYYYY = 7;
public final static int YYYYMD = 8;
public final static int MMMDYYYY = 9;
public final static int DMMMYYYY = 10;
public final static int YYYYMMMD = 11;
// Public constructors
public FileDate();
public FileDate( java.util.Date date );
public FileDate( java.sql.Date date );
public FileDate( int y, int m, int d );
// Public methods
public String toFileString();
public static String toFileString( String s );
public static String toFileString( java.util.Date d );
public static String toFileString( java.sql.Date d );
public String toOracleString();
public static String toOracleString( String s );
public static String toOracleString( java.util.Date d );
public static String toOracleString( java.sql.Date d );
public String toNormalString();
public static String toNormalString( String s );
public static String toNormalString( java.util.Date d );
public static String toNormalString( java.sql.Date d );
public static FileDate valueOf( String s ) throws IllegalArgumentException;
public String formatDateToString();
public String formatDateToString( String delimiter, int fmtOpt );
public static String formatDateToString( String s );
public static String formatDateToString( String s, String delimiter );
public static String formatDateToString( String s, String delimiter,
int fmtOpt );
public static String formatDateToString( int y, int m, int d );
public static String formatDateToString( int y, int m, int d,
String delimiter );
public static String formatDateToString( int y, int m, int d,
String delimiter, int fmtOpt );
}
This interface defines the method that a class must implement to receive callback notification of events when using the CallbackTimer class.
public interface TimeOut
{
// Public method
public void timeOut( CallbackTimer timer );
}