Top Description Fields Constructors Methods
org.codehaus.commons.compiler.util

public abstract Class LineAndColumnTracker

extends Object
Class Inheritance
Imports
java.util.regex.Pattern

Keeps track of "line numbers" and "column numbers" while a char stream is being processed. Line breaks are identified as defined by the \R pattern of Pattern. Initially, line number and column number are 1.

This class has no public constructors, instead, use one of the static "factory methods".

See Also
create()

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_TAB_WIDTH

The default "tab width".

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract void
consume(char c)

Consumes the next character of the stream.

public static LineAndColumnTracker

Returns:

A LineAndColumnTracker instance
create
()

public abstract int
getColumnNumber()

Returns the column number of the previously consumed character; 1 after a line separator character has been consumed, 2 after the first non-line-separator character, and so forth.

public abstract int
getLineNumber()

Returns the line number of the previously consumed character (starting at 1).

public abstract void
reset()

Resets the current line number to 1 and the current column number to one.

public abstract void
setColumnNumber(int columnNumber)

Sets the "current column number" to the given value.

public abstract void
setLineNumber(int lineNumber)

Sets the "current line number" to the given value.

public abstract void
setTabWidth(int tabWidth)

Reconfigures the TAB width.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_TAB_WIDTHback to summary
public static final int DEFAULT_TAB_WIDTH

The default "tab width".

See Also
setTabWidth(int)

Constructor Detail

LineAndColumnTrackerback to summary
public LineAndColumnTracker()

Method Detail

consumeback to summary
public abstract void consume(char c)

Consumes the next character of the stream.

createback to summary
public static LineAndColumnTracker create()
Returns:LineAndColumnTracker

A LineAndColumnTracker instance

getColumnNumberback to summary
public abstract int getColumnNumber()

Returns the column number of the previously consumed character; 1 after a line separator character has been consumed, 2 after the first non-line-separator character, and so forth.

getLineNumberback to summary
public abstract int getLineNumber()

Returns the line number of the previously consumed character (starting at 1). Line separator characters belong to the "next" line.

resetback to summary
public abstract void reset()

Resets the current line number to 1 and the current column number to one. (The configured tab width remains.)

setColumnNumberback to summary
public abstract void setColumnNumber(int columnNumber)

Sets the "current column number" to the given value.

setLineNumberback to summary
public abstract void setLineNumber(int lineNumber)

Sets the "current line number" to the given value.

setTabWidthback to summary
public abstract void setTabWidth(int tabWidth)

Reconfigures the TAB width. Value 1 will treat TAB characters just like any other (non-line-break) character. The default tab with is DEFAULT_TAB_WIDTH (8).