Skip to content

Commit

Permalink
DotFormatter is now a real singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
johncurrier committed Aug 7, 2005
1 parent fc90909 commit 2e211d0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/net/sourceforge/schemaspy/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static void main(String[] argv) {
File graphsDir = new File(outputDir, "graphs/summary");
String dotBaseFilespec = "relationships";
out = new LineWriter(new FileWriter(new File(graphsDir, dotBaseFilespec + ".real.dot")));
WriteStats stats = new DotFormatter().writeRelationships(tables, false, out);
WriteStats stats = DotFormatter.getInstance().writeRelationships(tables, false, out);
boolean hasRelationships = stats.getNumTablesWritten() > 0 || stats.getNumViewsWritten() > 0;
out.close();

Expand All @@ -164,7 +164,7 @@ public static void main(String[] argv) {

File impliedDotFile = new File(graphsDir, dotBaseFilespec + ".implied.dot");
out = new LineWriter(new FileWriter(impliedDotFile));
boolean hasImplied = new DotFormatter().writeRelationships(tables, true, out).wroteImplied();
boolean hasImplied = DotFormatter.getInstance().writeRelationships(tables, true, out).wroteImplied();
out.close();
if (!hasImplied)
impliedDotFile.delete();
Expand Down
12 changes: 12 additions & 0 deletions src/net/sourceforge/schemaspy/view/DotFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
* @author John Currier
*/
public class DotFormatter {
private static DotFormatter instance = new DotFormatter();

/**
* Singleton - prevent creation
*/
private DotFormatter() {
}

public static DotFormatter getInstance() {
return instance;
}

/**
* Write relationships associated with the given table
*
Expand Down
2 changes: 1 addition & 1 deletion src/net/sourceforge/schemaspy/view/HtmlGraphFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public boolean writeOrphans(Database db, List orphanTables, boolean hasRelations
File graphFile = new File(graphDir, dotBaseFilespec + ".1degree.png");

LineWriter dotOut = new LineWriter(new FileWriter(dotFile));
new DotFormatter().writeOrphan(table, dotOut);
DotFormatter.getInstance().writeOrphan(table, dotOut);
dotOut.close();
try {
if (!dot.generateGraph(dotFile, graphFile))
Expand Down

0 comments on commit 2e211d0

Please sign in to comment.