|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsystem.CommentConverter
This class opens up the given file and converts the comments when you call the various methods. It can also add comments where there are not comments yet. After you made all your changes, call save() to write them to the file.
Field Summary | |
protected kirk.io.FileLineList |
file
The FileLineList that is used for editing the file. |
protected boolean |
starinsets
Whether or not this CommentConverter uses the star insets style of javadoc commenting. |
Constructor Summary | |
CommentConverter(String filename,
boolean starinsets)
Constructs a new CommentConverter over filename, and sets the appropriate javadoc style. |
Method Summary | |
void |
addAttributeComments(String[] tags,
int whitelines)
Adds all the javadoc attribute comments to all attributes without comment in this file using the set style. |
void |
addClassComments(String[] tags,
int whitelines)
Adds all the javadoc class comments to all classes without comment in this file using the set style. |
protected void |
addComment(int index,
String[] tags,
int whitelines)
Adds comment above index with the set javadoc style comment. |
void |
addMethodComments(String[] tags,
int whitelines)
Adds all the javadoc method comments to all methods without comment in this file using the set style. |
void |
convertAttributeComments(String[] tags)
Converts all the non-javadoc attribute comments in this file to javadoc comments using the set style. |
void |
convertClassComments(String[] tags)
Converts all the non-javadoc class comments in this file to javadoc comments using the set style. |
void |
convertMethodComments(String[] tags)
Converts all the non-javadoc method comments in this file to javadoc comments using the set style. |
protected String[] |
convertMethodTags(int index,
String[] tags)
Goes through tags and convert any special javadoc tags that have to with the method signature at index. |
protected String |
getIndentation(int index)
Returns the indentation of the line at index as a String. |
protected boolean |
isAttribute(int index)
Returns whether the line indicated by index is an attribute line. |
protected boolean |
isClass(int index)
Returns whether the line indicated by index is a class line. |
protected boolean |
isMethod(int index)
Returns whether the line indicated by index is a method line. |
protected boolean |
isToken(int fileindex,
int tokenindex,
String string,
boolean precise)
Returns whether the token on tokenindex in the String at index in file, is equal to the passed string, when tokenized on whitespace. |
protected void |
replaceComment(int index,
String[] tags)
Replaces the comment above index with the set javadoc style comment. |
void |
save(String filename)
Saves the changes this class made to the file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected kirk.io.FileLineList file
protected boolean starinsets
Constructor Detail |
public CommentConverter(String filename, boolean starinsets) throws IOException
filename
- The name of the file to be opened.starinsets
- The javadoc style. true when the star insets should be used,
false for no star insets.
IOException
- When an IO error is encountered.Method Detail |
public void save(String filename) throws IOException
filename
- The name of the file to save to.
IOException
public void convertClassComments(String[] tags)
tags
- An array of Strings. Each String is a javadoc tag or something
that the user wanted in all class comments.public void addClassComments(String[] tags, int whitelines)
tags
- An array of Strings. Each String is a javadoc tag or something
that the user wanted in all class comments.whitelines
- The number of white lines that has to be in each class
comment.public void convertMethodComments(String[] tags) throws Exception
tags
- An array of Strings. Each String is a javadoc tag or something
that the user wanted in all method comments.
Exception
- When a file format error is encountered.public void addMethodComments(String[] tags, int whitelines) throws Exception
tags
- An array of Strings. Each String is a javadoc tag or something
that the user wanted in all method comments.whitelines
- The number of white lines that has to be in each method
comment.
Exception
- When a file format error is encountered.public void convertAttributeComments(String[] tags)
tags
- An array of Strings. Each String is a javadoc tag or something
that the user wanted in all attribute comments.public void addAttributeComments(String[] tags, int whitelines)
tags
- An array of Strings. Each String is a javadoc tag or something
that the user wanted in all attribute comments.whitelines
- The number of white lines that has to be in each attribute
comment.protected String[] convertMethodTags(int index, String[] tags) throws Exception
index
- The index of the method signature where the info comes from.tags
- The tags to be converted.
Exception
- When a file format error is encountered.protected boolean isClass(int index)
Returns whether the line indicated by index is a class line. Examples of class lines:
public class Moo {
private class Baa extends Nothing {
etc.
index
- The line that needs to be checked.
protected boolean isMethod(int index)
Returns whether the line indicated by index is a method line. Examples of method lines:
public void baabaa(int moo);
public static final Fart getFartFromFartCollection(int index) throws
FartNotFoundException {
etc.
index
- The line that needs to be checked.
protected boolean isAttribute(int index)
Returns whether the line indicated by index is an attribute line. Examples of attribute lines:
public final String filetodestroy =
"C:\Windows\win.ini";
private transient int badattr;
etc.
index
- The line that needs to be checked.
protected boolean isToken(int fileindex, int tokenindex, String string, boolean precise)
Returns whether the token on tokenindex in the String at index in file, is equal to the passed string, when tokenized on whitespace.
A bit cheating, but if you specify a negative number as an index then any token is allowed to match.
fileindex
- The index of the String to check.tokenindex
- The index of the token to check.string
- The string to be checked for.precise
- Whether the matching has to be precise, or it has to starts
with string.
string
. false in any case if
tokenindex is larger than the amount of tokens in the String, or when
fileindex
is out of bounds.protected void replaceComment(int index, String[] tags)
index
- The index of the method/class/attribute that needs comment
converted.tags
- The tags to be inserted.protected void addComment(int index, String[] tags, int whitelines)
index
- The index of the method/class/attribute that needs comment
converted.tags
- The tags to be inserted.whitelines
- The amount of white lines to be inserted.protected String getIndentation(int index)
index
- The index of the line of which the indentation is to be returned.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |