Java Reference
In-Depth Information
The Tabs class provides two methods: settabpos() and istabstop() . Example 3-9 is the
source for the Tabs class.
Example 3-9. Tabs.java
public
public class
Tabs {
/** tabs every so often */
public
class Tabs
public final
final static
static int
int DEFTABSPACE =
8 ;
/** the current tab stop setting. */
protected
protected int
int tabSpace = DEFTABSPACE ;
/** The longest line that we initially set tabs for. */
public
public final
final static
static int
int MAXLINE = 255 ;
/** Construct a Tabs object with a given tab stop settings */
public
public Tabs ( int
int n ) {
iif ( n <= 0 ) {
n = 1 ;
}
tabSpace = n ;
}
/** Construct a Tabs object with a default tab stop settings */
public
public Tabs () {
this
this ( DEFTABSPACE );
}
/**
* @return Returns the tabSpace.
*/
public
public int
int getTabSpacing () {
return
return tabSpace ;
}
/** isTabStop - returns true if given column is a tab stop.
* @param col - the current column number
*/
public
public boolean
boolean isTabStop ( int
int col ) {
iif ( col <= 0 )
return
return false
false ;
return
return ( col + 1 ) % tabSpace == 0 ;
}
}
Search WWH ::




Custom Search