|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.presents.tools.SourceFile
public class SourceFile
Reads in a source file, allows the replacement of a "generated fields" and "generated methods" section and writing of the file back out to the disk.
| Field Summary | |
|---|---|
protected List<String> |
_lines
|
protected int |
_mend
|
protected int |
_mstart
|
protected int |
_nend
|
protected int |
_nstart
|
protected static String |
FIELDS_END
|
protected static String |
FIELDS_START
|
protected static String |
MARKER
|
protected static String |
METHODS_END
|
protected static String |
METHODS_START
|
| Constructor Summary | |
|---|---|
SourceFile()
|
|
| Method Summary | |
|---|---|
protected void |
addOrRemoveGeneratedImport(boolean add)
Add or remove an import for "@Generated", if needed. |
protected void |
check(File source,
String mname,
int mline,
String fname,
int fline)
Helper function for sanity checking marker existence. |
boolean |
containsString(String text)
Returns true if the supplied text appears in the non-auto-generated section. |
String |
generate(String fsection,
String msection)
Writes the code out to the specified file. |
void |
readFrom(File source)
Reads the code from the supplied source file. |
protected String |
safeGetLine(int index)
Safely gets the indexth line, returning the empty string if we exceed the
length of the array. |
protected void |
writeln(BufferedWriter bout,
String line)
Helper function for writing a string and a newline to a writer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected List<String> _lines
protected int _nstart
protected int _nend
protected int _mstart
protected int _mend
protected static final String MARKER
protected static final String FIELDS_START
protected static final String FIELDS_END
protected static final String METHODS_START
protected static final String METHODS_END
| Constructor Detail |
|---|
public SourceFile()
| Method Detail |
|---|
public void readFrom(File source)
throws IOException
IOExceptionpublic boolean containsString(String text)
public String generate(String fsection,
String msection)
throws IOException
fsection - the new "generated fields" to write to the file, or null.msection - the new "generated methods" to write to the file, or null.
IOException
protected void check(File source,
String mname,
int mline,
String fname,
int fline)
throws IOException
IOExceptionprotected String safeGetLine(int index)
indexth line, returning the empty string if we exceed the
length of the array.
protected void writeln(BufferedWriter bout,
String line)
throws IOException
IOExceptionprotected void addOrRemoveGeneratedImport(boolean add)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||