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

Variable Index

 o excludedWordsLists
array of storage elements that containw words not to change/include
 o inComment
keeps track of whether the start of the line being examinded is in a multi line comment
 o MAXWORDSPERLINE
the maximum words per line before overflow occurs
 o STATEAFTERSLASH
after slash, may be a comment
 o STATEINCHARLITERAL
in a character literal
 o STATEINCHARLITERALAFTERBACKSLASH
in a character literal, but next character can be a single quote
 o STATEINSTRING
in a string
 o STATEINSTRINGAFTERBACKSLASH
in a string, but next character can be a quote
 o STATEINWORD
parsing a word
 o STATELINECOMMENT
a line comment, that's it for this line
 o STATELONGCOMMENT
a long comment, may or may not end on this line
 o STATELONGCOMMENTAFTERASTERIX
a long comment which may be broken
 o STATENORMAL
normal state
 o wordEndIndex
points to the character immediately after a word
 o wordList
contains all the words to change
 o wordOverlow
used when overflow occurs
 o wordsInLine
the number of words in the current line
 o wordStartIndex
points to the start of each word

Constructor Index

 o LineScanner()
LineScanner constructor sets objects to null
 o LineScanner(WordStorage[])
constructs or saves the references of the important storage elements that this class depends on.

Method Index

 o 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)
 o convertAll(String)
sets the convertTo field of the WordDataStorage unit Creation date: (01/01/2002 8:32:13 PM)
 o isExcluded(String)
checks whether the word is on any of the excluded lists Creation date: (31/12/2001 1:38:47 PM)
 o newFile()
at the top of a file, the first line is not in a comment Creation date: (30/12/2001 2:46:31 PM)
 o 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)
 o 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)
 o reverseConvertTo(BufferedReader, String)
performs a reverse conversion Creation date: (01/01/2002 10:25:49 PM)
 o toString()
prints the wordList.
 o writeConversionData(BufferedWriter)
writes the conversion data out to a file Creation date: (01/01/2002 10:11:13 PM)

Variables

 o inComment
 private boolean inComment
keeps track of whether the start of the line being examinded is in a multi line comment

 o excludedWordsLists
 private WordStorage excludedWordsLists[]
array of storage elements that containw words not to change/include

 o wordList
 private WordDataStorage wordList
contains all the words to change

 o wordsInLine
 private int wordsInLine
the number of words in the current line

 o wordStartIndex
 private int wordStartIndex[]
points to the start of each word

 o wordEndIndex
 private int wordEndIndex[]
points to the character immediately after a word

 o wordOverlow
 private Vector wordOverlow
used when overflow occurs

 o MAXWORDSPERLINE
 private static final int MAXWORDSPERLINE
the maximum words per line before overflow occurs

 o STATENORMAL
 private static final int STATENORMAL
normal state

 o STATEINWORD
 private static final int STATEINWORD
parsing a word

 o STATEINSTRING
 private static final int STATEINSTRING
in a string

 o STATEINSTRINGAFTERBACKSLASH
 private static final int STATEINSTRINGAFTERBACKSLASH
in a string, but next character can be a quote

 o STATEINCHARLITERAL
 private static final int STATEINCHARLITERAL
in a character literal

 o STATEINCHARLITERALAFTERBACKSLASH
 private static final int STATEINCHARLITERALAFTERBACKSLASH
in a character literal, but next character can be a single quote

 o STATEAFTERSLASH
 private static final int STATEAFTERSLASH
after slash, may be a comment

 o STATELINECOMMENT
 private static final int STATELINECOMMENT
a line comment, that's it for this line

 o STATELONGCOMMENT
 private static final int STATELONGCOMMENT
a long comment, may or may not end on this line

 o STATELONGCOMMENTAFTERASTERIX
 private static final int STATELONGCOMMENTAFTERASTERIX
a long comment which may be broken

Constructors

 o LineScanner
 public LineScanner()
LineScanner constructor sets objects to null

 o 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[]

Methods

 o 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
 o 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
 o 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
 o 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)

 o 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
 o 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
 o 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
 o 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
 o 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