All Packages Class Hierarchy This Package Previous Next Index
Class bradel.wordchanger.LineScanner
java.lang.Object
|
+----bradel.wordchanger.LineScanner
- public class LineScanner
- extends Object
The line scanner holds all of the
data objects important for this application.
It uses the excluded words lists to exclude
words from being changed.
The scanner also keeps track of the words
which have to be changed and can say what the
words should be changed to.
The scanner is also responsible for examing
each line of a file.
Notes:
Comments can span multiple lines
Strings cannot span multiple lines
Unicode sequences are not considered
All words that are not in the excluded list
must start with a letter and have a sequence
of letters, digits, and underscores only.
Strings and character literals must be properly formatted
and have starting and end points on the same line
Anything within single quotes is not considered as
words/variables
Creation date: (30/12/2001 2:30:03 PM)
- Author:
- : Borys Bradel
Copyright (c) 2001 Borys Bradel
All rights reserved
-
excludedWordsLists
- array of storage elements that containw words not to change/include
-
inComment
- keeps track of whether the start of the line being examinded is in a multi line comment
-
MAXWORDSPERLINE
- the maximum words per line before overflow occurs
-
STATEAFTERSLASH
- after slash, may be a comment
-
STATEINCHARLITERAL
- in a character literal
-
STATEINCHARLITERALAFTERBACKSLASH
- in a character literal, but next character can be a single quote
-
STATEINSTRING
- in a string
-
STATEINSTRINGAFTERBACKSLASH
- in a string, but next character can be a quote
-
STATEINWORD
- parsing a word
-
STATELINECOMMENT
- a line comment, that's it for this line
-
STATELONGCOMMENT
- a long comment, may or may not end on this line
-
STATELONGCOMMENTAFTERASTERIX
- a long comment which may be broken
-
STATENORMAL
- normal state
-
wordEndIndex
- points to the character immediately after a word
-
wordList
- contains all the words to change
-
wordOverlow
- used when overflow occurs
-
wordsInLine
- the number of words in the current line
-
wordStartIndex
- points to the start of each word
-
LineScanner()
- LineScanner constructor sets objects to null
-
LineScanner(WordStorage[])
- constructs or saves the references of the
important storage elements that this class
depends on.
-
addFromLine(String)
- add the appropriate words from the line specified
the start of the line may or may not be part of
a multi line comment depending on the current
state of inComment
addFromLine and replaceLine are similar
except replaceLine has to store a new line and wirte
that to a buffer
Creation date: (30/12/2001 2:47:03 PM)
-
convertAll(String)
- sets the convertTo field of the WordDataStorage unit
Creation date: (01/01/2002 8:32:13 PM)
-
isExcluded(String)
- checks whether the word is on any of the
excluded lists
Creation date: (31/12/2001 1:38:47 PM)
-
newFile()
- at the top of a file, the first line is not in a comment
Creation date: (30/12/2001 2:46:31 PM)
-
parseLine(String)
- parses the line so that all of the beginning and
end indices of the words will be stored in two
arrays (and an overflow Vector if necessary)
Creation date: (30/12/2001 2:47:03 PM)
-
replaceLine(String, BufferedWriter)
- modify the appropriate words in the line specified
the start of the line may or may not be part of
a multi line comment depending on the current
state of inComment
The new line is writen to the buffered writer
addFromLine and replaceLine are similar
except replaceLine has to store a new line and wirte
that to a buffer
Creation date: (30/12/2001 3:29:20 PM)
-
reverseConvertTo(BufferedReader, String)
- performs a reverse conversion
Creation date: (01/01/2002 10:25:49 PM)
-
toString()
- prints the wordList.
-
writeConversionData(BufferedWriter)
- writes the conversion data out to a file
Creation date: (01/01/2002 10:11:13 PM)
inComment
private boolean inComment
- keeps track of whether the start of the line being examinded is in a multi line comment
excludedWordsLists
private WordStorage excludedWordsLists[]
- array of storage elements that containw words not to change/include
wordList
private WordDataStorage wordList
- contains all the words to change
wordsInLine
private int wordsInLine
- the number of words in the current line
wordStartIndex
private int wordStartIndex[]
- points to the start of each word
wordEndIndex
private int wordEndIndex[]
- points to the character immediately after a word
wordOverlow
private Vector wordOverlow
- used when overflow occurs
MAXWORDSPERLINE
private static final int MAXWORDSPERLINE
- the maximum words per line before overflow occurs
STATENORMAL
private static final int STATENORMAL
- normal state
STATEINWORD
private static final int STATEINWORD
- parsing a word
STATEINSTRING
private static final int STATEINSTRING
- in a string
STATEINSTRINGAFTERBACKSLASH
private static final int STATEINSTRINGAFTERBACKSLASH
- in a string, but next character can be a quote
STATEINCHARLITERAL
private static final int STATEINCHARLITERAL
- in a character literal
STATEINCHARLITERALAFTERBACKSLASH
private static final int STATEINCHARLITERALAFTERBACKSLASH
- in a character literal, but next character can be a single quote
STATEAFTERSLASH
private static final int STATEAFTERSLASH
- after slash, may be a comment
STATELINECOMMENT
private static final int STATELINECOMMENT
- a line comment, that's it for this line
STATELONGCOMMENT
private static final int STATELONGCOMMENT
- a long comment, may or may not end on this line
STATELONGCOMMENTAFTERASTERIX
private static final int STATELONGCOMMENTAFTERASTERIX
- a long comment which may be broken
LineScanner
public LineScanner()
- LineScanner constructor sets objects to null
LineScanner
public LineScanner(WordStorage excludedWordsLists[])
- constructs or saves the references of the
important storage elements that this class
depends on.
Creation date: (30/12/2001 2:40:54 PM)
- Parameters:
- excludedWordsLists - bradel.wordchanger.WordStorage[]
addFromLine
public void addFromLine(String line)
- add the appropriate words from the line specified
the start of the line may or may not be part of
a multi line comment depending on the current
state of inComment
addFromLine and replaceLine are similar
except replaceLine has to store a new line and wirte
that to a buffer
Creation date: (30/12/2001 2:47:03 PM)
- Parameters:
- line - java.lang.String
convertAll
public void convertAll(String prefix)
- sets the convertTo field of the WordDataStorage unit
Creation date: (01/01/2002 8:32:13 PM)
- Parameters:
- prefix - java.lang.String
isExcluded
private boolean isExcluded(String word)
- checks whether the word is on any of the
excluded lists
Creation date: (31/12/2001 1:38:47 PM)
- Parameters:
- word - java.lang.String
- Returns:
- boolean
newFile
public void newFile()
- at the top of a file, the first line is not in a comment
Creation date: (30/12/2001 2:46:31 PM)
parseLine
private void parseLine(String line)
- parses the line so that all of the beginning and
end indices of the words will be stored in two
arrays (and an overflow Vector if necessary)
Creation date: (30/12/2001 2:47:03 PM)
- Parameters:
- line - java.lang.String
replaceLine
public void replaceLine(String line,
BufferedWriter outBuffer)
- modify the appropriate words in the line specified
the start of the line may or may not be part of
a multi line comment depending on the current
state of inComment
The new line is writen to the buffered writer
addFromLine and replaceLine are similar
except replaceLine has to store a new line and wirte
that to a buffer
Creation date: (30/12/2001 3:29:20 PM)
- Parameters:
- line - java.lang.String
- outBuffer - java.io.BufferedWriter
reverseConvertTo
public void reverseConvertTo(BufferedReader conversionData,
String prefix)
- performs a reverse conversion
Creation date: (01/01/2002 10:25:49 PM)
- Parameters:
- conversionData - java.io.BufferedReader
- prefix - String
toString
public String toString()
- prints the wordList.
Creation date: (01/01/2002 1:26:19 PM)
- Returns:
- java.lang.String
- Overrides:
- toString in class Object
writeConversionData
public void writeConversionData(BufferedWriter outWriter)
- writes the conversion data out to a file
Creation date: (01/01/2002 10:11:13 PM)
- Parameters:
- outWriter - java.io.BufferedWriter
All Packages Class Hierarchy This Package Previous Next Index